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

com.google.cloud.privilegedaccessmanager.v1.stub.HttpJsonPrivilegedAccessManagerStub Maven / Gradle / Ivy

Go to download

Privileged Access Manager API Privileged Access Manager (PAM) helps you on your journey towards least privilege and helps mitigate risks tied to privileged access misuse or abuse.

There is a newer version: 0.6.0
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.privilegedaccessmanager.v1.stub;

import static com.google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManagerClient.ListEntitlementsPagedResponse;
import static com.google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManagerClient.ListGrantsPagedResponse;
import static com.google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManagerClient.ListLocationsPagedResponse;
import static com.google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManagerClient.SearchEntitlementsPagedResponse;
import static com.google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManagerClient.SearchGrantsPagedResponse;

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.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.privilegedaccessmanager.v1.ApproveGrantRequest;
import com.google.cloud.privilegedaccessmanager.v1.CheckOnboardingStatusRequest;
import com.google.cloud.privilegedaccessmanager.v1.CheckOnboardingStatusResponse;
import com.google.cloud.privilegedaccessmanager.v1.CreateEntitlementRequest;
import com.google.cloud.privilegedaccessmanager.v1.CreateGrantRequest;
import com.google.cloud.privilegedaccessmanager.v1.DeleteEntitlementRequest;
import com.google.cloud.privilegedaccessmanager.v1.DenyGrantRequest;
import com.google.cloud.privilegedaccessmanager.v1.Entitlement;
import com.google.cloud.privilegedaccessmanager.v1.GetEntitlementRequest;
import com.google.cloud.privilegedaccessmanager.v1.GetGrantRequest;
import com.google.cloud.privilegedaccessmanager.v1.Grant;
import com.google.cloud.privilegedaccessmanager.v1.ListEntitlementsRequest;
import com.google.cloud.privilegedaccessmanager.v1.ListEntitlementsResponse;
import com.google.cloud.privilegedaccessmanager.v1.ListGrantsRequest;
import com.google.cloud.privilegedaccessmanager.v1.ListGrantsResponse;
import com.google.cloud.privilegedaccessmanager.v1.OperationMetadata;
import com.google.cloud.privilegedaccessmanager.v1.RevokeGrantRequest;
import com.google.cloud.privilegedaccessmanager.v1.SearchEntitlementsRequest;
import com.google.cloud.privilegedaccessmanager.v1.SearchEntitlementsResponse;
import com.google.cloud.privilegedaccessmanager.v1.SearchGrantsRequest;
import com.google.cloud.privilegedaccessmanager.v1.SearchGrantsResponse;
import com.google.cloud.privilegedaccessmanager.v1.UpdateEntitlementRequest;
import com.google.common.collect.ImmutableMap;
import com.google.longrunning.Operation;
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 PrivilegedAccessManager service API.
 *
 * 

This class is for advanced usage and reflects the underlying API directly. */ @Generated("by gapic-generator-java") public class HttpJsonPrivilegedAccessManagerStub extends PrivilegedAccessManagerStub { private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder() .add(OperationMetadata.getDescriptor()) .add(Grant.getDescriptor()) .add(Entitlement.getDescriptor()) .build(); private static final ApiMethodDescriptor< CheckOnboardingStatusRequest, CheckOnboardingStatusResponse> checkOnboardingStatusMethodDescriptor = ApiMethodDescriptor .newBuilder() .setFullMethodName( "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/CheckOnboardingStatus") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/locations/*}:checkOnboardingStatus", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths( "/v1/{parent=organizations/*/locations/*}:checkOnboardingStatus", "/v1/{parent=folders/*/locations/*}:checkOnboardingStatus") .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(CheckOnboardingStatusResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor listEntitlementsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/ListEntitlements") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/locations/*}/entitlements", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths( "/v1/{parent=organizations/*/locations/*}/entitlements", "/v1/{parent=folders/*/locations/*}/entitlements") .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(ListEntitlementsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor searchEntitlementsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/SearchEntitlements") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/locations/*}/entitlements:search", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths( "/v1/{parent=organizations/*/locations/*}/entitlements:search", "/v1/{parent=folders/*/locations/*}/entitlements:search") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam( fields, "callerAccessType", request.getCallerAccessTypeValue()); 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(SearchEntitlementsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getEntitlementMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/GetEntitlement") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/locations/*/entitlements/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setAdditionalPaths( "/v1/{name=organizations/*/locations/*/entitlements/*}", "/v1/{name=folders/*/locations/*/entitlements/*}") .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(Entitlement.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor createEntitlementMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/CreateEntitlement") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/locations/*}/entitlements", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths( "/v1/{parent=organizations/*/locations/*}/entitlements", "/v1/{parent=folders/*/locations/*}/entitlements") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam( fields, "entitlementId", request.getEntitlementId()); serializer.putQueryParam(fields, "requestId", request.getRequestId()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("entitlement", request.getEntitlement(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (CreateEntitlementRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor deleteEntitlementMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/DeleteEntitlement") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/locations/*/entitlements/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setAdditionalPaths( "/v1/{name=organizations/*/locations/*/entitlements/*}", "/v1/{name=folders/*/locations/*/entitlements/*}") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "force", request.getForce()); serializer.putQueryParam(fields, "requestId", request.getRequestId()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (DeleteEntitlementRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor updateEntitlementMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/UpdateEntitlement") .setHttpMethod("PATCH") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{entitlement.name=projects/*/locations/*/entitlements/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "entitlement.name", request.getEntitlement().getName()); return fields; }) .setAdditionalPaths( "/v1/{entitlement.name=organizations/*/locations/*/entitlements/*}", "/v1/{entitlement.name=folders/*/locations/*/entitlements/*}") .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("entitlement", request.getEntitlement(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (UpdateEntitlementRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor listGrantsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/ListGrants") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/locations/*/entitlements/*}/grants", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths( "/v1/{parent=organizations/*/locations/*/entitlements/*}/grants", "/v1/{parent=folders/*/locations/*/entitlements/*}/grants") .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(ListGrantsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor searchGrantsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/SearchGrants") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/locations/*/entitlements/*}/grants:search", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths( "/v1/{parent=organizations/*/locations/*/entitlements/*}/grants:search", "/v1/{parent=folders/*/locations/*/entitlements/*}/grants:search") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam( fields, "callerRelationship", request.getCallerRelationshipValue()); 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(SearchGrantsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getGrantMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/GetGrant") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/locations/*/entitlements/*/grants/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setAdditionalPaths( "/v1/{name=organizations/*/locations/*/entitlements/*/grants/*}", "/v1/{name=folders/*/locations/*/entitlements/*/grants/*}") .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(Grant.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor createGrantMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/CreateGrant") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{parent=projects/*/locations/*/entitlements/*}/grants", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "parent", request.getParent()); return fields; }) .setAdditionalPaths( "/v1/{parent=organizations/*/locations/*/entitlements/*}/grants", "/v1/{parent=folders/*/locations/*/entitlements/*}/grants") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "requestId", request.getRequestId()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create().toBody("grant", request.getGrant(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Grant.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor approveGrantMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/ApproveGrant") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/locations/*/entitlements/*/grants/*}:approve", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setAdditionalPaths( "/v1/{name=organizations/*/locations/*/entitlements/*/grants/*}:approve", "/v1/{name=folders/*/locations/*/entitlements/*/grants/*}:approve") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearName().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Grant.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor denyGrantMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/DenyGrant") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/locations/*/entitlements/*/grants/*}:deny", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setAdditionalPaths( "/v1/{name=organizations/*/locations/*/entitlements/*/grants/*}:deny", "/v1/{name=folders/*/locations/*/entitlements/*/grants/*}:deny") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearName().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Grant.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor revokeGrantMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.privilegedaccessmanager.v1.PrivilegedAccessManager/RevokeGrant") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/locations/*/entitlements/*/grants/*}:revoke", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setAdditionalPaths( "/v1/{name=organizations/*/locations/*/entitlements/*/grants/*}:revoke", "/v1/{name=folders/*/locations/*/entitlements/*/grants/*}:revoke") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("*", request.toBuilder().clearName().build(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Operation.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .setOperationSnapshotFactory( (RevokeGrantRequest request, Operation response) -> HttpJsonOperationSnapshot.create(response)) .build(); private static final ApiMethodDescriptor listLocationsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.location.Locations/ListLocations") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*}/locations", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setAdditionalPaths( "/v1/{name=organizations/*}/locations", "/v1/{name=folders/*}/locations") .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor(request -> null) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(ListLocationsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getLocationMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName("google.cloud.location.Locations/GetLocation") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1/{name=projects/*/locations/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam(fields, "name", request.getName()); return fields; }) .setAdditionalPaths( "/v1/{name=organizations/*/locations/*}", "/v1/{name=folders/*/locations/*}") .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 checkOnboardingStatusCallable; private final UnaryCallable listEntitlementsCallable; private final UnaryCallable listEntitlementsPagedCallable; private final UnaryCallable searchEntitlementsCallable; private final UnaryCallable searchEntitlementsPagedCallable; private final UnaryCallable getEntitlementCallable; private final UnaryCallable createEntitlementCallable; private final OperationCallable createEntitlementOperationCallable; private final UnaryCallable deleteEntitlementCallable; private final OperationCallable deleteEntitlementOperationCallable; private final UnaryCallable updateEntitlementCallable; private final OperationCallable updateEntitlementOperationCallable; private final UnaryCallable listGrantsCallable; private final UnaryCallable listGrantsPagedCallable; private final UnaryCallable searchGrantsCallable; private final UnaryCallable searchGrantsPagedCallable; private final UnaryCallable getGrantCallable; private final UnaryCallable createGrantCallable; private final UnaryCallable approveGrantCallable; private final UnaryCallable denyGrantCallable; private final UnaryCallable revokeGrantCallable; private final OperationCallable revokeGrantOperationCallable; private final UnaryCallable listLocationsCallable; private final UnaryCallable listLocationsPagedCallable; private final UnaryCallable getLocationCallable; private final BackgroundResource backgroundResources; private final HttpJsonOperationsStub httpJsonOperationsStub; private final HttpJsonStubCallableFactory callableFactory; public static final HttpJsonPrivilegedAccessManagerStub create( PrivilegedAccessManagerStubSettings settings) throws IOException { return new HttpJsonPrivilegedAccessManagerStub(settings, ClientContext.create(settings)); } public static final HttpJsonPrivilegedAccessManagerStub create(ClientContext clientContext) throws IOException { return new HttpJsonPrivilegedAccessManagerStub( PrivilegedAccessManagerStubSettings.newHttpJsonBuilder().build(), clientContext); } public static final HttpJsonPrivilegedAccessManagerStub create( ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { return new HttpJsonPrivilegedAccessManagerStub( PrivilegedAccessManagerStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of HttpJsonPrivilegedAccessManagerStub, 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 HttpJsonPrivilegedAccessManagerStub( PrivilegedAccessManagerStubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new HttpJsonPrivilegedAccessManagerCallableFactory()); } /** * Constructs an instance of HttpJsonPrivilegedAccessManagerStub, 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 HttpJsonPrivilegedAccessManagerStub( PrivilegedAccessManagerStubSettings settings, ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; this.httpJsonOperationsStub = HttpJsonOperationsStub.create( clientContext, callableFactory, typeRegistry, ImmutableMap.builder() .put( "google.longrunning.Operations.DeleteOperation", HttpRule.newBuilder() .setDelete("/v1/{name=projects/*/locations/*/operations/*}") .addAdditionalBindings( HttpRule.newBuilder() .setDelete("/v1/{name=organizations/*/locations/*/operations/*}") .build()) .addAdditionalBindings( HttpRule.newBuilder() .setDelete("/v1/{name=folders/*/locations/*/operations/*}") .build()) .build()) .put( "google.longrunning.Operations.GetOperation", HttpRule.newBuilder() .setGet("/v1/{name=projects/*/locations/*/operations/*}") .addAdditionalBindings( HttpRule.newBuilder() .setGet("/v1/{name=organizations/*/locations/*/operations/*}") .build()) .addAdditionalBindings( HttpRule.newBuilder() .setGet("/v1/{name=folders/*/locations/*/operations/*}") .build()) .build()) .put( "google.longrunning.Operations.ListOperations", HttpRule.newBuilder() .setGet("/v1/{name=projects/*/locations/*}/operations") .addAdditionalBindings( HttpRule.newBuilder() .setGet("/v1/{name=organizations/*/locations/*}/operations") .build()) .addAdditionalBindings( HttpRule.newBuilder() .setGet("/v1/{name=folders/*/locations/*}/operations") .build()) .build()) .build()); HttpJsonCallSettings checkOnboardingStatusTransportSettings = HttpJsonCallSettings .newBuilder() .setMethodDescriptor(checkOnboardingStatusMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings listEntitlementsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listEntitlementsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings searchEntitlementsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(searchEntitlementsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getEntitlementTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getEntitlementMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings createEntitlementTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createEntitlementMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings deleteEntitlementTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteEntitlementMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings updateEntitlementTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateEntitlementMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add( "entitlement.name", String.valueOf(request.getEntitlement().getName())); return builder.build(); }) .build(); HttpJsonCallSettings listGrantsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listGrantsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings searchGrantsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(searchGrantsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getGrantTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getGrantMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings createGrantTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createGrantMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings approveGrantTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(approveGrantMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings denyGrantTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(denyGrantMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings revokeGrantTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(revokeGrantMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings listLocationsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listLocationsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings getLocationTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getLocationMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); this.checkOnboardingStatusCallable = callableFactory.createUnaryCallable( checkOnboardingStatusTransportSettings, settings.checkOnboardingStatusSettings(), clientContext); this.listEntitlementsCallable = callableFactory.createUnaryCallable( listEntitlementsTransportSettings, settings.listEntitlementsSettings(), clientContext); this.listEntitlementsPagedCallable = callableFactory.createPagedCallable( listEntitlementsTransportSettings, settings.listEntitlementsSettings(), clientContext); this.searchEntitlementsCallable = callableFactory.createUnaryCallable( searchEntitlementsTransportSettings, settings.searchEntitlementsSettings(), clientContext); this.searchEntitlementsPagedCallable = callableFactory.createPagedCallable( searchEntitlementsTransportSettings, settings.searchEntitlementsSettings(), clientContext); this.getEntitlementCallable = callableFactory.createUnaryCallable( getEntitlementTransportSettings, settings.getEntitlementSettings(), clientContext); this.createEntitlementCallable = callableFactory.createUnaryCallable( createEntitlementTransportSettings, settings.createEntitlementSettings(), clientContext); this.createEntitlementOperationCallable = callableFactory.createOperationCallable( createEntitlementTransportSettings, settings.createEntitlementOperationSettings(), clientContext, httpJsonOperationsStub); this.deleteEntitlementCallable = callableFactory.createUnaryCallable( deleteEntitlementTransportSettings, settings.deleteEntitlementSettings(), clientContext); this.deleteEntitlementOperationCallable = callableFactory.createOperationCallable( deleteEntitlementTransportSettings, settings.deleteEntitlementOperationSettings(), clientContext, httpJsonOperationsStub); this.updateEntitlementCallable = callableFactory.createUnaryCallable( updateEntitlementTransportSettings, settings.updateEntitlementSettings(), clientContext); this.updateEntitlementOperationCallable = callableFactory.createOperationCallable( updateEntitlementTransportSettings, settings.updateEntitlementOperationSettings(), clientContext, httpJsonOperationsStub); this.listGrantsCallable = callableFactory.createUnaryCallable( listGrantsTransportSettings, settings.listGrantsSettings(), clientContext); this.listGrantsPagedCallable = callableFactory.createPagedCallable( listGrantsTransportSettings, settings.listGrantsSettings(), clientContext); this.searchGrantsCallable = callableFactory.createUnaryCallable( searchGrantsTransportSettings, settings.searchGrantsSettings(), clientContext); this.searchGrantsPagedCallable = callableFactory.createPagedCallable( searchGrantsTransportSettings, settings.searchGrantsSettings(), clientContext); this.getGrantCallable = callableFactory.createUnaryCallable( getGrantTransportSettings, settings.getGrantSettings(), clientContext); this.createGrantCallable = callableFactory.createUnaryCallable( createGrantTransportSettings, settings.createGrantSettings(), clientContext); this.approveGrantCallable = callableFactory.createUnaryCallable( approveGrantTransportSettings, settings.approveGrantSettings(), clientContext); this.denyGrantCallable = callableFactory.createUnaryCallable( denyGrantTransportSettings, settings.denyGrantSettings(), clientContext); this.revokeGrantCallable = callableFactory.createUnaryCallable( revokeGrantTransportSettings, settings.revokeGrantSettings(), clientContext); this.revokeGrantOperationCallable = callableFactory.createOperationCallable( revokeGrantTransportSettings, settings.revokeGrantOperationSettings(), clientContext, httpJsonOperationsStub); 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(checkOnboardingStatusMethodDescriptor); methodDescriptors.add(listEntitlementsMethodDescriptor); methodDescriptors.add(searchEntitlementsMethodDescriptor); methodDescriptors.add(getEntitlementMethodDescriptor); methodDescriptors.add(createEntitlementMethodDescriptor); methodDescriptors.add(deleteEntitlementMethodDescriptor); methodDescriptors.add(updateEntitlementMethodDescriptor); methodDescriptors.add(listGrantsMethodDescriptor); methodDescriptors.add(searchGrantsMethodDescriptor); methodDescriptors.add(getGrantMethodDescriptor); methodDescriptors.add(createGrantMethodDescriptor); methodDescriptors.add(approveGrantMethodDescriptor); methodDescriptors.add(denyGrantMethodDescriptor); methodDescriptors.add(revokeGrantMethodDescriptor); methodDescriptors.add(listLocationsMethodDescriptor); methodDescriptors.add(getLocationMethodDescriptor); return methodDescriptors; } public HttpJsonOperationsStub getHttpJsonOperationsStub() { return httpJsonOperationsStub; } @Override public UnaryCallable checkOnboardingStatusCallable() { return checkOnboardingStatusCallable; } @Override public UnaryCallable listEntitlementsCallable() { return listEntitlementsCallable; } @Override public UnaryCallable listEntitlementsPagedCallable() { return listEntitlementsPagedCallable; } @Override public UnaryCallable searchEntitlementsCallable() { return searchEntitlementsCallable; } @Override public UnaryCallable searchEntitlementsPagedCallable() { return searchEntitlementsPagedCallable; } @Override public UnaryCallable getEntitlementCallable() { return getEntitlementCallable; } @Override public UnaryCallable createEntitlementCallable() { return createEntitlementCallable; } @Override public OperationCallable createEntitlementOperationCallable() { return createEntitlementOperationCallable; } @Override public UnaryCallable deleteEntitlementCallable() { return deleteEntitlementCallable; } @Override public OperationCallable deleteEntitlementOperationCallable() { return deleteEntitlementOperationCallable; } @Override public UnaryCallable updateEntitlementCallable() { return updateEntitlementCallable; } @Override public OperationCallable updateEntitlementOperationCallable() { return updateEntitlementOperationCallable; } @Override public UnaryCallable listGrantsCallable() { return listGrantsCallable; } @Override public UnaryCallable listGrantsPagedCallable() { return listGrantsPagedCallable; } @Override public UnaryCallable searchGrantsCallable() { return searchGrantsCallable; } @Override public UnaryCallable searchGrantsPagedCallable() { return searchGrantsPagedCallable; } @Override public UnaryCallable getGrantCallable() { return getGrantCallable; } @Override public UnaryCallable createGrantCallable() { return createGrantCallable; } @Override public UnaryCallable approveGrantCallable() { return approveGrantCallable; } @Override public UnaryCallable denyGrantCallable() { return denyGrantCallable; } @Override public UnaryCallable revokeGrantCallable() { return revokeGrantCallable; } @Override public OperationCallable revokeGrantOperationCallable() { return revokeGrantOperationCallable; } @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 - 2024 Weber Informatics LLC | Privacy Policy