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

com.google.cloud.binaryauthorization.v1beta1.stub.HttpJsonBinauthzManagementServiceV1Beta1Stub Maven / Gradle / Ivy

Go to download

Binary Authorization is a service on Google Cloud that provides centralized software supply-chain security for applications that run on Google Kubernetes Engine (GKE) and Anthos clusters on VMware

There is a newer version: 1.48.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.binaryauthorization.v1beta1.stub;

import static com.google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1Client.ListAttestorsPagedResponse;

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.binaryauthorization.v1beta1.Attestor;
import com.google.cloud.binaryauthorization.v1beta1.CreateAttestorRequest;
import com.google.cloud.binaryauthorization.v1beta1.DeleteAttestorRequest;
import com.google.cloud.binaryauthorization.v1beta1.GetAttestorRequest;
import com.google.cloud.binaryauthorization.v1beta1.GetPolicyRequest;
import com.google.cloud.binaryauthorization.v1beta1.ListAttestorsRequest;
import com.google.cloud.binaryauthorization.v1beta1.ListAttestorsResponse;
import com.google.cloud.binaryauthorization.v1beta1.Policy;
import com.google.cloud.binaryauthorization.v1beta1.UpdateAttestorRequest;
import com.google.cloud.binaryauthorization.v1beta1.UpdatePolicyRequest;
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 BinauthzManagementServiceV1Beta1 service API.
 *
 * 

This class is for advanced usage and reflects the underlying API directly. */ @BetaApi @Generated("by gapic-generator-java") public class HttpJsonBinauthzManagementServiceV1Beta1Stub extends BinauthzManagementServiceV1Beta1Stub { private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); private static final ApiMethodDescriptor getPolicyMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/GetPolicy") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{name=projects/*/policy}", 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(Policy.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor updatePolicyMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/UpdatePolicy") .setHttpMethod("PUT") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{policy.name=projects/*/policy}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "policy.name", request.getPolicy().getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("policy", request.getPolicy(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Policy.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor createAttestorMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/CreateAttestor") .setHttpMethod("POST") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{parent=projects/*}/attestors", 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, "attestorId", request.getAttestorId()); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("attestor", request.getAttestor(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Attestor.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor getAttestorMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/GetAttestor") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{name=projects/*/attestors/*}", 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(Attestor.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor updateAttestorMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/UpdateAttestor") .setHttpMethod("PUT") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{attestor.name=projects/*/attestors/*}", request -> { Map fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putPathParam( fields, "attestor.name", request.getAttestor().getName()); return fields; }) .setQueryParamsExtractor( request -> { Map> fields = new HashMap<>(); ProtoRestSerializer serializer = ProtoRestSerializer.create(); serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int"); return fields; }) .setRequestBodyExtractor( request -> ProtoRestSerializer.create() .toBody("attestor", request.getAttestor(), true)) .build()) .setResponseParser( ProtoMessageResponseParser.newBuilder() .setDefaultInstance(Attestor.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor listAttestorsMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/ListAttestors") .setHttpMethod("GET") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{parent=projects/*}/attestors", 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(ListAttestorsResponse.getDefaultInstance()) .setDefaultTypeRegistry(typeRegistry) .build()) .build(); private static final ApiMethodDescriptor deleteAttestorMethodDescriptor = ApiMethodDescriptor.newBuilder() .setFullMethodName( "google.cloud.binaryauthorization.v1beta1.BinauthzManagementServiceV1Beta1/DeleteAttestor") .setHttpMethod("DELETE") .setType(ApiMethodDescriptor.MethodType.UNARY) .setRequestFormatter( ProtoMessageRequestFormatter.newBuilder() .setPath( "/v1beta1/{name=projects/*/attestors/*}", 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 final UnaryCallable getPolicyCallable; private final UnaryCallable updatePolicyCallable; private final UnaryCallable createAttestorCallable; private final UnaryCallable getAttestorCallable; private final UnaryCallable updateAttestorCallable; private final UnaryCallable listAttestorsCallable; private final UnaryCallable listAttestorsPagedCallable; private final UnaryCallable deleteAttestorCallable; private final BackgroundResource backgroundResources; private final HttpJsonStubCallableFactory callableFactory; public static final HttpJsonBinauthzManagementServiceV1Beta1Stub create( BinauthzManagementServiceV1Beta1StubSettings settings) throws IOException { return new HttpJsonBinauthzManagementServiceV1Beta1Stub( settings, ClientContext.create(settings)); } public static final HttpJsonBinauthzManagementServiceV1Beta1Stub create( ClientContext clientContext) throws IOException { return new HttpJsonBinauthzManagementServiceV1Beta1Stub( BinauthzManagementServiceV1Beta1StubSettings.newHttpJsonBuilder().build(), clientContext); } public static final HttpJsonBinauthzManagementServiceV1Beta1Stub create( ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { return new HttpJsonBinauthzManagementServiceV1Beta1Stub( BinauthzManagementServiceV1Beta1StubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); } /** * Constructs an instance of HttpJsonBinauthzManagementServiceV1Beta1Stub, 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 HttpJsonBinauthzManagementServiceV1Beta1Stub( BinauthzManagementServiceV1Beta1StubSettings settings, ClientContext clientContext) throws IOException { this(settings, clientContext, new HttpJsonBinauthzManagementServiceV1Beta1CallableFactory()); } /** * Constructs an instance of HttpJsonBinauthzManagementServiceV1Beta1Stub, 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 HttpJsonBinauthzManagementServiceV1Beta1Stub( BinauthzManagementServiceV1Beta1StubSettings settings, ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { this.callableFactory = callableFactory; HttpJsonCallSettings getPolicyTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getPolicyMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings updatePolicyTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updatePolicyMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("policy.name", String.valueOf(request.getPolicy().getName())); return builder.build(); }) .build(); HttpJsonCallSettings createAttestorTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(createAttestorMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings getAttestorTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(getAttestorMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); HttpJsonCallSettings updateAttestorTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(updateAttestorMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("attestor.name", String.valueOf(request.getAttestor().getName())); return builder.build(); }) .build(); HttpJsonCallSettings listAttestorsTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(listAttestorsMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("parent", String.valueOf(request.getParent())); return builder.build(); }) .build(); HttpJsonCallSettings deleteAttestorTransportSettings = HttpJsonCallSettings.newBuilder() .setMethodDescriptor(deleteAttestorMethodDescriptor) .setTypeRegistry(typeRegistry) .setParamsExtractor( request -> { RequestParamsBuilder builder = RequestParamsBuilder.create(); builder.add("name", String.valueOf(request.getName())); return builder.build(); }) .build(); this.getPolicyCallable = callableFactory.createUnaryCallable( getPolicyTransportSettings, settings.getPolicySettings(), clientContext); this.updatePolicyCallable = callableFactory.createUnaryCallable( updatePolicyTransportSettings, settings.updatePolicySettings(), clientContext); this.createAttestorCallable = callableFactory.createUnaryCallable( createAttestorTransportSettings, settings.createAttestorSettings(), clientContext); this.getAttestorCallable = callableFactory.createUnaryCallable( getAttestorTransportSettings, settings.getAttestorSettings(), clientContext); this.updateAttestorCallable = callableFactory.createUnaryCallable( updateAttestorTransportSettings, settings.updateAttestorSettings(), clientContext); this.listAttestorsCallable = callableFactory.createUnaryCallable( listAttestorsTransportSettings, settings.listAttestorsSettings(), clientContext); this.listAttestorsPagedCallable = callableFactory.createPagedCallable( listAttestorsTransportSettings, settings.listAttestorsSettings(), clientContext); this.deleteAttestorCallable = callableFactory.createUnaryCallable( deleteAttestorTransportSettings, settings.deleteAttestorSettings(), clientContext); this.backgroundResources = new BackgroundResourceAggregation(clientContext.getBackgroundResources()); } @InternalApi public static List getMethodDescriptors() { List methodDescriptors = new ArrayList<>(); methodDescriptors.add(getPolicyMethodDescriptor); methodDescriptors.add(updatePolicyMethodDescriptor); methodDescriptors.add(createAttestorMethodDescriptor); methodDescriptors.add(getAttestorMethodDescriptor); methodDescriptors.add(updateAttestorMethodDescriptor); methodDescriptors.add(listAttestorsMethodDescriptor); methodDescriptors.add(deleteAttestorMethodDescriptor); return methodDescriptors; } @Override public UnaryCallable getPolicyCallable() { return getPolicyCallable; } @Override public UnaryCallable updatePolicyCallable() { return updatePolicyCallable; } @Override public UnaryCallable createAttestorCallable() { return createAttestorCallable; } @Override public UnaryCallable getAttestorCallable() { return getAttestorCallable; } @Override public UnaryCallable updateAttestorCallable() { return updateAttestorCallable; } @Override public UnaryCallable listAttestorsCallable() { return listAttestorsCallable; } @Override public UnaryCallable listAttestorsPagedCallable() { return listAttestorsPagedCallable; } @Override public UnaryCallable deleteAttestorCallable() { return deleteAttestorCallable; } @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