com.google.cloud.securityposture.v1.stub.HttpJsonSecurityPostureStub Maven / Gradle / Ivy
Show all versions of google-cloud-securityposture Show documentation
/*
* 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.securityposture.v1.stub;
import static com.google.cloud.securityposture.v1.SecurityPostureClient.ListLocationsPagedResponse;
import static com.google.cloud.securityposture.v1.SecurityPostureClient.ListPostureDeploymentsPagedResponse;
import static com.google.cloud.securityposture.v1.SecurityPostureClient.ListPostureRevisionsPagedResponse;
import static com.google.cloud.securityposture.v1.SecurityPostureClient.ListPostureTemplatesPagedResponse;
import static com.google.cloud.securityposture.v1.SecurityPostureClient.ListPosturesPagedResponse;
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.securityposture.v1.CreatePostureDeploymentRequest;
import com.google.cloud.securityposture.v1.CreatePostureRequest;
import com.google.cloud.securityposture.v1.DeletePostureDeploymentRequest;
import com.google.cloud.securityposture.v1.DeletePostureRequest;
import com.google.cloud.securityposture.v1.ExtractPostureRequest;
import com.google.cloud.securityposture.v1.GetPostureDeploymentRequest;
import com.google.cloud.securityposture.v1.GetPostureRequest;
import com.google.cloud.securityposture.v1.GetPostureTemplateRequest;
import com.google.cloud.securityposture.v1.ListPostureDeploymentsRequest;
import com.google.cloud.securityposture.v1.ListPostureDeploymentsResponse;
import com.google.cloud.securityposture.v1.ListPostureRevisionsRequest;
import com.google.cloud.securityposture.v1.ListPostureRevisionsResponse;
import com.google.cloud.securityposture.v1.ListPostureTemplatesRequest;
import com.google.cloud.securityposture.v1.ListPostureTemplatesResponse;
import com.google.cloud.securityposture.v1.ListPosturesRequest;
import com.google.cloud.securityposture.v1.ListPosturesResponse;
import com.google.cloud.securityposture.v1.OperationMetadata;
import com.google.cloud.securityposture.v1.Posture;
import com.google.cloud.securityposture.v1.PostureDeployment;
import com.google.cloud.securityposture.v1.PostureTemplate;
import com.google.cloud.securityposture.v1.UpdatePostureDeploymentRequest;
import com.google.cloud.securityposture.v1.UpdatePostureRequest;
import com.google.common.collect.ImmutableMap;
import com.google.longrunning.Operation;
import com.google.protobuf.Empty;
import com.google.protobuf.TypeRegistry;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Generated;
// AUTO-GENERATED DOCUMENTATION AND CLASS.
/**
* REST stub implementation for the SecurityPosture service API.
*
* This class is for advanced usage and reflects the underlying API directly.
*/
@Generated("by gapic-generator-java")
public class HttpJsonSecurityPostureStub extends SecurityPostureStub {
private static final TypeRegistry typeRegistry =
TypeRegistry.newBuilder()
.add(Empty.getDescriptor())
.add(Posture.getDescriptor())
.add(OperationMetadata.getDescriptor())
.add(PostureDeployment.getDescriptor())
.build();
private static final ApiMethodDescriptor
listPosturesMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.securityposture.v1.SecurityPosture/ListPostures")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=organizations/*/locations/*}/postures",
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(ListPosturesResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor<
ListPostureRevisionsRequest, ListPostureRevisionsResponse>
listPostureRevisionsMethodDescriptor =
ApiMethodDescriptor
.newBuilder()
.setFullMethodName(
"google.cloud.securityposture.v1.SecurityPosture/ListPostureRevisions")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=organizations/*/locations/*/postures/*}:listRevisions",
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, "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(ListPostureRevisionsResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor getPostureMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.securityposture.v1.SecurityPosture/GetPosture")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=organizations/*/locations/*/postures/*}",
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, "revisionId", request.getRevisionId());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Posture.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
createPostureMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.securityposture.v1.SecurityPosture/CreatePosture")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=organizations/*/locations/*}/postures",
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, "postureId", request.getPostureId());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("posture", request.getPosture(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(CreatePostureRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
updatePostureMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.securityposture.v1.SecurityPosture/UpdatePosture")
.setHttpMethod("PATCH")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{posture.name=organizations/*/locations/*/postures/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields, "posture.name", request.getPosture().getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "revisionId", request.getRevisionId());
serializer.putQueryParam(fields, "updateMask", request.getUpdateMask());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("posture", request.getPosture(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(UpdatePostureRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
deletePostureMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.securityposture.v1.SecurityPosture/DeletePosture")
.setHttpMethod("DELETE")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=organizations/*/locations/*/postures/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "name", request.getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "etag", request.getEtag());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(DeletePostureRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
extractPostureMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.securityposture.v1.SecurityPosture/ExtractPosture")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=organizations/*/locations/*}/postures:extract",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "parent", request.getParent());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody("*", request.toBuilder().clearParent().build(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(ExtractPostureRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor<
ListPostureDeploymentsRequest, ListPostureDeploymentsResponse>
listPostureDeploymentsMethodDescriptor =
ApiMethodDescriptor
.newBuilder()
.setFullMethodName(
"google.cloud.securityposture.v1.SecurityPosture/ListPostureDeployments")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=organizations/*/locations/*}/postureDeployments",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "parent", request.getParent());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "filter", request.getFilter());
serializer.putQueryParam(fields, "pageSize", request.getPageSize());
serializer.putQueryParam(fields, "pageToken", request.getPageToken());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(ListPostureDeploymentsResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
getPostureDeploymentMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName(
"google.cloud.securityposture.v1.SecurityPosture/GetPostureDeployment")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=organizations/*/locations/*/postureDeployments/*}",
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(PostureDeployment.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
createPostureDeploymentMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName(
"google.cloud.securityposture.v1.SecurityPosture/CreatePostureDeployment")
.setHttpMethod("POST")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=organizations/*/locations/*}/postureDeployments",
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, "postureDeploymentId", request.getPostureDeploymentId());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(
request ->
ProtoRestSerializer.create()
.toBody(
"postureDeployment", request.getPostureDeployment(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(CreatePostureDeploymentRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
updatePostureDeploymentMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName(
"google.cloud.securityposture.v1.SecurityPosture/UpdatePostureDeployment")
.setHttpMethod("PATCH")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{postureDeployment.name=organizations/*/locations/*/postureDeployments/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(
fields,
"postureDeployment.name",
request.getPostureDeployment().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(
"postureDeployment", request.getPostureDeployment(), true))
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(UpdatePostureDeploymentRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor
deletePostureDeploymentMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName(
"google.cloud.securityposture.v1.SecurityPosture/DeletePostureDeployment")
.setHttpMethod("DELETE")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=organizations/*/locations/*/postureDeployments/*}",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "name", request.getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "etag", request.getEtag());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(Operation.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.setOperationSnapshotFactory(
(DeletePostureDeploymentRequest request, Operation response) ->
HttpJsonOperationSnapshot.create(response))
.build();
private static final ApiMethodDescriptor<
ListPostureTemplatesRequest, ListPostureTemplatesResponse>
listPostureTemplatesMethodDescriptor =
ApiMethodDescriptor
.newBuilder()
.setFullMethodName(
"google.cloud.securityposture.v1.SecurityPosture/ListPostureTemplates")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{parent=organizations/*/locations/*}/postureTemplates",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "parent", request.getParent());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "filter", request.getFilter());
serializer.putQueryParam(fields, "pageSize", request.getPageSize());
serializer.putQueryParam(fields, "pageToken", request.getPageToken());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(ListPostureTemplatesResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
getPostureTemplateMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName(
"google.cloud.securityposture.v1.SecurityPosture/GetPostureTemplate")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=organizations/*/locations/*/postureTemplates/*}",
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, "revisionId", request.getRevisionId());
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(PostureTemplate.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
listLocationsMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.location.Locations/ListLocations")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=organizations/*}/locations",
request -> {
Map fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putPathParam(fields, "name", request.getName());
return fields;
})
.setQueryParamsExtractor(
request -> {
Map> fields = new HashMap<>();
ProtoRestSerializer serializer =
ProtoRestSerializer.create();
serializer.putQueryParam(fields, "$alt", "json;enum-encoding=int");
return fields;
})
.setRequestBodyExtractor(request -> null)
.build())
.setResponseParser(
ProtoMessageResponseParser.newBuilder()
.setDefaultInstance(ListLocationsResponse.getDefaultInstance())
.setDefaultTypeRegistry(typeRegistry)
.build())
.build();
private static final ApiMethodDescriptor
getLocationMethodDescriptor =
ApiMethodDescriptor.newBuilder()
.setFullMethodName("google.cloud.location.Locations/GetLocation")
.setHttpMethod("GET")
.setType(ApiMethodDescriptor.MethodType.UNARY)
.setRequestFormatter(
ProtoMessageRequestFormatter.newBuilder()
.setPath(
"/v1/{name=organizations/*/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 listPosturesCallable;
private final UnaryCallable
listPosturesPagedCallable;
private final UnaryCallable
listPostureRevisionsCallable;
private final UnaryCallable
listPostureRevisionsPagedCallable;
private final UnaryCallable getPostureCallable;
private final UnaryCallable createPostureCallable;
private final OperationCallable
createPostureOperationCallable;
private final UnaryCallable updatePostureCallable;
private final OperationCallable
updatePostureOperationCallable;
private final UnaryCallable deletePostureCallable;
private final OperationCallable
deletePostureOperationCallable;
private final UnaryCallable extractPostureCallable;
private final OperationCallable
extractPostureOperationCallable;
private final UnaryCallable
listPostureDeploymentsCallable;
private final UnaryCallable
listPostureDeploymentsPagedCallable;
private final UnaryCallable
getPostureDeploymentCallable;
private final UnaryCallable
createPostureDeploymentCallable;
private final OperationCallable<
CreatePostureDeploymentRequest, PostureDeployment, OperationMetadata>
createPostureDeploymentOperationCallable;
private final UnaryCallable
updatePostureDeploymentCallable;
private final OperationCallable<
UpdatePostureDeploymentRequest, PostureDeployment, OperationMetadata>
updatePostureDeploymentOperationCallable;
private final UnaryCallable
deletePostureDeploymentCallable;
private final OperationCallable
deletePostureDeploymentOperationCallable;
private final UnaryCallable
listPostureTemplatesCallable;
private final UnaryCallable
listPostureTemplatesPagedCallable;
private final UnaryCallable
getPostureTemplateCallable;
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 HttpJsonSecurityPostureStub create(SecurityPostureStubSettings settings)
throws IOException {
return new HttpJsonSecurityPostureStub(settings, ClientContext.create(settings));
}
public static final HttpJsonSecurityPostureStub create(ClientContext clientContext)
throws IOException {
return new HttpJsonSecurityPostureStub(
SecurityPostureStubSettings.newHttpJsonBuilder().build(), clientContext);
}
public static final HttpJsonSecurityPostureStub create(
ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
return new HttpJsonSecurityPostureStub(
SecurityPostureStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory);
}
/**
* Constructs an instance of HttpJsonSecurityPostureStub, 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 HttpJsonSecurityPostureStub(
SecurityPostureStubSettings settings, ClientContext clientContext) throws IOException {
this(settings, clientContext, new HttpJsonSecurityPostureCallableFactory());
}
/**
* Constructs an instance of HttpJsonSecurityPostureStub, 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 HttpJsonSecurityPostureStub(
SecurityPostureStubSettings settings,
ClientContext clientContext,
HttpJsonStubCallableFactory callableFactory)
throws IOException {
this.callableFactory = callableFactory;
this.httpJsonOperationsStub =
HttpJsonOperationsStub.create(
clientContext,
callableFactory,
typeRegistry,
ImmutableMap.builder()
.put(
"google.longrunning.Operations.CancelOperation",
HttpRule.newBuilder()
.setPost("/v1/{name=organizations/*/locations/*/operations/*}:cancel")
.build())
.put(
"google.longrunning.Operations.DeleteOperation",
HttpRule.newBuilder()
.setDelete("/v1/{name=organizations/*/locations/*/operations/*}")
.build())
.put(
"google.longrunning.Operations.GetOperation",
HttpRule.newBuilder()
.setGet("/v1/{name=organizations/*/locations/*/operations/*}")
.build())
.put(
"google.longrunning.Operations.ListOperations",
HttpRule.newBuilder()
.setGet("/v1/{name=organizations/*/locations/*}/operations")
.build())
.build());
HttpJsonCallSettings listPosturesTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(listPosturesMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings
listPostureRevisionsTransportSettings =
HttpJsonCallSettings
.newBuilder()
.setMethodDescriptor(listPostureRevisionsMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings getPostureTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getPostureMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings createPostureTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(createPostureMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings updatePostureTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updatePostureMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("posture.name", String.valueOf(request.getPosture().getName()));
return builder.build();
})
.build();
HttpJsonCallSettings deletePostureTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(deletePostureMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings extractPostureTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(extractPostureMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings
listPostureDeploymentsTransportSettings =
HttpJsonCallSettings
.newBuilder()
.setMethodDescriptor(listPostureDeploymentsMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings
getPostureDeploymentTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getPostureDeploymentMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
createPostureDeploymentTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(createPostureDeploymentMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings
updatePostureDeploymentTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(updatePostureDeploymentMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add(
"posture_deployment.name",
String.valueOf(request.getPostureDeployment().getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
deletePostureDeploymentTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(deletePostureDeploymentMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("name", String.valueOf(request.getName()));
return builder.build();
})
.build();
HttpJsonCallSettings
listPostureTemplatesTransportSettings =
HttpJsonCallSettings
.newBuilder()
.setMethodDescriptor(listPostureTemplatesMethodDescriptor)
.setTypeRegistry(typeRegistry)
.setParamsExtractor(
request -> {
RequestParamsBuilder builder = RequestParamsBuilder.create();
builder.add("parent", String.valueOf(request.getParent()));
return builder.build();
})
.build();
HttpJsonCallSettings
getPostureTemplateTransportSettings =
HttpJsonCallSettings.newBuilder()
.setMethodDescriptor(getPostureTemplateMethodDescriptor)
.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.listPosturesCallable =
callableFactory.createUnaryCallable(
listPosturesTransportSettings, settings.listPosturesSettings(), clientContext);
this.listPosturesPagedCallable =
callableFactory.createPagedCallable(
listPosturesTransportSettings, settings.listPosturesSettings(), clientContext);
this.listPostureRevisionsCallable =
callableFactory.createUnaryCallable(
listPostureRevisionsTransportSettings,
settings.listPostureRevisionsSettings(),
clientContext);
this.listPostureRevisionsPagedCallable =
callableFactory.createPagedCallable(
listPostureRevisionsTransportSettings,
settings.listPostureRevisionsSettings(),
clientContext);
this.getPostureCallable =
callableFactory.createUnaryCallable(
getPostureTransportSettings, settings.getPostureSettings(), clientContext);
this.createPostureCallable =
callableFactory.createUnaryCallable(
createPostureTransportSettings, settings.createPostureSettings(), clientContext);
this.createPostureOperationCallable =
callableFactory.createOperationCallable(
createPostureTransportSettings,
settings.createPostureOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.updatePostureCallable =
callableFactory.createUnaryCallable(
updatePostureTransportSettings, settings.updatePostureSettings(), clientContext);
this.updatePostureOperationCallable =
callableFactory.createOperationCallable(
updatePostureTransportSettings,
settings.updatePostureOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.deletePostureCallable =
callableFactory.createUnaryCallable(
deletePostureTransportSettings, settings.deletePostureSettings(), clientContext);
this.deletePostureOperationCallable =
callableFactory.createOperationCallable(
deletePostureTransportSettings,
settings.deletePostureOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.extractPostureCallable =
callableFactory.createUnaryCallable(
extractPostureTransportSettings, settings.extractPostureSettings(), clientContext);
this.extractPostureOperationCallable =
callableFactory.createOperationCallable(
extractPostureTransportSettings,
settings.extractPostureOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.listPostureDeploymentsCallable =
callableFactory.createUnaryCallable(
listPostureDeploymentsTransportSettings,
settings.listPostureDeploymentsSettings(),
clientContext);
this.listPostureDeploymentsPagedCallable =
callableFactory.createPagedCallable(
listPostureDeploymentsTransportSettings,
settings.listPostureDeploymentsSettings(),
clientContext);
this.getPostureDeploymentCallable =
callableFactory.createUnaryCallable(
getPostureDeploymentTransportSettings,
settings.getPostureDeploymentSettings(),
clientContext);
this.createPostureDeploymentCallable =
callableFactory.createUnaryCallable(
createPostureDeploymentTransportSettings,
settings.createPostureDeploymentSettings(),
clientContext);
this.createPostureDeploymentOperationCallable =
callableFactory.createOperationCallable(
createPostureDeploymentTransportSettings,
settings.createPostureDeploymentOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.updatePostureDeploymentCallable =
callableFactory.createUnaryCallable(
updatePostureDeploymentTransportSettings,
settings.updatePostureDeploymentSettings(),
clientContext);
this.updatePostureDeploymentOperationCallable =
callableFactory.createOperationCallable(
updatePostureDeploymentTransportSettings,
settings.updatePostureDeploymentOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.deletePostureDeploymentCallable =
callableFactory.createUnaryCallable(
deletePostureDeploymentTransportSettings,
settings.deletePostureDeploymentSettings(),
clientContext);
this.deletePostureDeploymentOperationCallable =
callableFactory.createOperationCallable(
deletePostureDeploymentTransportSettings,
settings.deletePostureDeploymentOperationSettings(),
clientContext,
httpJsonOperationsStub);
this.listPostureTemplatesCallable =
callableFactory.createUnaryCallable(
listPostureTemplatesTransportSettings,
settings.listPostureTemplatesSettings(),
clientContext);
this.listPostureTemplatesPagedCallable =
callableFactory.createPagedCallable(
listPostureTemplatesTransportSettings,
settings.listPostureTemplatesSettings(),
clientContext);
this.getPostureTemplateCallable =
callableFactory.createUnaryCallable(
getPostureTemplateTransportSettings,
settings.getPostureTemplateSettings(),
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(listPosturesMethodDescriptor);
methodDescriptors.add(listPostureRevisionsMethodDescriptor);
methodDescriptors.add(getPostureMethodDescriptor);
methodDescriptors.add(createPostureMethodDescriptor);
methodDescriptors.add(updatePostureMethodDescriptor);
methodDescriptors.add(deletePostureMethodDescriptor);
methodDescriptors.add(extractPostureMethodDescriptor);
methodDescriptors.add(listPostureDeploymentsMethodDescriptor);
methodDescriptors.add(getPostureDeploymentMethodDescriptor);
methodDescriptors.add(createPostureDeploymentMethodDescriptor);
methodDescriptors.add(updatePostureDeploymentMethodDescriptor);
methodDescriptors.add(deletePostureDeploymentMethodDescriptor);
methodDescriptors.add(listPostureTemplatesMethodDescriptor);
methodDescriptors.add(getPostureTemplateMethodDescriptor);
methodDescriptors.add(listLocationsMethodDescriptor);
methodDescriptors.add(getLocationMethodDescriptor);
return methodDescriptors;
}
public HttpJsonOperationsStub getHttpJsonOperationsStub() {
return httpJsonOperationsStub;
}
@Override
public UnaryCallable listPosturesCallable() {
return listPosturesCallable;
}
@Override
public UnaryCallable listPosturesPagedCallable() {
return listPosturesPagedCallable;
}
@Override
public UnaryCallable
listPostureRevisionsCallable() {
return listPostureRevisionsCallable;
}
@Override
public UnaryCallable
listPostureRevisionsPagedCallable() {
return listPostureRevisionsPagedCallable;
}
@Override
public UnaryCallable getPostureCallable() {
return getPostureCallable;
}
@Override
public UnaryCallable createPostureCallable() {
return createPostureCallable;
}
@Override
public OperationCallable
createPostureOperationCallable() {
return createPostureOperationCallable;
}
@Override
public UnaryCallable updatePostureCallable() {
return updatePostureCallable;
}
@Override
public OperationCallable
updatePostureOperationCallable() {
return updatePostureOperationCallable;
}
@Override
public UnaryCallable deletePostureCallable() {
return deletePostureCallable;
}
@Override
public OperationCallable
deletePostureOperationCallable() {
return deletePostureOperationCallable;
}
@Override
public UnaryCallable extractPostureCallable() {
return extractPostureCallable;
}
@Override
public OperationCallable
extractPostureOperationCallable() {
return extractPostureOperationCallable;
}
@Override
public UnaryCallable
listPostureDeploymentsCallable() {
return listPostureDeploymentsCallable;
}
@Override
public UnaryCallable
listPostureDeploymentsPagedCallable() {
return listPostureDeploymentsPagedCallable;
}
@Override
public UnaryCallable
getPostureDeploymentCallable() {
return getPostureDeploymentCallable;
}
@Override
public UnaryCallable
createPostureDeploymentCallable() {
return createPostureDeploymentCallable;
}
@Override
public OperationCallable
createPostureDeploymentOperationCallable() {
return createPostureDeploymentOperationCallable;
}
@Override
public UnaryCallable
updatePostureDeploymentCallable() {
return updatePostureDeploymentCallable;
}
@Override
public OperationCallable
updatePostureDeploymentOperationCallable() {
return updatePostureDeploymentOperationCallable;
}
@Override
public UnaryCallable
deletePostureDeploymentCallable() {
return deletePostureDeploymentCallable;
}
@Override
public OperationCallable
deletePostureDeploymentOperationCallable() {
return deletePostureDeploymentOperationCallable;
}
@Override
public UnaryCallable
listPostureTemplatesCallable() {
return listPostureTemplatesCallable;
}
@Override
public UnaryCallable
listPostureTemplatesPagedCallable() {
return listPostureTemplatesPagedCallable;
}
@Override
public UnaryCallable getPostureTemplateCallable() {
return getPostureTemplateCallable;
}
@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);
}
}