diff --git a/google-cloud-api-gateway/pom.xml b/google-cloud-api-gateway/pom.xml index b566f2f..3cd57aa 100644 --- a/google-cloud-api-gateway/pom.xml +++ b/google-cloud-api-gateway/pom.xml @@ -58,6 +58,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -77,12 +81,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/ApiGatewayServiceClient.java b/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/ApiGatewayServiceClient.java index b8b2403..cc84d6a 100644 --- a/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/ApiGatewayServiceClient.java +++ b/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/ApiGatewayServiceClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -30,7 +31,6 @@ import com.google.cloud.apigateway.v1.stub.ApiGatewayServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import com.google.protobuf.FieldMask; import java.io.IOException; @@ -105,13 +105,29 @@ * ApiGatewayServiceClient.create(apiGatewayServiceSettings); * } * + *

To use REST (HTTP1.1/JSON) transport (instead of gRPC) for sending and receiving requests over + * the wire: + * + *

{@code
+ * // This snippet has been automatically generated for illustrative purposes only.
+ * // It may require modifications to work in your environment.
+ * ApiGatewayServiceSettings apiGatewayServiceSettings =
+ *     ApiGatewayServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ApiGatewayServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ApiGatewayServiceClient apiGatewayServiceClient =
+ *     ApiGatewayServiceClient.create(apiGatewayServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class ApiGatewayServiceClient implements BackgroundResource { private final ApiGatewayServiceSettings settings; private final ApiGatewayServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ApiGatewayServiceClient with default settings. */ public static final ApiGatewayServiceClient create() throws IOException { @@ -143,13 +159,17 @@ public static final ApiGatewayServiceClient create(ApiGatewayServiceStub stub) { protected ApiGatewayServiceClient(ApiGatewayServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((ApiGatewayServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected ApiGatewayServiceClient(ApiGatewayServiceStub stub) { this.settings = null; this.stub = stub; - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } public final ApiGatewayServiceSettings getSettings() { @@ -164,10 +184,18 @@ public ApiGatewayServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists Gateways in a given project and location. diff --git a/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/ApiGatewayServiceSettings.java b/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/ApiGatewayServiceSettings.java index babbd4c..016b58b 100644 --- a/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/ApiGatewayServiceSettings.java +++ b/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/ApiGatewayServiceSettings.java @@ -25,6 +25,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -234,11 +235,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ApiGatewayServiceStubSettings.defaultCredentialsProviderBuilder(); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return ApiGatewayServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ApiGatewayServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ApiGatewayServiceStubSettings.defaultTransportChannelProvider(); } @@ -248,11 +256,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ApiGatewayServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -290,6 +304,11 @@ private static Builder createDefault() { return new Builder(ApiGatewayServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ApiGatewayServiceStubSettings.newHttpJsonBuilder()); + } + public ApiGatewayServiceStubSettings.Builder getStubSettingsBuilder() { return ((ApiGatewayServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/stub/ApiGatewayServiceStub.java b/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/stub/ApiGatewayServiceStub.java index 5bad47c..fd58d76 100644 --- a/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/stub/ApiGatewayServiceStub.java +++ b/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/stub/ApiGatewayServiceStub.java @@ -60,7 +60,11 @@ public abstract class ApiGatewayServiceStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable listGatewaysPagedCallable() { diff --git a/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/stub/ApiGatewayServiceStubSettings.java b/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/stub/ApiGatewayServiceStubSettings.java index 0861394..aa7cf76 100644 --- a/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/stub/ApiGatewayServiceStubSettings.java +++ b/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/stub/ApiGatewayServiceStubSettings.java @@ -30,6 +30,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -457,6 +460,11 @@ public ApiGatewayServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcApiGatewayServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonApiGatewayServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -489,18 +497,25 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde .setUseJwtAccessWithScope(true); } - /** Returns a builder for the default ChannelProvider for this service. */ + /** Returns a builder for the default gRPC ChannelProvider for this service. */ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProviderBuilder() { return InstantiatingGrpcChannelProvider.newBuilder() .setMaxInboundMessageSize(Integer.MAX_VALUE); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return InstantiatingHttpJsonChannelProvider.newBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return defaultGrpcTransportProviderBuilder().build(); } @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") - public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + public static ApiClientHeaderProvider.Builder defaultGrpcApiClientHeaderProviderBuilder() { return ApiClientHeaderProvider.newBuilder() .setGeneratedLibToken( "gapic", GaxProperties.getLibraryVersion(ApiGatewayServiceStubSettings.class)) @@ -508,11 +523,30 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil GaxGrpcProperties.getGrpcTokenName(), GaxGrpcProperties.getGrpcVersion()); } - /** Returns a new builder for this class. */ + @BetaApi("The surface for customizing headers is not stable yet and may change in the future.") + public static ApiClientHeaderProvider.Builder defaultHttpJsonApiClientHeaderProviderBuilder() { + return ApiClientHeaderProvider.newBuilder() + .setGeneratedLibToken( + "gapic", GaxProperties.getLibraryVersion(ApiGatewayServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ApiGatewayServiceStubSettings.defaultGrpcApiClientHeaderProviderBuilder(); + } + + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -747,6 +781,19 @@ private static Builder createDefault() { return initDefaults(builder); } + private static Builder createHttpJsonDefault() { + Builder builder = new Builder(((ClientContext) null)); + + builder.setTransportChannelProvider(defaultHttpJsonTransportProviderBuilder().build()); + builder.setCredentialsProvider(defaultCredentialsProviderBuilder().build()); + builder.setInternalHeaderProvider(defaultHttpJsonApiClientHeaderProviderBuilder().build()); + builder.setEndpoint(getDefaultEndpoint()); + builder.setMtlsEndpoint(getDefaultMtlsEndpoint()); + builder.setSwitchToMtlsEndpointAllowed(true); + + return initDefaults(builder); + } + private static Builder initDefaults(Builder builder) { builder .listGatewaysSettings() diff --git a/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/stub/HttpJsonApiGatewayServiceCallableFactory.java b/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/stub/HttpJsonApiGatewayServiceCallableFactory.java new file mode 100644 index 0000000..455fb7f --- /dev/null +++ b/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/stub/HttpJsonApiGatewayServiceCallableFactory.java @@ -0,0 +1,105 @@ +/* + * Copyright 2022 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.apigateway.v1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the ApiGatewayService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonApiGatewayServiceCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/stub/HttpJsonApiGatewayServiceStub.java b/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/stub/HttpJsonApiGatewayServiceStub.java new file mode 100644 index 0000000..1d8d655 --- /dev/null +++ b/google-cloud-api-gateway/src/main/java/com/google/cloud/apigateway/v1/stub/HttpJsonApiGatewayServiceStub.java @@ -0,0 +1,1117 @@ +/* + * Copyright 2022 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.apigateway.v1.stub; + +import static com.google.cloud.apigateway.v1.ApiGatewayServiceClient.ListApiConfigsPagedResponse; +import static com.google.cloud.apigateway.v1.ApiGatewayServiceClient.ListApisPagedResponse; +import static com.google.cloud.apigateway.v1.ApiGatewayServiceClient.ListGatewaysPagedResponse; + +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.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.UnaryCallable; +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.CreateApiConfigRequest; +import com.google.cloud.apigateway.v1.CreateApiRequest; +import com.google.cloud.apigateway.v1.CreateGatewayRequest; +import com.google.cloud.apigateway.v1.DeleteApiConfigRequest; +import com.google.cloud.apigateway.v1.DeleteApiRequest; +import com.google.cloud.apigateway.v1.DeleteGatewayRequest; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.GetApiConfigRequest; +import com.google.cloud.apigateway.v1.GetApiRequest; +import com.google.cloud.apigateway.v1.GetGatewayRequest; +import com.google.cloud.apigateway.v1.ListApiConfigsRequest; +import com.google.cloud.apigateway.v1.ListApiConfigsResponse; +import com.google.cloud.apigateway.v1.ListApisRequest; +import com.google.cloud.apigateway.v1.ListApisResponse; +import com.google.cloud.apigateway.v1.ListGatewaysRequest; +import com.google.cloud.apigateway.v1.ListGatewaysResponse; +import com.google.cloud.apigateway.v1.OperationMetadata; +import com.google.cloud.apigateway.v1.UpdateApiConfigRequest; +import com.google.cloud.apigateway.v1.UpdateApiRequest; +import com.google.cloud.apigateway.v1.UpdateGatewayRequest; +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 ApiGatewayService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonApiGatewayServiceStub extends ApiGatewayServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(OperationMetadata.getDescriptor()) + .add(Empty.getDescriptor()) + .add(Gateway.getDescriptor()) + .add(ApiConfig.getDescriptor()) + .add(Api.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listGatewaysMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/ListGateways") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/gateways", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListGatewaysResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getGatewayMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/GetGateway") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/gateways/*}", + 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(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Gateway.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createGatewayMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/CreateGateway") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/gateways", + 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, "gatewayId", request.getGatewayId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("gateway", request.getGateway())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateGatewayRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateGatewayMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/UpdateGateway") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{gateway.name=projects/*/locations/*/gateways/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "gateway.name", request.getGateway().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("gateway", request.getGateway())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateGatewayRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteGatewayMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/DeleteGateway") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/gateways/*}", + 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(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteGatewayRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listApisMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/ListApis") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/apis", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListApisResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getApiMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/GetApi") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/apis/*}", + 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(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Api.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor createApiMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/CreateApi") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/apis", + 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, "apiId", request.getApiId()); + return fields; + }) + .setRequestBodyExtractor( + request -> ProtoRestSerializer.create().toBody("api", request.getApi())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateApiRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor updateApiMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/UpdateApi") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{api.name=projects/*/locations/*/apis/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "api.name", request.getApi().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> ProtoRestSerializer.create().toBody("api", request.getApi())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateApiRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor deleteApiMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/DeleteApi") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/apis/*}", + 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(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteApiRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listApiConfigsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/ListApiConfigs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/apis/*}/configs", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "parent", request.getParent()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "filter", request.getFilter()); + serializer.putQueryParam(fields, "orderBy", request.getOrderBy()); + serializer.putQueryParam(fields, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListApiConfigsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getApiConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/GetApiConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/apis/*/configs/*}", + 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, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ApiConfig.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createApiConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/CreateApiConfig") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/apis/*}/configs", + 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, "apiConfigId", request.getApiConfigId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("apiConfig", request.getApiConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateApiConfigRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateApiConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/UpdateApiConfig") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{apiConfig.name=projects/*/locations/*/apis/*/configs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "apiConfig.name", request.getApiConfig().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("apiConfig", request.getApiConfig())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateApiConfigRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteApiConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.apigateway.v1.ApiGatewayService/DeleteApiConfig") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/apis/*/configs/*}", + 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(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteApiConfigRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable listGatewaysCallable; + private final UnaryCallable + listGatewaysPagedCallable; + private final UnaryCallable getGatewayCallable; + private final UnaryCallable createGatewayCallable; + private final OperationCallable + createGatewayOperationCallable; + private final UnaryCallable updateGatewayCallable; + private final OperationCallable + updateGatewayOperationCallable; + private final UnaryCallable deleteGatewayCallable; + private final OperationCallable + deleteGatewayOperationCallable; + private final UnaryCallable listApisCallable; + private final UnaryCallable listApisPagedCallable; + private final UnaryCallable getApiCallable; + private final UnaryCallable createApiCallable; + private final OperationCallable + createApiOperationCallable; + private final UnaryCallable updateApiCallable; + private final OperationCallable + updateApiOperationCallable; + private final UnaryCallable deleteApiCallable; + private final OperationCallable + deleteApiOperationCallable; + private final UnaryCallable listApiConfigsCallable; + private final UnaryCallable + listApiConfigsPagedCallable; + private final UnaryCallable getApiConfigCallable; + private final UnaryCallable createApiConfigCallable; + private final OperationCallable + createApiConfigOperationCallable; + private final UnaryCallable updateApiConfigCallable; + private final OperationCallable + updateApiConfigOperationCallable; + private final UnaryCallable deleteApiConfigCallable; + private final OperationCallable + deleteApiConfigOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonApiGatewayServiceStub create(ApiGatewayServiceStubSettings settings) + throws IOException { + return new HttpJsonApiGatewayServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonApiGatewayServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonApiGatewayServiceStub( + ApiGatewayServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonApiGatewayServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonApiGatewayServiceStub( + ApiGatewayServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonApiGatewayServiceStub, 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 HttpJsonApiGatewayServiceStub( + ApiGatewayServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonApiGatewayServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonApiGatewayServiceStub, 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 HttpJsonApiGatewayServiceStub( + ApiGatewayServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings listGatewaysTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listGatewaysMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getGatewayTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getGatewayMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createGatewayTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createGatewayMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateGatewayTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateGatewayMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteGatewayTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteGatewayMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listApisTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listApisMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getApiTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getApiMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createApiTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createApiMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateApiTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateApiMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteApiTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteApiMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listApiConfigsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listApiConfigsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getApiConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getApiConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createApiConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createApiConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateApiConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateApiConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteApiConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteApiConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listGatewaysCallable = + callableFactory.createUnaryCallable( + listGatewaysTransportSettings, settings.listGatewaysSettings(), clientContext); + this.listGatewaysPagedCallable = + callableFactory.createPagedCallable( + listGatewaysTransportSettings, settings.listGatewaysSettings(), clientContext); + this.getGatewayCallable = + callableFactory.createUnaryCallable( + getGatewayTransportSettings, settings.getGatewaySettings(), clientContext); + this.createGatewayCallable = + callableFactory.createUnaryCallable( + createGatewayTransportSettings, settings.createGatewaySettings(), clientContext); + this.createGatewayOperationCallable = + callableFactory.createOperationCallable( + createGatewayTransportSettings, + settings.createGatewayOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateGatewayCallable = + callableFactory.createUnaryCallable( + updateGatewayTransportSettings, settings.updateGatewaySettings(), clientContext); + this.updateGatewayOperationCallable = + callableFactory.createOperationCallable( + updateGatewayTransportSettings, + settings.updateGatewayOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteGatewayCallable = + callableFactory.createUnaryCallable( + deleteGatewayTransportSettings, settings.deleteGatewaySettings(), clientContext); + this.deleteGatewayOperationCallable = + callableFactory.createOperationCallable( + deleteGatewayTransportSettings, + settings.deleteGatewayOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listApisCallable = + callableFactory.createUnaryCallable( + listApisTransportSettings, settings.listApisSettings(), clientContext); + this.listApisPagedCallable = + callableFactory.createPagedCallable( + listApisTransportSettings, settings.listApisSettings(), clientContext); + this.getApiCallable = + callableFactory.createUnaryCallable( + getApiTransportSettings, settings.getApiSettings(), clientContext); + this.createApiCallable = + callableFactory.createUnaryCallable( + createApiTransportSettings, settings.createApiSettings(), clientContext); + this.createApiOperationCallable = + callableFactory.createOperationCallable( + createApiTransportSettings, + settings.createApiOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateApiCallable = + callableFactory.createUnaryCallable( + updateApiTransportSettings, settings.updateApiSettings(), clientContext); + this.updateApiOperationCallable = + callableFactory.createOperationCallable( + updateApiTransportSettings, + settings.updateApiOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteApiCallable = + callableFactory.createUnaryCallable( + deleteApiTransportSettings, settings.deleteApiSettings(), clientContext); + this.deleteApiOperationCallable = + callableFactory.createOperationCallable( + deleteApiTransportSettings, + settings.deleteApiOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listApiConfigsCallable = + callableFactory.createUnaryCallable( + listApiConfigsTransportSettings, settings.listApiConfigsSettings(), clientContext); + this.listApiConfigsPagedCallable = + callableFactory.createPagedCallable( + listApiConfigsTransportSettings, settings.listApiConfigsSettings(), clientContext); + this.getApiConfigCallable = + callableFactory.createUnaryCallable( + getApiConfigTransportSettings, settings.getApiConfigSettings(), clientContext); + this.createApiConfigCallable = + callableFactory.createUnaryCallable( + createApiConfigTransportSettings, settings.createApiConfigSettings(), clientContext); + this.createApiConfigOperationCallable = + callableFactory.createOperationCallable( + createApiConfigTransportSettings, + settings.createApiConfigOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateApiConfigCallable = + callableFactory.createUnaryCallable( + updateApiConfigTransportSettings, settings.updateApiConfigSettings(), clientContext); + this.updateApiConfigOperationCallable = + callableFactory.createOperationCallable( + updateApiConfigTransportSettings, + settings.updateApiConfigOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteApiConfigCallable = + callableFactory.createUnaryCallable( + deleteApiConfigTransportSettings, settings.deleteApiConfigSettings(), clientContext); + this.deleteApiConfigOperationCallable = + callableFactory.createOperationCallable( + deleteApiConfigTransportSettings, + settings.deleteApiConfigOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listGatewaysMethodDescriptor); + methodDescriptors.add(getGatewayMethodDescriptor); + methodDescriptors.add(createGatewayMethodDescriptor); + methodDescriptors.add(updateGatewayMethodDescriptor); + methodDescriptors.add(deleteGatewayMethodDescriptor); + methodDescriptors.add(listApisMethodDescriptor); + methodDescriptors.add(getApiMethodDescriptor); + methodDescriptors.add(createApiMethodDescriptor); + methodDescriptors.add(updateApiMethodDescriptor); + methodDescriptors.add(deleteApiMethodDescriptor); + methodDescriptors.add(listApiConfigsMethodDescriptor); + methodDescriptors.add(getApiConfigMethodDescriptor); + methodDescriptors.add(createApiConfigMethodDescriptor); + methodDescriptors.add(updateApiConfigMethodDescriptor); + methodDescriptors.add(deleteApiConfigMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listGatewaysCallable() { + return listGatewaysCallable; + } + + @Override + public UnaryCallable listGatewaysPagedCallable() { + return listGatewaysPagedCallable; + } + + @Override + public UnaryCallable getGatewayCallable() { + return getGatewayCallable; + } + + @Override + public UnaryCallable createGatewayCallable() { + return createGatewayCallable; + } + + @Override + public OperationCallable + createGatewayOperationCallable() { + return createGatewayOperationCallable; + } + + @Override + public UnaryCallable updateGatewayCallable() { + return updateGatewayCallable; + } + + @Override + public OperationCallable + updateGatewayOperationCallable() { + return updateGatewayOperationCallable; + } + + @Override + public UnaryCallable deleteGatewayCallable() { + return deleteGatewayCallable; + } + + @Override + public OperationCallable + deleteGatewayOperationCallable() { + return deleteGatewayOperationCallable; + } + + @Override + public UnaryCallable listApisCallable() { + return listApisCallable; + } + + @Override + public UnaryCallable listApisPagedCallable() { + return listApisPagedCallable; + } + + @Override + public UnaryCallable getApiCallable() { + return getApiCallable; + } + + @Override + public UnaryCallable createApiCallable() { + return createApiCallable; + } + + @Override + public OperationCallable createApiOperationCallable() { + return createApiOperationCallable; + } + + @Override + public UnaryCallable updateApiCallable() { + return updateApiCallable; + } + + @Override + public OperationCallable updateApiOperationCallable() { + return updateApiOperationCallable; + } + + @Override + public UnaryCallable deleteApiCallable() { + return deleteApiCallable; + } + + @Override + public OperationCallable + deleteApiOperationCallable() { + return deleteApiOperationCallable; + } + + @Override + public UnaryCallable listApiConfigsCallable() { + return listApiConfigsCallable; + } + + @Override + public UnaryCallable + listApiConfigsPagedCallable() { + return listApiConfigsPagedCallable; + } + + @Override + public UnaryCallable getApiConfigCallable() { + return getApiConfigCallable; + } + + @Override + public UnaryCallable createApiConfigCallable() { + return createApiConfigCallable; + } + + @Override + public OperationCallable + createApiConfigOperationCallable() { + return createApiConfigOperationCallable; + } + + @Override + public UnaryCallable updateApiConfigCallable() { + return updateApiConfigCallable; + } + + @Override + public OperationCallable + updateApiConfigOperationCallable() { + return updateApiConfigOperationCallable; + } + + @Override + public UnaryCallable deleteApiConfigCallable() { + return deleteApiConfigCallable; + } + + @Override + public OperationCallable + deleteApiConfigOperationCallable() { + return deleteApiConfigOperationCallable; + } + + @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); + } +} diff --git a/google-cloud-api-gateway/src/test/java/com/google/cloud/apigateway/v1/ApiGatewayServiceClientHttpJsonTest.java b/google-cloud-api-gateway/src/test/java/com/google/cloud/apigateway/v1/ApiGatewayServiceClientHttpJsonTest.java new file mode 100644 index 0000000..e9c4cc5 --- /dev/null +++ b/google-cloud-api-gateway/src/test/java/com/google/cloud/apigateway/v1/ApiGatewayServiceClientHttpJsonTest.java @@ -0,0 +1,1552 @@ +/* + * Copyright 2022 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.apigateway.v1; + +import static com.google.cloud.apigateway.v1.ApiGatewayServiceClient.ListApiConfigsPagedResponse; +import static com.google.cloud.apigateway.v1.ApiGatewayServiceClient.ListApisPagedResponse; +import static com.google.cloud.apigateway.v1.ApiGatewayServiceClient.ListGatewaysPagedResponse; + +import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.testing.MockHttpService; +import com.google.api.gax.rpc.ApiClientHeaderProvider; +import com.google.api.gax.rpc.ApiException; +import com.google.api.gax.rpc.ApiExceptionFactory; +import com.google.api.gax.rpc.InvalidArgumentException; +import com.google.api.gax.rpc.StatusCode; +import com.google.api.gax.rpc.testing.FakeStatusCode; +import com.google.cloud.apigateway.v1.stub.HttpJsonApiGatewayServiceStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ApiGatewayServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ApiGatewayServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonApiGatewayServiceStub.getMethodDescriptors(), + ApiGatewayServiceSettings.getDefaultEndpoint()); + ApiGatewayServiceSettings settings = + ApiGatewayServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ApiGatewayServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ApiGatewayServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listGatewaysTest() throws Exception { + Gateway responsesElement = Gateway.newBuilder().build(); + ListGatewaysResponse expectedResponse = + ListGatewaysResponse.newBuilder() + .setNextPageToken("") + .addAllGateways(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListGatewaysPagedResponse pagedListResponse = client.listGateways(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGatewaysList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listGatewaysExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listGateways(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listGatewaysTest2() throws Exception { + Gateway responsesElement = Gateway.newBuilder().build(); + ListGatewaysResponse expectedResponse = + ListGatewaysResponse.newBuilder() + .setNextPageToken("") + .addAllGateways(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListGatewaysPagedResponse pagedListResponse = client.listGateways(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGatewaysList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listGatewaysExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listGateways(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getGatewayTest() throws Exception { + Gateway expectedResponse = + Gateway.newBuilder() + .setName(GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setApiConfig(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .setDefaultHostname("defaultHostname1698284948") + .build(); + mockService.addResponse(expectedResponse); + + GatewayName name = GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]"); + + Gateway actualResponse = client.getGateway(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getGatewayExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GatewayName name = GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]"); + client.getGateway(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getGatewayTest2() throws Exception { + Gateway expectedResponse = + Gateway.newBuilder() + .setName(GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setApiConfig(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .setDefaultHostname("defaultHostname1698284948") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-4351/locations/location-4351/gateways/gateway-4351"; + + Gateway actualResponse = client.getGateway(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getGatewayExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-4351/locations/location-4351/gateways/gateway-4351"; + client.getGateway(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createGatewayTest() throws Exception { + Gateway expectedResponse = + Gateway.newBuilder() + .setName(GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setApiConfig(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .setDefaultHostname("defaultHostname1698284948") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createGatewayTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Gateway gateway = Gateway.newBuilder().build(); + String gatewayId = "gatewayId-1354641793"; + + Gateway actualResponse = client.createGatewayAsync(parent, gateway, gatewayId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createGatewayExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Gateway gateway = Gateway.newBuilder().build(); + String gatewayId = "gatewayId-1354641793"; + client.createGatewayAsync(parent, gateway, gatewayId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createGatewayTest2() throws Exception { + Gateway expectedResponse = + Gateway.newBuilder() + .setName(GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setApiConfig(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .setDefaultHostname("defaultHostname1698284948") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createGatewayTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Gateway gateway = Gateway.newBuilder().build(); + String gatewayId = "gatewayId-1354641793"; + + Gateway actualResponse = client.createGatewayAsync(parent, gateway, gatewayId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createGatewayExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Gateway gateway = Gateway.newBuilder().build(); + String gatewayId = "gatewayId-1354641793"; + client.createGatewayAsync(parent, gateway, gatewayId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateGatewayTest() throws Exception { + Gateway expectedResponse = + Gateway.newBuilder() + .setName(GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setApiConfig(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .setDefaultHostname("defaultHostname1698284948") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateGatewayTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Gateway gateway = + Gateway.newBuilder() + .setName(GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setApiConfig(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .setDefaultHostname("defaultHostname1698284948") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Gateway actualResponse = client.updateGatewayAsync(gateway, updateMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateGatewayExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Gateway gateway = + Gateway.newBuilder() + .setName(GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setApiConfig(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .setDefaultHostname("defaultHostname1698284948") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateGatewayAsync(gateway, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteGatewayTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteGatewayTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + GatewayName name = GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]"); + + client.deleteGatewayAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteGatewayExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GatewayName name = GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]"); + client.deleteGatewayAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteGatewayTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteGatewayTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-4351/locations/location-4351/gateways/gateway-4351"; + + client.deleteGatewayAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteGatewayExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-4351/locations/location-4351/gateways/gateway-4351"; + client.deleteGatewayAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listApisTest() throws Exception { + Api responsesElement = Api.newBuilder().build(); + ListApisResponse expectedResponse = + ListApisResponse.newBuilder() + .setNextPageToken("") + .addAllApis(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListApisPagedResponse pagedListResponse = client.listApis(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getApisList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listApisExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listApis(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listApisTest2() throws Exception { + Api responsesElement = Api.newBuilder().build(); + ListApisResponse expectedResponse = + ListApisResponse.newBuilder() + .setNextPageToken("") + .addAllApis(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListApisPagedResponse pagedListResponse = client.listApis(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getApisList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listApisExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listApis(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getApiTest() throws Exception { + Api expectedResponse = + Api.newBuilder() + .setName(ApiName.of("[PROJECT]", "[API]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setManagedService("managedService2047823382") + .build(); + mockService.addResponse(expectedResponse); + + ApiName name = ApiName.of("[PROJECT]", "[API]"); + + Api actualResponse = client.getApi(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getApiExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ApiName name = ApiName.of("[PROJECT]", "[API]"); + client.getApi(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getApiTest2() throws Exception { + Api expectedResponse = + Api.newBuilder() + .setName(ApiName.of("[PROJECT]", "[API]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setManagedService("managedService2047823382") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3607/locations/location-3607/apis/api-3607"; + + Api actualResponse = client.getApi(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getApiExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3607/locations/location-3607/apis/api-3607"; + client.getApi(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createApiTest() throws Exception { + Api expectedResponse = + Api.newBuilder() + .setName(ApiName.of("[PROJECT]", "[API]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setManagedService("managedService2047823382") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createApiTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Api api = Api.newBuilder().build(); + String apiId = "apiId93021397"; + + Api actualResponse = client.createApiAsync(parent, api, apiId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createApiExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Api api = Api.newBuilder().build(); + String apiId = "apiId93021397"; + client.createApiAsync(parent, api, apiId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createApiTest2() throws Exception { + Api expectedResponse = + Api.newBuilder() + .setName(ApiName.of("[PROJECT]", "[API]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setManagedService("managedService2047823382") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createApiTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Api api = Api.newBuilder().build(); + String apiId = "apiId93021397"; + + Api actualResponse = client.createApiAsync(parent, api, apiId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createApiExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + Api api = Api.newBuilder().build(); + String apiId = "apiId93021397"; + client.createApiAsync(parent, api, apiId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateApiTest() throws Exception { + Api expectedResponse = + Api.newBuilder() + .setName(ApiName.of("[PROJECT]", "[API]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setManagedService("managedService2047823382") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateApiTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Api api = + Api.newBuilder() + .setName(ApiName.of("[PROJECT]", "[API]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setManagedService("managedService2047823382") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Api actualResponse = client.updateApiAsync(api, updateMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateApiExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Api api = + Api.newBuilder() + .setName(ApiName.of("[PROJECT]", "[API]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setManagedService("managedService2047823382") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateApiAsync(api, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteApiTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteApiTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ApiName name = ApiName.of("[PROJECT]", "[API]"); + + client.deleteApiAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteApiExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ApiName name = ApiName.of("[PROJECT]", "[API]"); + client.deleteApiAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteApiTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteApiTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-3607/locations/location-3607/apis/api-3607"; + + client.deleteApiAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteApiExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3607/locations/location-3607/apis/api-3607"; + client.deleteApiAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listApiConfigsTest() throws Exception { + ApiConfig responsesElement = ApiConfig.newBuilder().build(); + ListApiConfigsResponse expectedResponse = + ListApiConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllApiConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ApiName parent = ApiName.of("[PROJECT]", "[API]"); + + ListApiConfigsPagedResponse pagedListResponse = client.listApiConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getApiConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listApiConfigsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ApiName parent = ApiName.of("[PROJECT]", "[API]"); + client.listApiConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listApiConfigsTest2() throws Exception { + ApiConfig responsesElement = ApiConfig.newBuilder().build(); + ListApiConfigsResponse expectedResponse = + ListApiConfigsResponse.newBuilder() + .setNextPageToken("") + .addAllApiConfigs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-7414/locations/location-7414/apis/api-7414"; + + ListApiConfigsPagedResponse pagedListResponse = client.listApiConfigs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getApiConfigsList().get(0), resources.get(0)); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void listApiConfigsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-7414/locations/location-7414/apis/api-7414"; + client.listApiConfigs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getApiConfigTest() throws Exception { + ApiConfig expectedResponse = + ApiConfig.newBuilder() + .setName(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setGatewayServiceAccount("gatewayServiceAccount153690396") + .setServiceConfigId("serviceConfigId650537426") + .addAllOpenapiDocuments(new ArrayList()) + .addAllGrpcServices(new ArrayList()) + .addAllManagedServiceConfigs(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + ApiConfigName name = ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]"); + + ApiConfig actualResponse = client.getApiConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getApiConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ApiConfigName name = ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]"); + client.getApiConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getApiConfigTest2() throws Exception { + ApiConfig expectedResponse = + ApiConfig.newBuilder() + .setName(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setGatewayServiceAccount("gatewayServiceAccount153690396") + .setServiceConfigId("serviceConfigId650537426") + .addAllOpenapiDocuments(new ArrayList()) + .addAllGrpcServices(new ArrayList()) + .addAllManagedServiceConfigs(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-7242/locations/location-7242/apis/api-7242/configs/config-7242"; + + ApiConfig actualResponse = client.getApiConfig(name); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getApiConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7242/locations/location-7242/apis/api-7242/configs/config-7242"; + client.getApiConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createApiConfigTest() throws Exception { + ApiConfig expectedResponse = + ApiConfig.newBuilder() + .setName(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setGatewayServiceAccount("gatewayServiceAccount153690396") + .setServiceConfigId("serviceConfigId650537426") + .addAllOpenapiDocuments(new ArrayList()) + .addAllGrpcServices(new ArrayList()) + .addAllManagedServiceConfigs(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createApiConfigTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ApiName parent = ApiName.of("[PROJECT]", "[API]"); + ApiConfig apiConfig = ApiConfig.newBuilder().build(); + String apiConfigId = "apiConfigId-64952265"; + + ApiConfig actualResponse = client.createApiConfigAsync(parent, apiConfig, apiConfigId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createApiConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ApiName parent = ApiName.of("[PROJECT]", "[API]"); + ApiConfig apiConfig = ApiConfig.newBuilder().build(); + String apiConfigId = "apiConfigId-64952265"; + client.createApiConfigAsync(parent, apiConfig, apiConfigId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createApiConfigTest2() throws Exception { + ApiConfig expectedResponse = + ApiConfig.newBuilder() + .setName(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setGatewayServiceAccount("gatewayServiceAccount153690396") + .setServiceConfigId("serviceConfigId650537426") + .addAllOpenapiDocuments(new ArrayList()) + .addAllGrpcServices(new ArrayList()) + .addAllManagedServiceConfigs(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createApiConfigTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-7414/locations/location-7414/apis/api-7414"; + ApiConfig apiConfig = ApiConfig.newBuilder().build(); + String apiConfigId = "apiConfigId-64952265"; + + ApiConfig actualResponse = client.createApiConfigAsync(parent, apiConfig, apiConfigId).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createApiConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-7414/locations/location-7414/apis/api-7414"; + ApiConfig apiConfig = ApiConfig.newBuilder().build(); + String apiConfigId = "apiConfigId-64952265"; + client.createApiConfigAsync(parent, apiConfig, apiConfigId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateApiConfigTest() throws Exception { + ApiConfig expectedResponse = + ApiConfig.newBuilder() + .setName(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setGatewayServiceAccount("gatewayServiceAccount153690396") + .setServiceConfigId("serviceConfigId650537426") + .addAllOpenapiDocuments(new ArrayList()) + .addAllGrpcServices(new ArrayList()) + .addAllManagedServiceConfigs(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateApiConfigTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ApiConfig apiConfig = + ApiConfig.newBuilder() + .setName(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setGatewayServiceAccount("gatewayServiceAccount153690396") + .setServiceConfigId("serviceConfigId650537426") + .addAllOpenapiDocuments(new ArrayList()) + .addAllGrpcServices(new ArrayList()) + .addAllManagedServiceConfigs(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + ApiConfig actualResponse = client.updateApiConfigAsync(apiConfig, updateMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateApiConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ApiConfig apiConfig = + ApiConfig.newBuilder() + .setName(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setDisplayName("displayName1714148973") + .setGatewayServiceAccount("gatewayServiceAccount153690396") + .setServiceConfigId("serviceConfigId650537426") + .addAllOpenapiDocuments(new ArrayList()) + .addAllGrpcServices(new ArrayList()) + .addAllManagedServiceConfigs(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateApiConfigAsync(apiConfig, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteApiConfigTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteApiConfigTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ApiConfigName name = ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]"); + + client.deleteApiConfigAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteApiConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ApiConfigName name = ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]"); + client.deleteApiConfigAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteApiConfigTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteApiConfigTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-7242/locations/location-7242/apis/api-7242/configs/config-7242"; + + client.deleteApiConfigAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteApiConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-7242/locations/location-7242/apis/api-7242/configs/config-7242"; + client.deleteApiConfigAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 0000000..def9d53 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiGatewayServiceSettings; +import com.google.cloud.apigateway.v1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ApiGatewayServiceSettings apiGatewayServiceSettings = + ApiGatewayServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ApiGatewayServiceClient apiGatewayServiceClient = + ApiGatewayServiceClient.create(apiGatewayServiceSettings); + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 0000000..9c31c6b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiGatewayServiceSettings; + +public class SyncCreateSetCredentialsProvider1 { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider1(); + } + + public static void syncCreateSetCredentialsProvider1() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ApiGatewayServiceSettings apiGatewayServiceSettings = + ApiGatewayServiceSettings.newBuilder() + .setTransportChannelProvider( + ApiGatewayServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ApiGatewayServiceClient apiGatewayServiceClient = + ApiGatewayServiceClient.create(apiGatewayServiceSettings); + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 0000000..b9bb6c5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_create_setendpoint_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiGatewayServiceSettings; +import com.google.cloud.apigateway.v1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ApiGatewayServiceSettings apiGatewayServiceSettings = + ApiGatewayServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ApiGatewayServiceClient apiGatewayServiceClient = + ApiGatewayServiceClient.create(apiGatewayServiceSettings); + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/AsyncCreateApi.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/AsyncCreateApi.java new file mode 100644 index 0000000..99aa384 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/AsyncCreateApi.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_createapi_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.CreateApiRequest; +import com.google.cloud.apigateway.v1.LocationName; +import com.google.longrunning.Operation; + +public class AsyncCreateApi { + + public static void main(String[] args) throws Exception { + asyncCreateApi(); + } + + public static void asyncCreateApi() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + CreateApiRequest request = + CreateApiRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setApiId("apiId93021397") + .setApi(Api.newBuilder().build()) + .build(); + ApiFuture future = apiGatewayServiceClient.createApiCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_createapi_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/AsyncCreateApiLRO.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/AsyncCreateApiLRO.java new file mode 100644 index 0000000..55c77d0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/AsyncCreateApiLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_createapi_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.CreateApiRequest; +import com.google.cloud.apigateway.v1.LocationName; +import com.google.cloud.apigateway.v1.OperationMetadata; + +public class AsyncCreateApiLRO { + + public static void main(String[] args) throws Exception { + asyncCreateApiLRO(); + } + + public static void asyncCreateApiLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + CreateApiRequest request = + CreateApiRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setApiId("apiId93021397") + .setApi(Api.newBuilder().build()) + .build(); + OperationFuture future = + apiGatewayServiceClient.createApiOperationCallable().futureCall(request); + // Do something. + Api response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_createapi_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/SyncCreateApi.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/SyncCreateApi.java new file mode 100644 index 0000000..63d6f19 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/SyncCreateApi.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_createapi_sync] +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.CreateApiRequest; +import com.google.cloud.apigateway.v1.LocationName; + +public class SyncCreateApi { + + public static void main(String[] args) throws Exception { + syncCreateApi(); + } + + public static void syncCreateApi() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + CreateApiRequest request = + CreateApiRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setApiId("apiId93021397") + .setApi(Api.newBuilder().build()) + .build(); + Api response = apiGatewayServiceClient.createApiAsync(request).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_createapi_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/SyncCreateApiLocationnameApiString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/SyncCreateApiLocationnameApiString.java new file mode 100644 index 0000000..4826ac3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/SyncCreateApiLocationnameApiString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_createapi_locationnameapistring_sync] +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.LocationName; + +public class SyncCreateApiLocationnameApiString { + + public static void main(String[] args) throws Exception { + syncCreateApiLocationnameApiString(); + } + + public static void syncCreateApiLocationnameApiString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Api api = Api.newBuilder().build(); + String apiId = "apiId93021397"; + Api response = apiGatewayServiceClient.createApiAsync(parent, api, apiId).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_createapi_locationnameapistring_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/SyncCreateApiStringApiString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/SyncCreateApiStringApiString.java new file mode 100644 index 0000000..d5a8d7f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapi/SyncCreateApiStringApiString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_createapi_stringapistring_sync] +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.LocationName; + +public class SyncCreateApiStringApiString { + + public static void main(String[] args) throws Exception { + syncCreateApiStringApiString(); + } + + public static void syncCreateApiStringApiString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Api api = Api.newBuilder().build(); + String apiId = "apiId93021397"; + Api response = apiGatewayServiceClient.createApiAsync(parent, api, apiId).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_createapi_stringapistring_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/AsyncCreateApiConfig.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/AsyncCreateApiConfig.java new file mode 100644 index 0000000..14da639 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/AsyncCreateApiConfig.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_createapiconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; +import com.google.cloud.apigateway.v1.CreateApiConfigRequest; +import com.google.longrunning.Operation; + +public class AsyncCreateApiConfig { + + public static void main(String[] args) throws Exception { + asyncCreateApiConfig(); + } + + public static void asyncCreateApiConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + CreateApiConfigRequest request = + CreateApiConfigRequest.newBuilder() + .setParent(ApiName.of("[PROJECT]", "[API]").toString()) + .setApiConfigId("apiConfigId-64952265") + .setApiConfig(ApiConfig.newBuilder().build()) + .build(); + ApiFuture future = + apiGatewayServiceClient.createApiConfigCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_createapiconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/AsyncCreateApiConfigLRO.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/AsyncCreateApiConfigLRO.java new file mode 100644 index 0000000..3d3f520 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/AsyncCreateApiConfigLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_createapiconfig_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; +import com.google.cloud.apigateway.v1.CreateApiConfigRequest; +import com.google.cloud.apigateway.v1.OperationMetadata; + +public class AsyncCreateApiConfigLRO { + + public static void main(String[] args) throws Exception { + asyncCreateApiConfigLRO(); + } + + public static void asyncCreateApiConfigLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + CreateApiConfigRequest request = + CreateApiConfigRequest.newBuilder() + .setParent(ApiName.of("[PROJECT]", "[API]").toString()) + .setApiConfigId("apiConfigId-64952265") + .setApiConfig(ApiConfig.newBuilder().build()) + .build(); + OperationFuture future = + apiGatewayServiceClient.createApiConfigOperationCallable().futureCall(request); + // Do something. + ApiConfig response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_createapiconfig_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/SyncCreateApiConfig.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/SyncCreateApiConfig.java new file mode 100644 index 0000000..89ccd4f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/SyncCreateApiConfig.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_createapiconfig_sync] +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; +import com.google.cloud.apigateway.v1.CreateApiConfigRequest; + +public class SyncCreateApiConfig { + + public static void main(String[] args) throws Exception { + syncCreateApiConfig(); + } + + public static void syncCreateApiConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + CreateApiConfigRequest request = + CreateApiConfigRequest.newBuilder() + .setParent(ApiName.of("[PROJECT]", "[API]").toString()) + .setApiConfigId("apiConfigId-64952265") + .setApiConfig(ApiConfig.newBuilder().build()) + .build(); + ApiConfig response = apiGatewayServiceClient.createApiConfigAsync(request).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_createapiconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/SyncCreateApiConfigApinameApiconfigString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/SyncCreateApiConfigApinameApiconfigString.java new file mode 100644 index 0000000..8871e99 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/SyncCreateApiConfigApinameApiconfigString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START +// apigateway_v1_generated_apigatewayserviceclient_createapiconfig_apinameapiconfigstring_sync] +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; + +public class SyncCreateApiConfigApinameApiconfigString { + + public static void main(String[] args) throws Exception { + syncCreateApiConfigApinameApiconfigString(); + } + + public static void syncCreateApiConfigApinameApiconfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ApiName parent = ApiName.of("[PROJECT]", "[API]"); + ApiConfig apiConfig = ApiConfig.newBuilder().build(); + String apiConfigId = "apiConfigId-64952265"; + ApiConfig response = + apiGatewayServiceClient.createApiConfigAsync(parent, apiConfig, apiConfigId).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_createapiconfig_apinameapiconfigstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/SyncCreateApiConfigStringApiconfigString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/SyncCreateApiConfigStringApiconfigString.java new file mode 100644 index 0000000..e93f356 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/createapiconfig/SyncCreateApiConfigStringApiconfigString.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START +// apigateway_v1_generated_apigatewayserviceclient_createapiconfig_stringapiconfigstring_sync] +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; + +public class SyncCreateApiConfigStringApiconfigString { + + public static void main(String[] args) throws Exception { + syncCreateApiConfigStringApiconfigString(); + } + + public static void syncCreateApiConfigStringApiconfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + String parent = ApiName.of("[PROJECT]", "[API]").toString(); + ApiConfig apiConfig = ApiConfig.newBuilder().build(); + String apiConfigId = "apiConfigId-64952265"; + ApiConfig response = + apiGatewayServiceClient.createApiConfigAsync(parent, apiConfig, apiConfigId).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_createapiconfig_stringapiconfigstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/AsyncCreateGateway.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/AsyncCreateGateway.java new file mode 100644 index 0000000..62f4847 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/AsyncCreateGateway.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_creategateway_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.CreateGatewayRequest; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.LocationName; +import com.google.longrunning.Operation; + +public class AsyncCreateGateway { + + public static void main(String[] args) throws Exception { + asyncCreateGateway(); + } + + public static void asyncCreateGateway() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + CreateGatewayRequest request = + CreateGatewayRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setGatewayId("gatewayId-1354641793") + .setGateway(Gateway.newBuilder().build()) + .build(); + ApiFuture future = + apiGatewayServiceClient.createGatewayCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_creategateway_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/AsyncCreateGatewayLRO.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/AsyncCreateGatewayLRO.java new file mode 100644 index 0000000..40058a8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/AsyncCreateGatewayLRO.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_creategateway_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.CreateGatewayRequest; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.LocationName; +import com.google.cloud.apigateway.v1.OperationMetadata; + +public class AsyncCreateGatewayLRO { + + public static void main(String[] args) throws Exception { + asyncCreateGatewayLRO(); + } + + public static void asyncCreateGatewayLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + CreateGatewayRequest request = + CreateGatewayRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setGatewayId("gatewayId-1354641793") + .setGateway(Gateway.newBuilder().build()) + .build(); + OperationFuture future = + apiGatewayServiceClient.createGatewayOperationCallable().futureCall(request); + // Do something. + Gateway response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_creategateway_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/SyncCreateGateway.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/SyncCreateGateway.java new file mode 100644 index 0000000..287211e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/SyncCreateGateway.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_creategateway_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.CreateGatewayRequest; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.LocationName; + +public class SyncCreateGateway { + + public static void main(String[] args) throws Exception { + syncCreateGateway(); + } + + public static void syncCreateGateway() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + CreateGatewayRequest request = + CreateGatewayRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setGatewayId("gatewayId-1354641793") + .setGateway(Gateway.newBuilder().build()) + .build(); + Gateway response = apiGatewayServiceClient.createGatewayAsync(request).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_creategateway_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/SyncCreateGatewayLocationnameGatewayString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/SyncCreateGatewayLocationnameGatewayString.java new file mode 100644 index 0000000..1cbccf8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/SyncCreateGatewayLocationnameGatewayString.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START +// apigateway_v1_generated_apigatewayserviceclient_creategateway_locationnamegatewaystring_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.LocationName; + +public class SyncCreateGatewayLocationnameGatewayString { + + public static void main(String[] args) throws Exception { + syncCreateGatewayLocationnameGatewayString(); + } + + public static void syncCreateGatewayLocationnameGatewayString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Gateway gateway = Gateway.newBuilder().build(); + String gatewayId = "gatewayId-1354641793"; + Gateway response = + apiGatewayServiceClient.createGatewayAsync(parent, gateway, gatewayId).get(); + } + } +} +// [END +// apigateway_v1_generated_apigatewayserviceclient_creategateway_locationnamegatewaystring_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/SyncCreateGatewayStringGatewayString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/SyncCreateGatewayStringGatewayString.java new file mode 100644 index 0000000..714b23d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/creategateway/SyncCreateGatewayStringGatewayString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_creategateway_stringgatewaystring_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.LocationName; + +public class SyncCreateGatewayStringGatewayString { + + public static void main(String[] args) throws Exception { + syncCreateGatewayStringGatewayString(); + } + + public static void syncCreateGatewayStringGatewayString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Gateway gateway = Gateway.newBuilder().build(); + String gatewayId = "gatewayId-1354641793"; + Gateway response = + apiGatewayServiceClient.createGatewayAsync(parent, gateway, gatewayId).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_creategateway_stringgatewaystring_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/AsyncDeleteApi.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/AsyncDeleteApi.java new file mode 100644 index 0000000..6dd8838 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/AsyncDeleteApi.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deleteapi_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; +import com.google.cloud.apigateway.v1.DeleteApiRequest; +import com.google.longrunning.Operation; + +public class AsyncDeleteApi { + + public static void main(String[] args) throws Exception { + asyncDeleteApi(); + } + + public static void asyncDeleteApi() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + DeleteApiRequest request = + DeleteApiRequest.newBuilder() + .setName(ApiName.of("[PROJECT]", "[API]").toString()) + .build(); + ApiFuture future = apiGatewayServiceClient.deleteApiCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deleteapi_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/AsyncDeleteApiLRO.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/AsyncDeleteApiLRO.java new file mode 100644 index 0000000..fc6ece9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/AsyncDeleteApiLRO.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deleteapi_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; +import com.google.cloud.apigateway.v1.DeleteApiRequest; +import com.google.cloud.apigateway.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteApiLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteApiLRO(); + } + + public static void asyncDeleteApiLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + DeleteApiRequest request = + DeleteApiRequest.newBuilder() + .setName(ApiName.of("[PROJECT]", "[API]").toString()) + .build(); + OperationFuture future = + apiGatewayServiceClient.deleteApiOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deleteapi_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/SyncDeleteApi.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/SyncDeleteApi.java new file mode 100644 index 0000000..24f0a1a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/SyncDeleteApi.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deleteapi_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; +import com.google.cloud.apigateway.v1.DeleteApiRequest; + +public class SyncDeleteApi { + + public static void main(String[] args) throws Exception { + syncDeleteApi(); + } + + public static void syncDeleteApi() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + DeleteApiRequest request = + DeleteApiRequest.newBuilder() + .setName(ApiName.of("[PROJECT]", "[API]").toString()) + .build(); + apiGatewayServiceClient.deleteApiAsync(request).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deleteapi_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/SyncDeleteApiApiname.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/SyncDeleteApiApiname.java new file mode 100644 index 0000000..f03e8c0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/SyncDeleteApiApiname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deleteapi_apiname_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; + +public class SyncDeleteApiApiname { + + public static void main(String[] args) throws Exception { + syncDeleteApiApiname(); + } + + public static void syncDeleteApiApiname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ApiName name = ApiName.of("[PROJECT]", "[API]"); + apiGatewayServiceClient.deleteApiAsync(name).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deleteapi_apiname_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/SyncDeleteApiString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/SyncDeleteApiString.java new file mode 100644 index 0000000..427c4ad --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapi/SyncDeleteApiString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deleteapi_string_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; + +public class SyncDeleteApiString { + + public static void main(String[] args) throws Exception { + syncDeleteApiString(); + } + + public static void syncDeleteApiString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + String name = ApiName.of("[PROJECT]", "[API]").toString(); + apiGatewayServiceClient.deleteApiAsync(name).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deleteapi_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/AsyncDeleteApiConfig.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/AsyncDeleteApiConfig.java new file mode 100644 index 0000000..ea1137f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/AsyncDeleteApiConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deleteapiconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.ApiConfigName; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.DeleteApiConfigRequest; +import com.google.longrunning.Operation; + +public class AsyncDeleteApiConfig { + + public static void main(String[] args) throws Exception { + asyncDeleteApiConfig(); + } + + public static void asyncDeleteApiConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + DeleteApiConfigRequest request = + DeleteApiConfigRequest.newBuilder() + .setName(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .build(); + ApiFuture future = + apiGatewayServiceClient.deleteApiConfigCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deleteapiconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/AsyncDeleteApiConfigLRO.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/AsyncDeleteApiConfigLRO.java new file mode 100644 index 0000000..978d358 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/AsyncDeleteApiConfigLRO.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deleteapiconfig_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.apigateway.v1.ApiConfigName; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.DeleteApiConfigRequest; +import com.google.cloud.apigateway.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteApiConfigLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteApiConfigLRO(); + } + + public static void asyncDeleteApiConfigLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + DeleteApiConfigRequest request = + DeleteApiConfigRequest.newBuilder() + .setName(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .build(); + OperationFuture future = + apiGatewayServiceClient.deleteApiConfigOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deleteapiconfig_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/SyncDeleteApiConfig.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/SyncDeleteApiConfig.java new file mode 100644 index 0000000..2295082 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/SyncDeleteApiConfig.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deleteapiconfig_sync] +import com.google.cloud.apigateway.v1.ApiConfigName; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.DeleteApiConfigRequest; + +public class SyncDeleteApiConfig { + + public static void main(String[] args) throws Exception { + syncDeleteApiConfig(); + } + + public static void syncDeleteApiConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + DeleteApiConfigRequest request = + DeleteApiConfigRequest.newBuilder() + .setName(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .build(); + apiGatewayServiceClient.deleteApiConfigAsync(request).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deleteapiconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/SyncDeleteApiConfigApiconfigname.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/SyncDeleteApiConfigApiconfigname.java new file mode 100644 index 0000000..56171c9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/SyncDeleteApiConfigApiconfigname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deleteapiconfig_apiconfigname_sync] +import com.google.cloud.apigateway.v1.ApiConfigName; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; + +public class SyncDeleteApiConfigApiconfigname { + + public static void main(String[] args) throws Exception { + syncDeleteApiConfigApiconfigname(); + } + + public static void syncDeleteApiConfigApiconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ApiConfigName name = ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]"); + apiGatewayServiceClient.deleteApiConfigAsync(name).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deleteapiconfig_apiconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/SyncDeleteApiConfigString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/SyncDeleteApiConfigString.java new file mode 100644 index 0000000..2512af8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deleteapiconfig/SyncDeleteApiConfigString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deleteapiconfig_string_sync] +import com.google.cloud.apigateway.v1.ApiConfigName; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; + +public class SyncDeleteApiConfigString { + + public static void main(String[] args) throws Exception { + syncDeleteApiConfigString(); + } + + public static void syncDeleteApiConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + String name = ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString(); + apiGatewayServiceClient.deleteApiConfigAsync(name).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deleteapiconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/AsyncDeleteGateway.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/AsyncDeleteGateway.java new file mode 100644 index 0000000..740c24e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/AsyncDeleteGateway.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deletegateway_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.DeleteGatewayRequest; +import com.google.cloud.apigateway.v1.GatewayName; +import com.google.longrunning.Operation; + +public class AsyncDeleteGateway { + + public static void main(String[] args) throws Exception { + asyncDeleteGateway(); + } + + public static void asyncDeleteGateway() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + DeleteGatewayRequest request = + DeleteGatewayRequest.newBuilder() + .setName(GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]").toString()) + .build(); + ApiFuture future = + apiGatewayServiceClient.deleteGatewayCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deletegateway_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/AsyncDeleteGatewayLRO.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/AsyncDeleteGatewayLRO.java new file mode 100644 index 0000000..06da356 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/AsyncDeleteGatewayLRO.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deletegateway_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.DeleteGatewayRequest; +import com.google.cloud.apigateway.v1.GatewayName; +import com.google.cloud.apigateway.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteGatewayLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteGatewayLRO(); + } + + public static void asyncDeleteGatewayLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + DeleteGatewayRequest request = + DeleteGatewayRequest.newBuilder() + .setName(GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]").toString()) + .build(); + OperationFuture future = + apiGatewayServiceClient.deleteGatewayOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deletegateway_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/SyncDeleteGateway.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/SyncDeleteGateway.java new file mode 100644 index 0000000..69ba645 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/SyncDeleteGateway.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deletegateway_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.DeleteGatewayRequest; +import com.google.cloud.apigateway.v1.GatewayName; + +public class SyncDeleteGateway { + + public static void main(String[] args) throws Exception { + syncDeleteGateway(); + } + + public static void syncDeleteGateway() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + DeleteGatewayRequest request = + DeleteGatewayRequest.newBuilder() + .setName(GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]").toString()) + .build(); + apiGatewayServiceClient.deleteGatewayAsync(request).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deletegateway_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/SyncDeleteGatewayGatewayname.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/SyncDeleteGatewayGatewayname.java new file mode 100644 index 0000000..317ae6e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/SyncDeleteGatewayGatewayname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deletegateway_gatewayname_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.GatewayName; + +public class SyncDeleteGatewayGatewayname { + + public static void main(String[] args) throws Exception { + syncDeleteGatewayGatewayname(); + } + + public static void syncDeleteGatewayGatewayname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + GatewayName name = GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]"); + apiGatewayServiceClient.deleteGatewayAsync(name).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deletegateway_gatewayname_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/SyncDeleteGatewayString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/SyncDeleteGatewayString.java new file mode 100644 index 0000000..b8b8baa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/deletegateway/SyncDeleteGatewayString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_deletegateway_string_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.GatewayName; + +public class SyncDeleteGatewayString { + + public static void main(String[] args) throws Exception { + syncDeleteGatewayString(); + } + + public static void syncDeleteGatewayString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + String name = GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]").toString(); + apiGatewayServiceClient.deleteGatewayAsync(name).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_deletegateway_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapi/AsyncGetApi.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapi/AsyncGetApi.java new file mode 100644 index 0000000..b58c2d5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapi/AsyncGetApi.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_getapi_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; +import com.google.cloud.apigateway.v1.GetApiRequest; + +public class AsyncGetApi { + + public static void main(String[] args) throws Exception { + asyncGetApi(); + } + + public static void asyncGetApi() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + GetApiRequest request = + GetApiRequest.newBuilder().setName(ApiName.of("[PROJECT]", "[API]").toString()).build(); + ApiFuture future = apiGatewayServiceClient.getApiCallable().futureCall(request); + // Do something. + Api response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_getapi_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapi/SyncGetApi.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapi/SyncGetApi.java new file mode 100644 index 0000000..d66bc69 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapi/SyncGetApi.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_getapi_sync] +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; +import com.google.cloud.apigateway.v1.GetApiRequest; + +public class SyncGetApi { + + public static void main(String[] args) throws Exception { + syncGetApi(); + } + + public static void syncGetApi() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + GetApiRequest request = + GetApiRequest.newBuilder().setName(ApiName.of("[PROJECT]", "[API]").toString()).build(); + Api response = apiGatewayServiceClient.getApi(request); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_getapi_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapi/SyncGetApiApiname.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapi/SyncGetApiApiname.java new file mode 100644 index 0000000..7170d30 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapi/SyncGetApiApiname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_getapi_apiname_sync] +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; + +public class SyncGetApiApiname { + + public static void main(String[] args) throws Exception { + syncGetApiApiname(); + } + + public static void syncGetApiApiname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ApiName name = ApiName.of("[PROJECT]", "[API]"); + Api response = apiGatewayServiceClient.getApi(name); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_getapi_apiname_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapi/SyncGetApiString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapi/SyncGetApiString.java new file mode 100644 index 0000000..6d9a33d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapi/SyncGetApiString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_getapi_string_sync] +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; + +public class SyncGetApiString { + + public static void main(String[] args) throws Exception { + syncGetApiString(); + } + + public static void syncGetApiString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + String name = ApiName.of("[PROJECT]", "[API]").toString(); + Api response = apiGatewayServiceClient.getApi(name); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_getapi_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapiconfig/AsyncGetApiConfig.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapiconfig/AsyncGetApiConfig.java new file mode 100644 index 0000000..72141aa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapiconfig/AsyncGetApiConfig.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_getapiconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiConfigName; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.GetApiConfigRequest; + +public class AsyncGetApiConfig { + + public static void main(String[] args) throws Exception { + asyncGetApiConfig(); + } + + public static void asyncGetApiConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + GetApiConfigRequest request = + GetApiConfigRequest.newBuilder() + .setName(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .build(); + ApiFuture future = + apiGatewayServiceClient.getApiConfigCallable().futureCall(request); + // Do something. + ApiConfig response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_getapiconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapiconfig/SyncGetApiConfig.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapiconfig/SyncGetApiConfig.java new file mode 100644 index 0000000..d6394e2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapiconfig/SyncGetApiConfig.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_getapiconfig_sync] +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiConfigName; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.GetApiConfigRequest; + +public class SyncGetApiConfig { + + public static void main(String[] args) throws Exception { + syncGetApiConfig(); + } + + public static void syncGetApiConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + GetApiConfigRequest request = + GetApiConfigRequest.newBuilder() + .setName(ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString()) + .build(); + ApiConfig response = apiGatewayServiceClient.getApiConfig(request); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_getapiconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapiconfig/SyncGetApiConfigApiconfigname.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapiconfig/SyncGetApiConfigApiconfigname.java new file mode 100644 index 0000000..dc6be06 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapiconfig/SyncGetApiConfigApiconfigname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_getapiconfig_apiconfigname_sync] +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiConfigName; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; + +public class SyncGetApiConfigApiconfigname { + + public static void main(String[] args) throws Exception { + syncGetApiConfigApiconfigname(); + } + + public static void syncGetApiConfigApiconfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ApiConfigName name = ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]"); + ApiConfig response = apiGatewayServiceClient.getApiConfig(name); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_getapiconfig_apiconfigname_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapiconfig/SyncGetApiConfigString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapiconfig/SyncGetApiConfigString.java new file mode 100644 index 0000000..25fb720 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getapiconfig/SyncGetApiConfigString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_getapiconfig_string_sync] +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiConfigName; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; + +public class SyncGetApiConfigString { + + public static void main(String[] args) throws Exception { + syncGetApiConfigString(); + } + + public static void syncGetApiConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + String name = ApiConfigName.of("[PROJECT]", "[API]", "[API_CONFIG]").toString(); + ApiConfig response = apiGatewayServiceClient.getApiConfig(name); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_getapiconfig_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getgateway/AsyncGetGateway.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getgateway/AsyncGetGateway.java new file mode 100644 index 0000000..e697983 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getgateway/AsyncGetGateway.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_getgateway_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.GatewayName; +import com.google.cloud.apigateway.v1.GetGatewayRequest; + +public class AsyncGetGateway { + + public static void main(String[] args) throws Exception { + asyncGetGateway(); + } + + public static void asyncGetGateway() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + GetGatewayRequest request = + GetGatewayRequest.newBuilder() + .setName(GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]").toString()) + .build(); + ApiFuture future = apiGatewayServiceClient.getGatewayCallable().futureCall(request); + // Do something. + Gateway response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_getgateway_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getgateway/SyncGetGateway.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getgateway/SyncGetGateway.java new file mode 100644 index 0000000..9569146 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getgateway/SyncGetGateway.java @@ -0,0 +1,43 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_getgateway_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.GatewayName; +import com.google.cloud.apigateway.v1.GetGatewayRequest; + +public class SyncGetGateway { + + public static void main(String[] args) throws Exception { + syncGetGateway(); + } + + public static void syncGetGateway() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + GetGatewayRequest request = + GetGatewayRequest.newBuilder() + .setName(GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]").toString()) + .build(); + Gateway response = apiGatewayServiceClient.getGateway(request); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_getgateway_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getgateway/SyncGetGatewayGatewayname.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getgateway/SyncGetGatewayGatewayname.java new file mode 100644 index 0000000..0ac2718 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getgateway/SyncGetGatewayGatewayname.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_getgateway_gatewayname_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.GatewayName; + +public class SyncGetGatewayGatewayname { + + public static void main(String[] args) throws Exception { + syncGetGatewayGatewayname(); + } + + public static void syncGetGatewayGatewayname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + GatewayName name = GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]"); + Gateway response = apiGatewayServiceClient.getGateway(name); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_getgateway_gatewayname_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getgateway/SyncGetGatewayString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getgateway/SyncGetGatewayString.java new file mode 100644 index 0000000..e27497f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/getgateway/SyncGetGatewayString.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_getgateway_string_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.GatewayName; + +public class SyncGetGatewayString { + + public static void main(String[] args) throws Exception { + syncGetGatewayString(); + } + + public static void syncGetGatewayString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + String name = GatewayName.of("[PROJECT]", "[LOCATION]", "[GATEWAY]").toString(); + Gateway response = apiGatewayServiceClient.getGateway(name); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_getgateway_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/AsyncListApiConfigs.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/AsyncListApiConfigs.java new file mode 100644 index 0000000..53b727b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/AsyncListApiConfigs.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listapiconfigs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; +import com.google.cloud.apigateway.v1.ListApiConfigsRequest; + +public class AsyncListApiConfigs { + + public static void main(String[] args) throws Exception { + asyncListApiConfigs(); + } + + public static void asyncListApiConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ListApiConfigsRequest request = + ListApiConfigsRequest.newBuilder() + .setParent(ApiName.of("[PROJECT]", "[API]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + apiGatewayServiceClient.listApiConfigsPagedCallable().futureCall(request); + // Do something. + for (ApiConfig element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listapiconfigs_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/AsyncListApiConfigsPaged.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/AsyncListApiConfigsPaged.java new file mode 100644 index 0000000..1433f04 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/AsyncListApiConfigsPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listapiconfigs_paged_async] +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; +import com.google.cloud.apigateway.v1.ListApiConfigsRequest; +import com.google.cloud.apigateway.v1.ListApiConfigsResponse; +import com.google.common.base.Strings; + +public class AsyncListApiConfigsPaged { + + public static void main(String[] args) throws Exception { + asyncListApiConfigsPaged(); + } + + public static void asyncListApiConfigsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ListApiConfigsRequest request = + ListApiConfigsRequest.newBuilder() + .setParent(ApiName.of("[PROJECT]", "[API]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListApiConfigsResponse response = + apiGatewayServiceClient.listApiConfigsCallable().call(request); + for (ApiConfig element : response.getApiConfigsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listapiconfigs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/SyncListApiConfigs.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/SyncListApiConfigs.java new file mode 100644 index 0000000..efe3287 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/SyncListApiConfigs.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listapiconfigs_sync] +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; +import com.google.cloud.apigateway.v1.ListApiConfigsRequest; + +public class SyncListApiConfigs { + + public static void main(String[] args) throws Exception { + syncListApiConfigs(); + } + + public static void syncListApiConfigs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ListApiConfigsRequest request = + ListApiConfigsRequest.newBuilder() + .setParent(ApiName.of("[PROJECT]", "[API]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (ApiConfig element : apiGatewayServiceClient.listApiConfigs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listapiconfigs_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/SyncListApiConfigsApiname.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/SyncListApiConfigsApiname.java new file mode 100644 index 0000000..fb2cd6a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/SyncListApiConfigsApiname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listapiconfigs_apiname_sync] +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; + +public class SyncListApiConfigsApiname { + + public static void main(String[] args) throws Exception { + syncListApiConfigsApiname(); + } + + public static void syncListApiConfigsApiname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ApiName parent = ApiName.of("[PROJECT]", "[API]"); + for (ApiConfig element : apiGatewayServiceClient.listApiConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listapiconfigs_apiname_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/SyncListApiConfigsString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/SyncListApiConfigsString.java new file mode 100644 index 0000000..2c81a78 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapiconfigs/SyncListApiConfigsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listapiconfigs_string_sync] +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ApiName; + +public class SyncListApiConfigsString { + + public static void main(String[] args) throws Exception { + syncListApiConfigsString(); + } + + public static void syncListApiConfigsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + String parent = ApiName.of("[PROJECT]", "[API]").toString(); + for (ApiConfig element : apiGatewayServiceClient.listApiConfigs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listapiconfigs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/AsyncListApis.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/AsyncListApis.java new file mode 100644 index 0000000..e53e755 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/AsyncListApis.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listapis_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ListApisRequest; +import com.google.cloud.apigateway.v1.LocationName; + +public class AsyncListApis { + + public static void main(String[] args) throws Exception { + asyncListApis(); + } + + public static void asyncListApis() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ListApisRequest request = + ListApisRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = apiGatewayServiceClient.listApisPagedCallable().futureCall(request); + // Do something. + for (Api element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listapis_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/AsyncListApisPaged.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/AsyncListApisPaged.java new file mode 100644 index 0000000..f04de9a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/AsyncListApisPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listapis_paged_async] +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ListApisRequest; +import com.google.cloud.apigateway.v1.ListApisResponse; +import com.google.cloud.apigateway.v1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListApisPaged { + + public static void main(String[] args) throws Exception { + asyncListApisPaged(); + } + + public static void asyncListApisPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ListApisRequest request = + ListApisRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListApisResponse response = apiGatewayServiceClient.listApisCallable().call(request); + for (Api element : response.getApisList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listapis_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/SyncListApis.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/SyncListApis.java new file mode 100644 index 0000000..3dff850 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/SyncListApis.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listapis_sync] +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.ListApisRequest; +import com.google.cloud.apigateway.v1.LocationName; + +public class SyncListApis { + + public static void main(String[] args) throws Exception { + syncListApis(); + } + + public static void syncListApis() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ListApisRequest request = + ListApisRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Api element : apiGatewayServiceClient.listApis(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listapis_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/SyncListApisLocationname.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/SyncListApisLocationname.java new file mode 100644 index 0000000..cc84f11 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/SyncListApisLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listapis_locationname_sync] +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.LocationName; + +public class SyncListApisLocationname { + + public static void main(String[] args) throws Exception { + syncListApisLocationname(); + } + + public static void syncListApisLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Api element : apiGatewayServiceClient.listApis(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listapis_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/SyncListApisString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/SyncListApisString.java new file mode 100644 index 0000000..29e3e59 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listapis/SyncListApisString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listapis_string_sync] +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.LocationName; + +public class SyncListApisString { + + public static void main(String[] args) throws Exception { + syncListApisString(); + } + + public static void syncListApisString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Api element : apiGatewayServiceClient.listApis(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listapis_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/AsyncListGateways.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/AsyncListGateways.java new file mode 100644 index 0000000..05e7a43 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/AsyncListGateways.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listgateways_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.ListGatewaysRequest; +import com.google.cloud.apigateway.v1.LocationName; + +public class AsyncListGateways { + + public static void main(String[] args) throws Exception { + asyncListGateways(); + } + + public static void asyncListGateways() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ListGatewaysRequest request = + ListGatewaysRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + apiGatewayServiceClient.listGatewaysPagedCallable().futureCall(request); + // Do something. + for (Gateway element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listgateways_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/AsyncListGatewaysPaged.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/AsyncListGatewaysPaged.java new file mode 100644 index 0000000..4731e2f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/AsyncListGatewaysPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listgateways_paged_async] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.ListGatewaysRequest; +import com.google.cloud.apigateway.v1.ListGatewaysResponse; +import com.google.cloud.apigateway.v1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListGatewaysPaged { + + public static void main(String[] args) throws Exception { + asyncListGatewaysPaged(); + } + + public static void asyncListGatewaysPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ListGatewaysRequest request = + ListGatewaysRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListGatewaysResponse response = + apiGatewayServiceClient.listGatewaysCallable().call(request); + for (Gateway element : response.getGatewaysList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listgateways_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/SyncListGateways.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/SyncListGateways.java new file mode 100644 index 0000000..78120ce --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/SyncListGateways.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listgateways_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.ListGatewaysRequest; +import com.google.cloud.apigateway.v1.LocationName; + +public class SyncListGateways { + + public static void main(String[] args) throws Exception { + syncListGateways(); + } + + public static void syncListGateways() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ListGatewaysRequest request = + ListGatewaysRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Gateway element : apiGatewayServiceClient.listGateways(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listgateways_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/SyncListGatewaysLocationname.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/SyncListGatewaysLocationname.java new file mode 100644 index 0000000..c12fb70 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/SyncListGatewaysLocationname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listgateways_locationname_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.LocationName; + +public class SyncListGatewaysLocationname { + + public static void main(String[] args) throws Exception { + syncListGatewaysLocationname(); + } + + public static void syncListGatewaysLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Gateway element : apiGatewayServiceClient.listGateways(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listgateways_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/SyncListGatewaysString.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/SyncListGatewaysString.java new file mode 100644 index 0000000..59336c2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/listgateways/SyncListGatewaysString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_listgateways_string_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.LocationName; + +public class SyncListGatewaysString { + + public static void main(String[] args) throws Exception { + syncListGatewaysString(); + } + + public static void syncListGatewaysString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Gateway element : apiGatewayServiceClient.listGateways(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_listgateways_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapi/AsyncUpdateApi.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapi/AsyncUpdateApi.java new file mode 100644 index 0000000..6af74fd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapi/AsyncUpdateApi.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_updateapi_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.UpdateApiRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateApi { + + public static void main(String[] args) throws Exception { + asyncUpdateApi(); + } + + public static void asyncUpdateApi() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + UpdateApiRequest request = + UpdateApiRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setApi(Api.newBuilder().build()) + .build(); + ApiFuture future = apiGatewayServiceClient.updateApiCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_updateapi_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapi/AsyncUpdateApiLRO.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapi/AsyncUpdateApiLRO.java new file mode 100644 index 0000000..c1caeb1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapi/AsyncUpdateApiLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_updateapi_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.OperationMetadata; +import com.google.cloud.apigateway.v1.UpdateApiRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateApiLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateApiLRO(); + } + + public static void asyncUpdateApiLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + UpdateApiRequest request = + UpdateApiRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setApi(Api.newBuilder().build()) + .build(); + OperationFuture future = + apiGatewayServiceClient.updateApiOperationCallable().futureCall(request); + // Do something. + Api response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_updateapi_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapi/SyncUpdateApi.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapi/SyncUpdateApi.java new file mode 100644 index 0000000..84916b1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapi/SyncUpdateApi.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_updateapi_sync] +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.UpdateApiRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateApi { + + public static void main(String[] args) throws Exception { + syncUpdateApi(); + } + + public static void syncUpdateApi() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + UpdateApiRequest request = + UpdateApiRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setApi(Api.newBuilder().build()) + .build(); + Api response = apiGatewayServiceClient.updateApiAsync(request).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_updateapi_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapi/SyncUpdateApiApiFieldmask.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapi/SyncUpdateApiApiFieldmask.java new file mode 100644 index 0000000..a225f4d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapi/SyncUpdateApiApiFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_updateapi_apifieldmask_sync] +import com.google.cloud.apigateway.v1.Api; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateApiApiFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateApiApiFieldmask(); + } + + public static void syncUpdateApiApiFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + Api api = Api.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Api response = apiGatewayServiceClient.updateApiAsync(api, updateMask).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_updateapi_apifieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapiconfig/AsyncUpdateApiConfig.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapiconfig/AsyncUpdateApiConfig.java new file mode 100644 index 0000000..01ba38f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapiconfig/AsyncUpdateApiConfig.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_updateapiconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.UpdateApiConfigRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateApiConfig { + + public static void main(String[] args) throws Exception { + asyncUpdateApiConfig(); + } + + public static void asyncUpdateApiConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + UpdateApiConfigRequest request = + UpdateApiConfigRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setApiConfig(ApiConfig.newBuilder().build()) + .build(); + ApiFuture future = + apiGatewayServiceClient.updateApiConfigCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_updateapiconfig_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapiconfig/AsyncUpdateApiConfigLRO.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapiconfig/AsyncUpdateApiConfigLRO.java new file mode 100644 index 0000000..0c4dd3c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapiconfig/AsyncUpdateApiConfigLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_updateapiconfig_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.OperationMetadata; +import com.google.cloud.apigateway.v1.UpdateApiConfigRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateApiConfigLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateApiConfigLRO(); + } + + public static void asyncUpdateApiConfigLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + UpdateApiConfigRequest request = + UpdateApiConfigRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setApiConfig(ApiConfig.newBuilder().build()) + .build(); + OperationFuture future = + apiGatewayServiceClient.updateApiConfigOperationCallable().futureCall(request); + // Do something. + ApiConfig response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_updateapiconfig_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapiconfig/SyncUpdateApiConfig.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapiconfig/SyncUpdateApiConfig.java new file mode 100644 index 0000000..27a9034 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapiconfig/SyncUpdateApiConfig.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_updateapiconfig_sync] +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.UpdateApiConfigRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateApiConfig { + + public static void main(String[] args) throws Exception { + syncUpdateApiConfig(); + } + + public static void syncUpdateApiConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + UpdateApiConfigRequest request = + UpdateApiConfigRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setApiConfig(ApiConfig.newBuilder().build()) + .build(); + ApiConfig response = apiGatewayServiceClient.updateApiConfigAsync(request).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_updateapiconfig_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapiconfig/SyncUpdateApiConfigApiconfigFieldmask.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapiconfig/SyncUpdateApiConfigApiconfigFieldmask.java new file mode 100644 index 0000000..5d2a6e6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updateapiconfig/SyncUpdateApiConfigApiconfigFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_updateapiconfig_apiconfigfieldmask_sync] +import com.google.cloud.apigateway.v1.ApiConfig; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateApiConfigApiconfigFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateApiConfigApiconfigFieldmask(); + } + + public static void syncUpdateApiConfigApiconfigFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + ApiConfig apiConfig = ApiConfig.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + ApiConfig response = + apiGatewayServiceClient.updateApiConfigAsync(apiConfig, updateMask).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_updateapiconfig_apiconfigfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updategateway/AsyncUpdateGateway.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updategateway/AsyncUpdateGateway.java new file mode 100644 index 0000000..51c68a5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updategateway/AsyncUpdateGateway.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_updategateway_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.UpdateGatewayRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateGateway { + + public static void main(String[] args) throws Exception { + asyncUpdateGateway(); + } + + public static void asyncUpdateGateway() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + UpdateGatewayRequest request = + UpdateGatewayRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setGateway(Gateway.newBuilder().build()) + .build(); + ApiFuture future = + apiGatewayServiceClient.updateGatewayCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_updategateway_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updategateway/AsyncUpdateGatewayLRO.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updategateway/AsyncUpdateGatewayLRO.java new file mode 100644 index 0000000..0ebf369 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updategateway/AsyncUpdateGatewayLRO.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_updategateway_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.OperationMetadata; +import com.google.cloud.apigateway.v1.UpdateGatewayRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateGatewayLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateGatewayLRO(); + } + + public static void asyncUpdateGatewayLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + UpdateGatewayRequest request = + UpdateGatewayRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setGateway(Gateway.newBuilder().build()) + .build(); + OperationFuture future = + apiGatewayServiceClient.updateGatewayOperationCallable().futureCall(request); + // Do something. + Gateway response = future.get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_updategateway_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updategateway/SyncUpdateGateway.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updategateway/SyncUpdateGateway.java new file mode 100644 index 0000000..78e12cb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updategateway/SyncUpdateGateway.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_updategateway_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.cloud.apigateway.v1.UpdateGatewayRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateGateway { + + public static void main(String[] args) throws Exception { + syncUpdateGateway(); + } + + public static void syncUpdateGateway() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + UpdateGatewayRequest request = + UpdateGatewayRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setGateway(Gateway.newBuilder().build()) + .build(); + Gateway response = apiGatewayServiceClient.updateGatewayAsync(request).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_updategateway_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updategateway/SyncUpdateGatewayGatewayFieldmask.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updategateway/SyncUpdateGatewayGatewayFieldmask.java new file mode 100644 index 0000000..d39ddf5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayserviceclient/updategateway/SyncUpdateGatewayGatewayFieldmask.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayserviceclient_updategateway_gatewayfieldmask_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceClient; +import com.google.cloud.apigateway.v1.Gateway; +import com.google.protobuf.FieldMask; + +public class SyncUpdateGatewayGatewayFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateGatewayGatewayFieldmask(); + } + + public static void syncUpdateGatewayGatewayFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ApiGatewayServiceClient apiGatewayServiceClient = ApiGatewayServiceClient.create()) { + Gateway gateway = Gateway.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Gateway response = apiGatewayServiceClient.updateGatewayAsync(gateway, updateMask).get(); + } + } +} +// [END apigateway_v1_generated_apigatewayserviceclient_updategateway_gatewayfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayservicesettings/getgateway/SyncGetGateway.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayservicesettings/getgateway/SyncGetGateway.java new file mode 100644 index 0000000..99a158e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/apigatewayservicesettings/getgateway/SyncGetGateway.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 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.apigateway.v1.samples; + +// [START apigateway_v1_generated_apigatewayservicesettings_getgateway_sync] +import com.google.cloud.apigateway.v1.ApiGatewayServiceSettings; +import java.time.Duration; + +public class SyncGetGateway { + + public static void main(String[] args) throws Exception { + syncGetGateway(); + } + + public static void syncGetGateway() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ApiGatewayServiceSettings.Builder apiGatewayServiceSettingsBuilder = + ApiGatewayServiceSettings.newBuilder(); + apiGatewayServiceSettingsBuilder + .getGatewaySettings() + .setRetrySettings( + apiGatewayServiceSettingsBuilder + .getGatewaySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ApiGatewayServiceSettings apiGatewayServiceSettings = apiGatewayServiceSettingsBuilder.build(); + } +} +// [END apigateway_v1_generated_apigatewayservicesettings_getgateway_sync] diff --git a/samples/snippets/generated/com/google/cloud/apigateway/v1/stub/apigatewayservicestubsettings/getgateway/SyncGetGateway.java b/samples/snippets/generated/com/google/cloud/apigateway/v1/stub/apigatewayservicestubsettings/getgateway/SyncGetGateway.java new file mode 100644 index 0000000..e5e3e13 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/apigateway/v1/stub/apigatewayservicestubsettings/getgateway/SyncGetGateway.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 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.apigateway.v1.stub.samples; + +// [START apigateway_v1_generated_apigatewayservicestubsettings_getgateway_sync] +import com.google.cloud.apigateway.v1.stub.ApiGatewayServiceStubSettings; +import java.time.Duration; + +public class SyncGetGateway { + + public static void main(String[] args) throws Exception { + syncGetGateway(); + } + + public static void syncGetGateway() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ApiGatewayServiceStubSettings.Builder apiGatewayServiceSettingsBuilder = + ApiGatewayServiceStubSettings.newBuilder(); + apiGatewayServiceSettingsBuilder + .getGatewaySettings() + .setRetrySettings( + apiGatewayServiceSettingsBuilder + .getGatewaySettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ApiGatewayServiceStubSettings apiGatewayServiceSettings = + apiGatewayServiceSettingsBuilder.build(); + } +} +// [END apigateway_v1_generated_apigatewayservicestubsettings_getgateway_sync]