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

com.google.cloud.servicedirectory.v1beta1.stub.HttpJsonRegistrationServiceStub Maven / Gradle / Ivy

/*
 * 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.servicedirectory.v1beta1.stub;

import static com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListEndpointsPagedResponse;
import static com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListLocationsPagedResponse;
import static com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListNamespacesPagedResponse;
import static com.google.cloud.servicedirectory.v1beta1.RegistrationServiceClient.ListServicesPagedResponse;

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.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.rpc.ClientContext;
import com.google.api.gax.rpc.RequestParamsBuilder;
import com.google.api.gax.rpc.UnaryCallable;
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.cloud.servicedirectory.v1beta1.CreateEndpointRequest;
import com.google.cloud.servicedirectory.v1beta1.CreateNamespaceRequest;
import com.google.cloud.servicedirectory.v1beta1.CreateServiceRequest;
import com.google.cloud.servicedirectory.v1beta1.DeleteEndpointRequest;
import com.google.cloud.servicedirectory.v1beta1.DeleteNamespaceRequest;
import com.google.cloud.servicedirectory.v1beta1.DeleteServiceRequest;
import com.google.cloud.servicedirectory.v1beta1.Endpoint;
import com.google.cloud.servicedirectory.v1beta1.GetEndpointRequest;
import com.google.cloud.servicedirectory.v1beta1.GetNamespaceRequest;
import com.google.cloud.servicedirectory.v1beta1.GetServiceRequest;
import com.google.cloud.servicedirectory.v1beta1.ListEndpointsRequest;
import com.google.cloud.servicedirectory.v1beta1.ListEndpointsResponse;
import com.google.cloud.servicedirectory.v1beta1.ListNamespacesRequest;
import com.google.cloud.servicedirectory.v1beta1.ListNamespacesResponse;
import com.google.cloud.servicedirectory.v1beta1.ListServicesRequest;
import com.google.cloud.servicedirectory.v1beta1.ListServicesResponse;
import com.google.cloud.servicedirectory.v1beta1.Namespace;
import com.google.cloud.servicedirectory.v1beta1.Service;
import com.google.cloud.servicedirectory.v1beta1.UpdateEndpointRequest;
import com.google.cloud.servicedirectory.v1beta1.UpdateNamespaceRequest;
import com.google.cloud.servicedirectory.v1beta1.UpdateServiceRequest;
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.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 RegistrationService service API.
 *
 * 

This class is for advanced usage and reflects the underlying API directly. */ @BetaApi @Generated("by gapic-generator-java") public class HttpJsonRegistrationServiceStub extends RegistrationServiceStub { private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); private static final ApiMethodDescriptor createNamespaceMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/CreateNamespace") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{parent=projects/*/locations/*}/namespaces", 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, "namespaceId", request.getNamespaceId()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("namespace", request.getNamespace(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Namespace.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor listNamespacesMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/ListNamespaces") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{parent=projects/*/locations/*}/namespaces", 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(ListNamespacesResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getNamespaceMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/GetNamespace") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{name=projects/*/locations/*/namespaces/*}", 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(Namespace.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor updateNamespaceMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/UpdateNamespace") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{namespace.name=projects/*/locations/*/namespaces/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "namespace.name", request.getNamespace().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("namespace", request.getNamespace(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Namespace.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor deleteNamespaceMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/DeleteNamespace") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{name=projects/*/locations/*/namespaces/*}", 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 createServiceMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/CreateService") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{parent=projects/*/locations/*/namespaces/*}/services", 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, "serviceId", request.getServiceId()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("service", request.getService(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Service.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor listServicesMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/ListServices") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{parent=projects/*/locations/*/namespaces/*}/services", 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(ListServicesResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getServiceMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.servicedirectory.v1beta1.RegistrationService/GetService") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{name=projects/*/locations/*/namespaces/*/services/*}", 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(Service.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor updateServiceMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/UpdateService") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{service.name=projects/*/locations/*/namespaces/*/services/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "service.name", request.getService().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("service", request.getService(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Service.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor deleteServiceMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/DeleteService") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{name=projects/*/locations/*/namespaces/*/services/*}", 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 createEndpointMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/CreateEndpoint") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{parent=projects/*/locations/*/namespaces/*/services/*}/endpoints", 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, "endpointId", request.getEndpointId()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("endpoint", request.getEndpoint(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Endpoint.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor listEndpointsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/ListEndpoints") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{parent=projects/*/locations/*/namespaces/*/services/*}/endpoints", 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(ListEndpointsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getEndpointMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/GetEndpoint") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{name=projects/*/locations/*/namespaces/*/services/*/endpoints/*}", 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(Endpoint.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor updateEndpointMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/UpdateEndpoint") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{endpoint.name=projects/*/locations/*/namespaces/*/services/*/endpoints/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "endpoint.name", request.getEndpoint().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("endpoint", request.getEndpoint(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Endpoint.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor deleteEndpointMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/DeleteEndpoint") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{name=projects/*/locations/*/namespaces/*/services/*/endpoints/*}", 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 getIamPolicyMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/GetIamPolicy") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{resource=projects/*/locations/*/namespaces/*}:getIamPolicy", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "resource", request.getResource()); return fields; }) .setAdditionalPaths( "/v1beta1/{resource=projects/*/locations/*/namespaces/*/services/*}:getIamPolicy", "/v1beta1/{resource=projects/*/locations/*/namespaces/*/workloads/*}: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 setIamPolicyMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/SetIamPolicy") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{resource=projects/*/locations/*/namespaces/*}:setIamPolicy", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "resource", request.getResource()); return fields; }) .setAdditionalPaths( "/v1beta1/{resource=projects/*/locations/*/namespaces/*/services/*}:setIamPolicy", "/v1beta1/{resource=projects/*/locations/*/namespaces/*/workloads/*}: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 testIamPermissionsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.servicedirectory.v1beta1.RegistrationService/TestIamPermissions") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{resource=projects/*/locations/*/namespaces/*}:testIamPermissions", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "resource", request.getResource()); return fields; }) .setAdditionalPaths( "/v1beta1/{resource=projects/*/locations/*/namespaces/*/services/*}:testIamPermissions", "/v1beta1/{resource=projects/*/locations/*/namespaces/*/workloads/*}: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 listLocationsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.location.Locations/ListLocations") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{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( "/v1beta1/{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 createNamespaceCallable; private final UnaryCallable listNamespacesCallable; private final UnaryCallable listNamespacesPagedCallable; private final UnaryCallable getNamespaceCallable; private final UnaryCallable updateNamespaceCallable; private final UnaryCallable deleteNamespaceCallable; private final UnaryCallable createServiceCallable; private final UnaryCallable listServicesCallable; private final UnaryCallable listServicesPagedCallable; private final UnaryCallable getServiceCallable; private final UnaryCallable updateServiceCallable; private final UnaryCallable deleteServiceCallable; private final UnaryCallable createEndpointCallable; private final UnaryCallable listEndpointsCallable; private final UnaryCallable listEndpointsPagedCallable; private final UnaryCallable getEndpointCallable; private final UnaryCallable updateEndpointCallable; private final UnaryCallable deleteEndpointCallable; private final UnaryCallable getIamPolicyCallable; private final UnaryCallable setIamPolicyCallable; private final UnaryCallable testIamPermissionsCallable; private final UnaryCallable listLocationsCallable; private final UnaryCallable listLocationsPagedCallable; private final UnaryCallable getLocationCallable; private final BackgroundResource backgroundResources; private final HttpJsonStubCallableFactory callableFactory; public static final HttpJsonRegistrationServiceStub create( RegistrationServiceStubSettings settings) throws IOException { return new HttpJsonRegistrationServiceStub(settings, ClientContext.create(settings)); } public static final HttpJsonRegistrationServiceStub create(ClientContext clientContext) throws IOException { return new HttpJsonRegistrationServiceStub( RegistrationServiceStubSettings.newHttpJsonBuilder().build(), clientContext); } public static final HttpJsonRegistrationServiceStub create( ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { return new HttpJsonRegistrationServiceStub( RegistrationServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of HttpJsonRegistrationServiceStub, 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 HttpJsonRegistrationServiceStub( RegistrationServiceStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new HttpJsonRegistrationServiceCallableFactory()); } /** * Constructs an instance of HttpJsonRegistrationServiceStub, 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 HttpJsonRegistrationServiceStub( RegistrationServiceStubSettings settings, ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; HttpJsonCallSettings createNamespaceTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createNamespaceMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listNamespacesTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listNamespacesMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getNamespaceTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getNamespaceMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings updateNamespaceTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateNamespaceMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("namespace.name", String.valueOf(request.getNamespace().getName())); return builder.build(); }) .build(); HttpJsonCallSettings deleteNamespaceTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteNamespaceMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings createServiceTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createServiceMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listServicesTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listServicesMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getServiceTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getServiceMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings updateServiceTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateServiceMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("service.name", String.valueOf(request.getService().getName())); return builder.build(); }) .build(); HttpJsonCallSettings deleteServiceTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteServiceMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings createEndpointTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createEndpointMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listEndpointsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listEndpointsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getEndpointTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getEndpointMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings updateEndpointTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateEndpointMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("endpoint.name", String.valueOf(request.getEndpoint().getName())); return builder.build(); }) .build(); HttpJsonCallSettings deleteEndpointTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteEndpointMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); 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 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 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 listLocationsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listLocationsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings getLocationTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getLocationMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); this.createNamespaceCallable = callableFactory.createUnaryCallable( createNamespaceTransportSettings, settings.createNamespaceSettings(), clientContext); this.listNamespacesCallable = callableFactory.createUnaryCallable( listNamespacesTransportSettings, settings.listNamespacesSettings(), clientContext); this.listNamespacesPagedCallable = callableFactory.createPagedCallable( listNamespacesTransportSettings, settings.listNamespacesSettings(), clientContext); this.getNamespaceCallable = callableFactory.createUnaryCallable( getNamespaceTransportSettings, settings.getNamespaceSettings(), clientContext); this.updateNamespaceCallable = callableFactory.createUnaryCallable( updateNamespaceTransportSettings, settings.updateNamespaceSettings(), clientContext); this.deleteNamespaceCallable = callableFactory.createUnaryCallable( deleteNamespaceTransportSettings, settings.deleteNamespaceSettings(), clientContext); this.createServiceCallable = callableFactory.createUnaryCallable( createServiceTransportSettings, settings.createServiceSettings(), clientContext); this.listServicesCallable = callableFactory.createUnaryCallable( listServicesTransportSettings, settings.listServicesSettings(), clientContext); this.listServicesPagedCallable = callableFactory.createPagedCallable( listServicesTransportSettings, settings.listServicesSettings(), clientContext); this.getServiceCallable = callableFactory.createUnaryCallable( getServiceTransportSettings, settings.getServiceSettings(), clientContext); this.updateServiceCallable = callableFactory.createUnaryCallable( updateServiceTransportSettings, settings.updateServiceSettings(), clientContext); this.deleteServiceCallable = callableFactory.createUnaryCallable( deleteServiceTransportSettings, settings.deleteServiceSettings(), clientContext); this.createEndpointCallable = callableFactory.createUnaryCallable( createEndpointTransportSettings, settings.createEndpointSettings(), clientContext); this.listEndpointsCallable = callableFactory.createUnaryCallable( listEndpointsTransportSettings, settings.listEndpointsSettings(), clientContext); this.listEndpointsPagedCallable = callableFactory.createPagedCallable( listEndpointsTransportSettings, settings.listEndpointsSettings(), clientContext); this.getEndpointCallable = callableFactory.createUnaryCallable( getEndpointTransportSettings, settings.getEndpointSettings(), clientContext); this.updateEndpointCallable = callableFactory.createUnaryCallable( updateEndpointTransportSettings, settings.updateEndpointSettings(), clientContext); this.deleteEndpointCallable = callableFactory.createUnaryCallable( deleteEndpointTransportSettings, settings.deleteEndpointSettings(), clientContext); this.getIamPolicyCallable = callableFactory.createUnaryCallable( getIamPolicyTransportSettings, settings.getIamPolicySettings(), clientContext); this.setIamPolicyCallable = callableFactory.createUnaryCallable( setIamPolicyTransportSettings, settings.setIamPolicySettings(), clientContext); this.testIamPermissionsCallable = callableFactory.createUnaryCallable( testIamPermissionsTransportSettings, settings.testIamPermissionsSettings(), clientContext); this.listLocationsCallable = callableFactory.createUnaryCallable( listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); this.listLocationsPagedCallable = callableFactory.createPagedCallable( listLocationsTransportSettings, settings.listLocationsSettings(), clientContext); this.getLocationCallable = callableFactory.createUnaryCallable( getLocationTransportSettings, settings.getLocationSettings(), clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } @InternalApi public static List getMethodDescriptors() { List methodDescriptors = new ArrayList<>(); methodDescriptors.add(createNamespaceMethodDescriptor); methodDescriptors.add(listNamespacesMethodDescriptor); methodDescriptors.add(getNamespaceMethodDescriptor); methodDescriptors.add(updateNamespaceMethodDescriptor); methodDescriptors.add(deleteNamespaceMethodDescriptor); methodDescriptors.add(createServiceMethodDescriptor); methodDescriptors.add(listServicesMethodDescriptor); methodDescriptors.add(getServiceMethodDescriptor); methodDescriptors.add(updateServiceMethodDescriptor); methodDescriptors.add(deleteServiceMethodDescriptor); methodDescriptors.add(createEndpointMethodDescriptor); methodDescriptors.add(listEndpointsMethodDescriptor); methodDescriptors.add(getEndpointMethodDescriptor); methodDescriptors.add(updateEndpointMethodDescriptor); methodDescriptors.add(deleteEndpointMethodDescriptor); methodDescriptors.add(getIamPolicyMethodDescriptor); methodDescriptors.add(setIamPolicyMethodDescriptor); methodDescriptors.add(testIamPermissionsMethodDescriptor); methodDescriptors.add(listLocationsMethodDescriptor); methodDescriptors.add(getLocationMethodDescriptor); return methodDescriptors; } @Override public UnaryCallable createNamespaceCallable() { return createNamespaceCallable; } @Override public UnaryCallable listNamespacesCallable() { return listNamespacesCallable; } @Override public UnaryCallable listNamespacesPagedCallable() { return listNamespacesPagedCallable; } @Override public UnaryCallable getNamespaceCallable() { return getNamespaceCallable; } @Override public UnaryCallable updateNamespaceCallable() { return updateNamespaceCallable; } @Override public UnaryCallable deleteNamespaceCallable() { return deleteNamespaceCallable; } @Override public UnaryCallable createServiceCallable() { return createServiceCallable; } @Override public UnaryCallable listServicesCallable() { return listServicesCallable; } @Override public UnaryCallable listServicesPagedCallable() { return listServicesPagedCallable; } @Override public UnaryCallable getServiceCallable() { return getServiceCallable; } @Override public UnaryCallable updateServiceCallable() { return updateServiceCallable; } @Override public UnaryCallable deleteServiceCallable() { return deleteServiceCallable; } @Override public UnaryCallable createEndpointCallable() { return createEndpointCallable; } @Override public UnaryCallable listEndpointsCallable() { return listEndpointsCallable; } @Override public UnaryCallable listEndpointsPagedCallable() { return listEndpointsPagedCallable; } @Override public UnaryCallable getEndpointCallable() { return getEndpointCallable; } @Override public UnaryCallable updateEndpointCallable() { return updateEndpointCallable; } @Override public UnaryCallable deleteEndpointCallable() { return deleteEndpointCallable; } @Override public UnaryCallable getIamPolicyCallable() { return getIamPolicyCallable; } @Override public UnaryCallable setIamPolicyCallable() { return setIamPolicyCallable; } @Override public UnaryCallable testIamPermissionsCallable() { return testIamPermissionsCallable; } @Override public UnaryCallable listLocationsCallable() { return listLocationsCallable; } @Override public UnaryCallable listLocationsPagedCallable() { return listLocationsPagedCallable; } @Override public UnaryCallable getLocationCallable() { return getLocationCallable; } @Override public final void close() { try { backgroundResources.close(); } catch (RuntimeException e) { throw e; } catch (Exception e) { throw new IllegalStateException("Failed to close resource", e); } } @Override public void shutdown() { backgroundResources.shutdown(); } @Override public boolean isShutdown() { return backgroundResources.isShutdown(); } @Override public boolean isTerminated() { return backgroundResources.isTerminated(); } @Override public void shutdownNow() { backgroundResources.shutdownNow(); } @Override public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { return backgroundResources.awaitTermination(duration, unit); } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy