diff --git a/java-deploy/google-cloud-deploy/pom.xml b/java-deploy/google-cloud-deploy/pom.xml index 37a56d42da2c..968b8ad068d4 100644 --- a/java-deploy/google-cloud-deploy/pom.xml +++ b/java-deploy/google-cloud-deploy/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/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/CloudDeployClient.java b/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/CloudDeployClient.java index 99cb92cc6c9a..a184d3813ef4 100644 --- a/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/CloudDeployClient.java +++ b/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/CloudDeployClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; 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; @@ -31,7 +32,6 @@ import com.google.cloud.deploy.v1.stub.CloudDeployStubSettings; 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,28 @@ * CloudDeployClient cloudDeployClient = CloudDeployClient.create(cloudDeploySettings); * } * + *

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.
+ * CloudDeploySettings cloudDeploySettings =
+ *     CloudDeploySettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CloudDeploySettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CloudDeployClient cloudDeployClient = CloudDeployClient.create(cloudDeploySettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class CloudDeployClient implements BackgroundResource { private final CloudDeploySettings settings; private final CloudDeployStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of CloudDeployClient with default settings. */ public static final CloudDeployClient create() throws IOException { @@ -130,7 +145,6 @@ public static final CloudDeployClient create(CloudDeploySettings settings) throw * Constructs an instance of CloudDeployClient, using the given stub for making calls. This is for * advanced usage - prefer using create(CloudDeploySettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final CloudDeployClient create(CloudDeployStub stub) { return new CloudDeployClient(stub); } @@ -143,21 +157,23 @@ public static final CloudDeployClient create(CloudDeployStub stub) { protected CloudDeployClient(CloudDeploySettings settings) throws IOException { this.settings = settings; this.stub = ((CloudDeployStubSettings) 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()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected CloudDeployClient(CloudDeployStub 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 CloudDeploySettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public CloudDeployStub getStub() { return stub; } @@ -166,10 +182,19 @@ public CloudDeployStub 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. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists DeliveryPipelines in a given project and location. @@ -314,7 +339,7 @@ public final ListDeliveryPipelinesPagedResponse listDeliveryPipelines( * while (true) { * ListDeliveryPipelinesResponse response = * cloudDeployClient.listDeliveryPipelinesCallable().call(request); - * for (DeliveryPipeline element : response.getResponsesList()) { + * for (DeliveryPipeline element : response.getDeliveryPipelinesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1020,7 +1045,7 @@ public final ListTargetsPagedResponse listTargets(ListTargetsRequest request) { * .build(); * while (true) { * ListTargetsResponse response = cloudDeployClient.listTargetsCallable().call(request); - * for (Target element : response.getResponsesList()) { + * for (Target element : response.getTargetsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1689,7 +1714,7 @@ public final ListReleasesPagedResponse listReleases(ListReleasesRequest request) * .build(); * while (true) { * ListReleasesResponse response = cloudDeployClient.listReleasesCallable().call(request); - * for (Release element : response.getResponsesList()) { + * for (Release element : response.getReleasesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2241,7 +2266,7 @@ public final ListRolloutsPagedResponse listRollouts(ListRolloutsRequest request) * .build(); * while (true) { * ListRolloutsResponse response = cloudDeployClient.listRolloutsCallable().call(request); - * for (Rollout element : response.getResponsesList()) { + * for (Rollout element : response.getRolloutsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/CloudDeploySettings.java b/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/CloudDeploySettings.java index 0463ade641f2..dc75aab6245d 100644 --- a/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/CloudDeploySettings.java +++ b/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/CloudDeploySettings.java @@ -26,6 +26,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; @@ -249,11 +250,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CloudDeployStubSettings.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 CloudDeployStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CloudDeployStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CloudDeployStubSettings.defaultTransportChannelProvider(); } @@ -263,11 +271,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CloudDeployStubSettings.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); @@ -305,6 +319,11 @@ private static Builder createDefault() { return new Builder(CloudDeployStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CloudDeployStubSettings.newHttpJsonBuilder()); + } + public CloudDeployStubSettings.Builder getStubSettingsBuilder() { return ((CloudDeployStubSettings.Builder) getStubSettings()); } diff --git a/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/CloudDeployStub.java b/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/CloudDeployStub.java index a708fabb24db..04291252e1dc 100644 --- a/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/CloudDeployStub.java +++ b/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/CloudDeployStub.java @@ -68,7 +68,11 @@ public abstract class CloudDeployStub 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 diff --git a/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/CloudDeployStubSettings.java b/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/CloudDeployStubSettings.java index b1a6f904f55a..5e4f799d4d14 100644 --- a/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/CloudDeployStubSettings.java +++ b/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/CloudDeployStubSettings.java @@ -31,6 +31,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; @@ -551,13 +554,17 @@ public UnaryCallSettings getConfigSettings() { return getConfigSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public CloudDeployStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCloudDeployStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCloudDeployStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -590,18 +597,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(CloudDeployStubSettings.class)) @@ -609,11 +623,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(CloudDeployStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CloudDeployStubSettings.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); @@ -880,6 +913,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 .listDeliveryPipelinesSettings() diff --git a/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/HttpJsonCloudDeployCallableFactory.java b/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/HttpJsonCloudDeployCallableFactory.java new file mode 100644 index 000000000000..b95d414b5b9b --- /dev/null +++ b/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/HttpJsonCloudDeployCallableFactory.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.deploy.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 CloudDeploy service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCloudDeployCallableFactory + 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/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/HttpJsonCloudDeployStub.java b/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/HttpJsonCloudDeployStub.java new file mode 100644 index 000000000000..40195165d07b --- /dev/null +++ b/java-deploy/google-cloud-deploy/src/main/java/com/google/cloud/deploy/v1/stub/HttpJsonCloudDeployStub.java @@ -0,0 +1,1340 @@ +/* + * 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.deploy.v1.stub; + +import static com.google.cloud.deploy.v1.CloudDeployClient.ListDeliveryPipelinesPagedResponse; +import static com.google.cloud.deploy.v1.CloudDeployClient.ListReleasesPagedResponse; +import static com.google.cloud.deploy.v1.CloudDeployClient.ListRolloutsPagedResponse; +import static com.google.cloud.deploy.v1.CloudDeployClient.ListTargetsPagedResponse; + +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.deploy.v1.ApproveRolloutRequest; +import com.google.cloud.deploy.v1.ApproveRolloutResponse; +import com.google.cloud.deploy.v1.Config; +import com.google.cloud.deploy.v1.CreateDeliveryPipelineRequest; +import com.google.cloud.deploy.v1.CreateReleaseRequest; +import com.google.cloud.deploy.v1.CreateRolloutRequest; +import com.google.cloud.deploy.v1.CreateTargetRequest; +import com.google.cloud.deploy.v1.DeleteDeliveryPipelineRequest; +import com.google.cloud.deploy.v1.DeleteTargetRequest; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.GetConfigRequest; +import com.google.cloud.deploy.v1.GetDeliveryPipelineRequest; +import com.google.cloud.deploy.v1.GetReleaseRequest; +import com.google.cloud.deploy.v1.GetRolloutRequest; +import com.google.cloud.deploy.v1.GetTargetRequest; +import com.google.cloud.deploy.v1.ListDeliveryPipelinesRequest; +import com.google.cloud.deploy.v1.ListDeliveryPipelinesResponse; +import com.google.cloud.deploy.v1.ListReleasesRequest; +import com.google.cloud.deploy.v1.ListReleasesResponse; +import com.google.cloud.deploy.v1.ListRolloutsRequest; +import com.google.cloud.deploy.v1.ListRolloutsResponse; +import com.google.cloud.deploy.v1.ListTargetsRequest; +import com.google.cloud.deploy.v1.ListTargetsResponse; +import com.google.cloud.deploy.v1.OperationMetadata; +import com.google.cloud.deploy.v1.Release; +import com.google.cloud.deploy.v1.Rollout; +import com.google.cloud.deploy.v1.Target; +import com.google.cloud.deploy.v1.UpdateDeliveryPipelineRequest; +import com.google.cloud.deploy.v1.UpdateTargetRequest; +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 CloudDeploy service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCloudDeployStub extends CloudDeployStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .add(Rollout.getDescriptor()) + .add(DeliveryPipeline.getDescriptor()) + .add(Target.getDescriptor()) + .add(Release.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor< + ListDeliveryPipelinesRequest, ListDeliveryPipelinesResponse> + listDeliveryPipelinesMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/ListDeliveryPipelines") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/deliveryPipelines", + 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(ListDeliveryPipelinesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getDeliveryPipelineMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/GetDeliveryPipeline") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/deliveryPipelines/*}", + 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(DeliveryPipeline.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createDeliveryPipelineMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/CreateDeliveryPipeline") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/deliveryPipelines", + 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, "deliveryPipelineId", request.getDeliveryPipelineId()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("deliveryPipeline", request.getDeliveryPipeline())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateDeliveryPipelineRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateDeliveryPipelineMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/UpdateDeliveryPipeline") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{deliveryPipeline.name=projects/*/locations/*/deliveryPipelines/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "deliveryPipeline.name", + request.getDeliveryPipeline().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "allowMissing", request.getAllowMissing()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("deliveryPipeline", request.getDeliveryPipeline())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateDeliveryPipelineRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteDeliveryPipelineMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/DeleteDeliveryPipeline") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/deliveryPipelines/*}", + 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, "allowMissing", request.getAllowMissing()); + serializer.putQueryParam(fields, "etag", request.getEtag()); + serializer.putQueryParam(fields, "force", request.getForce()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteDeliveryPipelineRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listTargetsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/ListTargets") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/targets", + 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(ListTargetsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getTargetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/GetTarget") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/targets/*}", + 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(Target.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createTargetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/CreateTarget") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/targets", + 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, "requestId", request.getRequestId()); + serializer.putQueryParam(fields, "targetId", request.getTargetId()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("target", request.getTarget())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateTargetRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateTargetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/UpdateTarget") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{target.name=projects/*/locations/*/targets/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "target.name", request.getTarget().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam( + fields, "allowMissing", request.getAllowMissing()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("target", request.getTarget())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateTargetRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteTargetMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/DeleteTarget") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/targets/*}", + 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, "allowMissing", request.getAllowMissing()); + serializer.putQueryParam(fields, "etag", request.getEtag()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteTargetRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listReleasesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/ListReleases") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/deliveryPipelines/*}/releases", + 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(ListReleasesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getReleaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/GetRelease") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/deliveryPipelines/*/releases/*}", + 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(Release.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createReleaseMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/CreateRelease") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/deliveryPipelines/*}/releases", + 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, "releaseId", request.getReleaseId()); + serializer.putQueryParam(fields, "requestId", request.getRequestId()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("release", request.getRelease())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateReleaseRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + approveRolloutMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/ApproveRollout") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/deliveryPipelines/*/releases/*/rollouts/*}:approve", + 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 -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ApproveRolloutResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listRolloutsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/ListRollouts") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/deliveryPipelines/*/releases/*}/rollouts", + 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(ListRolloutsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getRolloutMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/GetRollout") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/deliveryPipelines/*/releases/*/rollouts/*}", + 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(Rollout.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createRolloutMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/CreateRollout") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/deliveryPipelines/*/releases/*}/rollouts", + 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, "requestId", request.getRequestId()); + serializer.putQueryParam(fields, "rolloutId", request.getRolloutId()); + serializer.putQueryParam( + fields, "validateOnly", request.getValidateOnly()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("rollout", request.getRollout())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateRolloutRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor getConfigMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.deploy.v1.CloudDeploy/GetConfig") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/config}", + 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(Config.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + listDeliveryPipelinesCallable; + private final UnaryCallable + listDeliveryPipelinesPagedCallable; + private final UnaryCallable + getDeliveryPipelineCallable; + private final UnaryCallable + createDeliveryPipelineCallable; + private final OperationCallable< + CreateDeliveryPipelineRequest, DeliveryPipeline, OperationMetadata> + createDeliveryPipelineOperationCallable; + private final UnaryCallable + updateDeliveryPipelineCallable; + private final OperationCallable< + UpdateDeliveryPipelineRequest, DeliveryPipeline, OperationMetadata> + updateDeliveryPipelineOperationCallable; + private final UnaryCallable + deleteDeliveryPipelineCallable; + private final OperationCallable + deleteDeliveryPipelineOperationCallable; + private final UnaryCallable listTargetsCallable; + private final UnaryCallable + listTargetsPagedCallable; + private final UnaryCallable getTargetCallable; + private final UnaryCallable createTargetCallable; + private final OperationCallable + createTargetOperationCallable; + private final UnaryCallable updateTargetCallable; + private final OperationCallable + updateTargetOperationCallable; + private final UnaryCallable deleteTargetCallable; + private final OperationCallable + deleteTargetOperationCallable; + private final UnaryCallable listReleasesCallable; + private final UnaryCallable + listReleasesPagedCallable; + private final UnaryCallable getReleaseCallable; + private final UnaryCallable createReleaseCallable; + private final OperationCallable + createReleaseOperationCallable; + private final UnaryCallable approveRolloutCallable; + private final UnaryCallable listRolloutsCallable; + private final UnaryCallable + listRolloutsPagedCallable; + private final UnaryCallable getRolloutCallable; + private final UnaryCallable createRolloutCallable; + private final OperationCallable + createRolloutOperationCallable; + private final UnaryCallable getConfigCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCloudDeployStub create(CloudDeployStubSettings settings) + throws IOException { + return new HttpJsonCloudDeployStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCloudDeployStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCloudDeployStub( + CloudDeployStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCloudDeployStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCloudDeployStub( + CloudDeployStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCloudDeployStub, 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 HttpJsonCloudDeployStub(CloudDeployStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonCloudDeployCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCloudDeployStub, 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 HttpJsonCloudDeployStub( + CloudDeployStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listDeliveryPipelinesTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listDeliveryPipelinesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getDeliveryPipelineTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getDeliveryPipelineMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createDeliveryPipelineTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createDeliveryPipelineMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateDeliveryPipelineTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateDeliveryPipelineMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteDeliveryPipelineTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteDeliveryPipelineMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listTargetsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listTargetsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getTargetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getTargetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createTargetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createTargetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateTargetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateTargetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteTargetTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteTargetMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listReleasesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listReleasesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getReleaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getReleaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createReleaseTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createReleaseMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + approveRolloutTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(approveRolloutMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listRolloutsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listRolloutsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getRolloutTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getRolloutMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createRolloutTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createRolloutMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getConfigTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getConfigMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listDeliveryPipelinesCallable = + callableFactory.createUnaryCallable( + listDeliveryPipelinesTransportSettings, + settings.listDeliveryPipelinesSettings(), + clientContext); + this.listDeliveryPipelinesPagedCallable = + callableFactory.createPagedCallable( + listDeliveryPipelinesTransportSettings, + settings.listDeliveryPipelinesSettings(), + clientContext); + this.getDeliveryPipelineCallable = + callableFactory.createUnaryCallable( + getDeliveryPipelineTransportSettings, + settings.getDeliveryPipelineSettings(), + clientContext); + this.createDeliveryPipelineCallable = + callableFactory.createUnaryCallable( + createDeliveryPipelineTransportSettings, + settings.createDeliveryPipelineSettings(), + clientContext); + this.createDeliveryPipelineOperationCallable = + callableFactory.createOperationCallable( + createDeliveryPipelineTransportSettings, + settings.createDeliveryPipelineOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateDeliveryPipelineCallable = + callableFactory.createUnaryCallable( + updateDeliveryPipelineTransportSettings, + settings.updateDeliveryPipelineSettings(), + clientContext); + this.updateDeliveryPipelineOperationCallable = + callableFactory.createOperationCallable( + updateDeliveryPipelineTransportSettings, + settings.updateDeliveryPipelineOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteDeliveryPipelineCallable = + callableFactory.createUnaryCallable( + deleteDeliveryPipelineTransportSettings, + settings.deleteDeliveryPipelineSettings(), + clientContext); + this.deleteDeliveryPipelineOperationCallable = + callableFactory.createOperationCallable( + deleteDeliveryPipelineTransportSettings, + settings.deleteDeliveryPipelineOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listTargetsCallable = + callableFactory.createUnaryCallable( + listTargetsTransportSettings, settings.listTargetsSettings(), clientContext); + this.listTargetsPagedCallable = + callableFactory.createPagedCallable( + listTargetsTransportSettings, settings.listTargetsSettings(), clientContext); + this.getTargetCallable = + callableFactory.createUnaryCallable( + getTargetTransportSettings, settings.getTargetSettings(), clientContext); + this.createTargetCallable = + callableFactory.createUnaryCallable( + createTargetTransportSettings, settings.createTargetSettings(), clientContext); + this.createTargetOperationCallable = + callableFactory.createOperationCallable( + createTargetTransportSettings, + settings.createTargetOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateTargetCallable = + callableFactory.createUnaryCallable( + updateTargetTransportSettings, settings.updateTargetSettings(), clientContext); + this.updateTargetOperationCallable = + callableFactory.createOperationCallable( + updateTargetTransportSettings, + settings.updateTargetOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteTargetCallable = + callableFactory.createUnaryCallable( + deleteTargetTransportSettings, settings.deleteTargetSettings(), clientContext); + this.deleteTargetOperationCallable = + callableFactory.createOperationCallable( + deleteTargetTransportSettings, + settings.deleteTargetOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listReleasesCallable = + callableFactory.createUnaryCallable( + listReleasesTransportSettings, settings.listReleasesSettings(), clientContext); + this.listReleasesPagedCallable = + callableFactory.createPagedCallable( + listReleasesTransportSettings, settings.listReleasesSettings(), clientContext); + this.getReleaseCallable = + callableFactory.createUnaryCallable( + getReleaseTransportSettings, settings.getReleaseSettings(), clientContext); + this.createReleaseCallable = + callableFactory.createUnaryCallable( + createReleaseTransportSettings, settings.createReleaseSettings(), clientContext); + this.createReleaseOperationCallable = + callableFactory.createOperationCallable( + createReleaseTransportSettings, + settings.createReleaseOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.approveRolloutCallable = + callableFactory.createUnaryCallable( + approveRolloutTransportSettings, settings.approveRolloutSettings(), clientContext); + this.listRolloutsCallable = + callableFactory.createUnaryCallable( + listRolloutsTransportSettings, settings.listRolloutsSettings(), clientContext); + this.listRolloutsPagedCallable = + callableFactory.createPagedCallable( + listRolloutsTransportSettings, settings.listRolloutsSettings(), clientContext); + this.getRolloutCallable = + callableFactory.createUnaryCallable( + getRolloutTransportSettings, settings.getRolloutSettings(), clientContext); + this.createRolloutCallable = + callableFactory.createUnaryCallable( + createRolloutTransportSettings, settings.createRolloutSettings(), clientContext); + this.createRolloutOperationCallable = + callableFactory.createOperationCallable( + createRolloutTransportSettings, + settings.createRolloutOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getConfigCallable = + callableFactory.createUnaryCallable( + getConfigTransportSettings, settings.getConfigSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listDeliveryPipelinesMethodDescriptor); + methodDescriptors.add(getDeliveryPipelineMethodDescriptor); + methodDescriptors.add(createDeliveryPipelineMethodDescriptor); + methodDescriptors.add(updateDeliveryPipelineMethodDescriptor); + methodDescriptors.add(deleteDeliveryPipelineMethodDescriptor); + methodDescriptors.add(listTargetsMethodDescriptor); + methodDescriptors.add(getTargetMethodDescriptor); + methodDescriptors.add(createTargetMethodDescriptor); + methodDescriptors.add(updateTargetMethodDescriptor); + methodDescriptors.add(deleteTargetMethodDescriptor); + methodDescriptors.add(listReleasesMethodDescriptor); + methodDescriptors.add(getReleaseMethodDescriptor); + methodDescriptors.add(createReleaseMethodDescriptor); + methodDescriptors.add(approveRolloutMethodDescriptor); + methodDescriptors.add(listRolloutsMethodDescriptor); + methodDescriptors.add(getRolloutMethodDescriptor); + methodDescriptors.add(createRolloutMethodDescriptor); + methodDescriptors.add(getConfigMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + listDeliveryPipelinesCallable() { + return listDeliveryPipelinesCallable; + } + + @Override + public UnaryCallable + listDeliveryPipelinesPagedCallable() { + return listDeliveryPipelinesPagedCallable; + } + + @Override + public UnaryCallable getDeliveryPipelineCallable() { + return getDeliveryPipelineCallable; + } + + @Override + public UnaryCallable createDeliveryPipelineCallable() { + return createDeliveryPipelineCallable; + } + + @Override + public OperationCallable + createDeliveryPipelineOperationCallable() { + return createDeliveryPipelineOperationCallable; + } + + @Override + public UnaryCallable updateDeliveryPipelineCallable() { + return updateDeliveryPipelineCallable; + } + + @Override + public OperationCallable + updateDeliveryPipelineOperationCallable() { + return updateDeliveryPipelineOperationCallable; + } + + @Override + public UnaryCallable deleteDeliveryPipelineCallable() { + return deleteDeliveryPipelineCallable; + } + + @Override + public OperationCallable + deleteDeliveryPipelineOperationCallable() { + return deleteDeliveryPipelineOperationCallable; + } + + @Override + public UnaryCallable listTargetsCallable() { + return listTargetsCallable; + } + + @Override + public UnaryCallable listTargetsPagedCallable() { + return listTargetsPagedCallable; + } + + @Override + public UnaryCallable getTargetCallable() { + return getTargetCallable; + } + + @Override + public UnaryCallable createTargetCallable() { + return createTargetCallable; + } + + @Override + public OperationCallable + createTargetOperationCallable() { + return createTargetOperationCallable; + } + + @Override + public UnaryCallable updateTargetCallable() { + return updateTargetCallable; + } + + @Override + public OperationCallable + updateTargetOperationCallable() { + return updateTargetOperationCallable; + } + + @Override + public UnaryCallable deleteTargetCallable() { + return deleteTargetCallable; + } + + @Override + public OperationCallable + deleteTargetOperationCallable() { + return deleteTargetOperationCallable; + } + + @Override + public UnaryCallable listReleasesCallable() { + return listReleasesCallable; + } + + @Override + public UnaryCallable listReleasesPagedCallable() { + return listReleasesPagedCallable; + } + + @Override + public UnaryCallable getReleaseCallable() { + return getReleaseCallable; + } + + @Override + public UnaryCallable createReleaseCallable() { + return createReleaseCallable; + } + + @Override + public OperationCallable + createReleaseOperationCallable() { + return createReleaseOperationCallable; + } + + @Override + public UnaryCallable approveRolloutCallable() { + return approveRolloutCallable; + } + + @Override + public UnaryCallable listRolloutsCallable() { + return listRolloutsCallable; + } + + @Override + public UnaryCallable listRolloutsPagedCallable() { + return listRolloutsPagedCallable; + } + + @Override + public UnaryCallable getRolloutCallable() { + return getRolloutCallable; + } + + @Override + public UnaryCallable createRolloutCallable() { + return createRolloutCallable; + } + + @Override + public OperationCallable + createRolloutOperationCallable() { + return createRolloutOperationCallable; + } + + @Override + public UnaryCallable getConfigCallable() { + return getConfigCallable; + } + + @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/java-deploy/google-cloud-deploy/src/test/java/com/google/cloud/deploy/v1/CloudDeployClientHttpJsonTest.java b/java-deploy/google-cloud-deploy/src/test/java/com/google/cloud/deploy/v1/CloudDeployClientHttpJsonTest.java new file mode 100644 index 000000000000..74dd5e3d5387 --- /dev/null +++ b/java-deploy/google-cloud-deploy/src/test/java/com/google/cloud/deploy/v1/CloudDeployClientHttpJsonTest.java @@ -0,0 +1,2049 @@ +/* + * 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.deploy.v1; + +import static com.google.cloud.deploy.v1.CloudDeployClient.ListDeliveryPipelinesPagedResponse; +import static com.google.cloud.deploy.v1.CloudDeployClient.ListReleasesPagedResponse; +import static com.google.cloud.deploy.v1.CloudDeployClient.ListRolloutsPagedResponse; +import static com.google.cloud.deploy.v1.CloudDeployClient.ListTargetsPagedResponse; + +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.deploy.v1.stub.HttpJsonCloudDeployStub; +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 CloudDeployClientHttpJsonTest { + private static MockHttpService mockService; + private static CloudDeployClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCloudDeployStub.getMethodDescriptors(), + CloudDeploySettings.getDefaultEndpoint()); + CloudDeploySettings settings = + CloudDeploySettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CloudDeploySettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CloudDeployClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listDeliveryPipelinesTest() throws Exception { + DeliveryPipeline responsesElement = DeliveryPipeline.newBuilder().build(); + ListDeliveryPipelinesResponse expectedResponse = + ListDeliveryPipelinesResponse.newBuilder() + .setNextPageToken("") + .addAllDeliveryPipelines(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListDeliveryPipelinesPagedResponse pagedListResponse = client.listDeliveryPipelines(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDeliveryPipelinesList().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 listDeliveryPipelinesExceptionTest() 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.listDeliveryPipelines(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listDeliveryPipelinesTest2() throws Exception { + DeliveryPipeline responsesElement = DeliveryPipeline.newBuilder().build(); + ListDeliveryPipelinesResponse expectedResponse = + ListDeliveryPipelinesResponse.newBuilder() + .setNextPageToken("") + .addAllDeliveryPipelines(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListDeliveryPipelinesPagedResponse pagedListResponse = client.listDeliveryPipelines(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getDeliveryPipelinesList().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 listDeliveryPipelinesExceptionTest2() 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.listDeliveryPipelines(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDeliveryPipelineTest() throws Exception { + DeliveryPipeline expectedResponse = + DeliveryPipeline.newBuilder() + .setName( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setCondition(PipelineCondition.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + DeliveryPipelineName name = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]"); + + DeliveryPipeline actualResponse = client.getDeliveryPipeline(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 getDeliveryPipelineExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeliveryPipelineName name = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]"); + client.getDeliveryPipeline(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getDeliveryPipelineTest2() throws Exception { + DeliveryPipeline expectedResponse = + DeliveryPipeline.newBuilder() + .setName( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setCondition(PipelineCondition.newBuilder().build()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-2531/locations/location-2531/deliveryPipelines/deliveryPipeline-2531"; + + DeliveryPipeline actualResponse = client.getDeliveryPipeline(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 getDeliveryPipelineExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-2531/locations/location-2531/deliveryPipelines/deliveryPipeline-2531"; + client.getDeliveryPipeline(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createDeliveryPipelineTest() throws Exception { + DeliveryPipeline expectedResponse = + DeliveryPipeline.newBuilder() + .setName( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setCondition(PipelineCondition.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createDeliveryPipelineTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + DeliveryPipeline deliveryPipeline = DeliveryPipeline.newBuilder().build(); + String deliveryPipelineId = "deliveryPipelineId-632411535"; + + DeliveryPipeline actualResponse = + client.createDeliveryPipelineAsync(parent, deliveryPipeline, deliveryPipelineId).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 createDeliveryPipelineExceptionTest() 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]"); + DeliveryPipeline deliveryPipeline = DeliveryPipeline.newBuilder().build(); + String deliveryPipelineId = "deliveryPipelineId-632411535"; + client.createDeliveryPipelineAsync(parent, deliveryPipeline, deliveryPipelineId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createDeliveryPipelineTest2() throws Exception { + DeliveryPipeline expectedResponse = + DeliveryPipeline.newBuilder() + .setName( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setCondition(PipelineCondition.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createDeliveryPipelineTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + DeliveryPipeline deliveryPipeline = DeliveryPipeline.newBuilder().build(); + String deliveryPipelineId = "deliveryPipelineId-632411535"; + + DeliveryPipeline actualResponse = + client.createDeliveryPipelineAsync(parent, deliveryPipeline, deliveryPipelineId).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 createDeliveryPipelineExceptionTest2() 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"; + DeliveryPipeline deliveryPipeline = DeliveryPipeline.newBuilder().build(); + String deliveryPipelineId = "deliveryPipelineId-632411535"; + client.createDeliveryPipelineAsync(parent, deliveryPipeline, deliveryPipelineId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateDeliveryPipelineTest() throws Exception { + DeliveryPipeline expectedResponse = + DeliveryPipeline.newBuilder() + .setName( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setCondition(PipelineCondition.newBuilder().build()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateDeliveryPipelineTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DeliveryPipeline deliveryPipeline = + DeliveryPipeline.newBuilder() + .setName( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setCondition(PipelineCondition.newBuilder().build()) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + DeliveryPipeline actualResponse = + client.updateDeliveryPipelineAsync(deliveryPipeline, 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 updateDeliveryPipelineExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeliveryPipeline deliveryPipeline = + DeliveryPipeline.newBuilder() + .setName( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setCondition(PipelineCondition.newBuilder().build()) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateDeliveryPipelineAsync(deliveryPipeline, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteDeliveryPipelineTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDeliveryPipelineTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DeliveryPipelineName name = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]"); + + client.deleteDeliveryPipelineAsync(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 deleteDeliveryPipelineExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeliveryPipelineName name = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]"); + client.deleteDeliveryPipelineAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteDeliveryPipelineTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteDeliveryPipelineTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = + "projects/project-2531/locations/location-2531/deliveryPipelines/deliveryPipeline-2531"; + + client.deleteDeliveryPipelineAsync(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 deleteDeliveryPipelineExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-2531/locations/location-2531/deliveryPipelines/deliveryPipeline-2531"; + client.deleteDeliveryPipelineAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listTargetsTest() throws Exception { + Target responsesElement = Target.newBuilder().build(); + ListTargetsResponse expectedResponse = + ListTargetsResponse.newBuilder() + .setNextPageToken("") + .addAllTargets(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListTargetsPagedResponse pagedListResponse = client.listTargets(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTargetsList().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 listTargetsExceptionTest() 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.listTargets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listTargetsTest2() throws Exception { + Target responsesElement = Target.newBuilder().build(); + ListTargetsResponse expectedResponse = + ListTargetsResponse.newBuilder() + .setNextPageToken("") + .addAllTargets(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListTargetsPagedResponse pagedListResponse = client.listTargets(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getTargetsList().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 listTargetsExceptionTest2() 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.listTargets(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getTargetTest() throws Exception { + Target expectedResponse = + Target.newBuilder() + .setName(TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]").toString()) + .setTargetId("targetId-441951604") + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setRequireApproval(true) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .addAllExecutionConfigs(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + TargetName name = TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]"); + + Target actualResponse = client.getTarget(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 getTargetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TargetName name = TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]"); + client.getTarget(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getTargetTest2() throws Exception { + Target expectedResponse = + Target.newBuilder() + .setName(TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]").toString()) + .setTargetId("targetId-441951604") + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setRequireApproval(true) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .addAllExecutionConfigs(new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-8104/locations/location-8104/targets/target-8104"; + + Target actualResponse = client.getTarget(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 getTargetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-8104/locations/location-8104/targets/target-8104"; + client.getTarget(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createTargetTest() throws Exception { + Target expectedResponse = + Target.newBuilder() + .setName(TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]").toString()) + .setTargetId("targetId-441951604") + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setRequireApproval(true) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .addAllExecutionConfigs(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createTargetTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Target target = Target.newBuilder().build(); + String targetId = "targetId-441951604"; + + Target actualResponse = client.createTargetAsync(parent, target, targetId).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 createTargetExceptionTest() 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]"); + Target target = Target.newBuilder().build(); + String targetId = "targetId-441951604"; + client.createTargetAsync(parent, target, targetId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createTargetTest2() throws Exception { + Target expectedResponse = + Target.newBuilder() + .setName(TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]").toString()) + .setTargetId("targetId-441951604") + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setRequireApproval(true) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .addAllExecutionConfigs(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createTargetTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Target target = Target.newBuilder().build(); + String targetId = "targetId-441951604"; + + Target actualResponse = client.createTargetAsync(parent, target, targetId).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 createTargetExceptionTest2() 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"; + Target target = Target.newBuilder().build(); + String targetId = "targetId-441951604"; + client.createTargetAsync(parent, target, targetId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateTargetTest() throws Exception { + Target expectedResponse = + Target.newBuilder() + .setName(TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]").toString()) + .setTargetId("targetId-441951604") + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setRequireApproval(true) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .addAllExecutionConfigs(new ArrayList()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateTargetTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Target target = + Target.newBuilder() + .setName(TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]").toString()) + .setTargetId("targetId-441951604") + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setRequireApproval(true) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .addAllExecutionConfigs(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Target actualResponse = client.updateTargetAsync(target, 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 updateTargetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Target target = + Target.newBuilder() + .setName(TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]").toString()) + .setTargetId("targetId-441951604") + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setRequireApproval(true) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .addAllExecutionConfigs(new ArrayList()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateTargetAsync(target, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteTargetTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteTargetTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + TargetName name = TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]"); + + client.deleteTargetAsync(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 deleteTargetExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + TargetName name = TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]"); + client.deleteTargetAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteTargetTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteTargetTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-8104/locations/location-8104/targets/target-8104"; + + client.deleteTargetAsync(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 deleteTargetExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-8104/locations/location-8104/targets/target-8104"; + client.deleteTargetAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listReleasesTest() throws Exception { + Release responsesElement = Release.newBuilder().build(); + ListReleasesResponse expectedResponse = + ListReleasesResponse.newBuilder() + .setNextPageToken("") + .addAllReleases(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + DeliveryPipelineName parent = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]"); + + ListReleasesPagedResponse pagedListResponse = client.listReleases(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getReleasesList().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 listReleasesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeliveryPipelineName parent = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]"); + client.listReleases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listReleasesTest2() throws Exception { + Release responsesElement = Release.newBuilder().build(); + ListReleasesResponse expectedResponse = + ListReleasesResponse.newBuilder() + .setNextPageToken("") + .addAllReleases(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-5586/locations/location-5586/deliveryPipelines/deliveryPipeline-5586"; + + ListReleasesPagedResponse pagedListResponse = client.listReleases(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getReleasesList().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 listReleasesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-5586/locations/location-5586/deliveryPipelines/deliveryPipeline-5586"; + client.listReleases(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getReleaseTest() throws Exception { + Release expectedResponse = + Release.newBuilder() + .setName( + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setRenderStartTime(Timestamp.newBuilder().build()) + .setRenderEndTime(Timestamp.newBuilder().build()) + .setSkaffoldConfigUri("skaffoldConfigUri1907228268") + .setSkaffoldConfigPath("skaffoldConfigPath-1005630683") + .addAllBuildArtifacts(new ArrayList()) + .setDeliveryPipelineSnapshot(DeliveryPipeline.newBuilder().build()) + .addAllTargetSnapshots(new ArrayList()) + .setEtag("etag3123477") + .setSkaffoldVersion("skaffoldVersion229290234") + .putAllTargetArtifacts(new HashMap()) + .putAllTargetRenders(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + ReleaseName name = + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]"); + + Release actualResponse = client.getRelease(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 getReleaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReleaseName name = + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]"); + client.getRelease(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getReleaseTest2() throws Exception { + Release expectedResponse = + Release.newBuilder() + .setName( + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setRenderStartTime(Timestamp.newBuilder().build()) + .setRenderEndTime(Timestamp.newBuilder().build()) + .setSkaffoldConfigUri("skaffoldConfigUri1907228268") + .setSkaffoldConfigPath("skaffoldConfigPath-1005630683") + .addAllBuildArtifacts(new ArrayList()) + .setDeliveryPipelineSnapshot(DeliveryPipeline.newBuilder().build()) + .addAllTargetSnapshots(new ArrayList()) + .setEtag("etag3123477") + .setSkaffoldVersion("skaffoldVersion229290234") + .putAllTargetArtifacts(new HashMap()) + .putAllTargetRenders(new HashMap()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-835/locations/location-835/deliveryPipelines/deliveryPipeline-835/releases/release-835"; + + Release actualResponse = client.getRelease(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 getReleaseExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-835/locations/location-835/deliveryPipelines/deliveryPipeline-835/releases/release-835"; + client.getRelease(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createReleaseTest() throws Exception { + Release expectedResponse = + Release.newBuilder() + .setName( + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setRenderStartTime(Timestamp.newBuilder().build()) + .setRenderEndTime(Timestamp.newBuilder().build()) + .setSkaffoldConfigUri("skaffoldConfigUri1907228268") + .setSkaffoldConfigPath("skaffoldConfigPath-1005630683") + .addAllBuildArtifacts(new ArrayList()) + .setDeliveryPipelineSnapshot(DeliveryPipeline.newBuilder().build()) + .addAllTargetSnapshots(new ArrayList()) + .setEtag("etag3123477") + .setSkaffoldVersion("skaffoldVersion229290234") + .putAllTargetArtifacts(new HashMap()) + .putAllTargetRenders(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createReleaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DeliveryPipelineName parent = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]"); + Release release = Release.newBuilder().build(); + String releaseId = "releaseId89607042"; + + Release actualResponse = client.createReleaseAsync(parent, release, releaseId).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 createReleaseExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeliveryPipelineName parent = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]"); + Release release = Release.newBuilder().build(); + String releaseId = "releaseId89607042"; + client.createReleaseAsync(parent, release, releaseId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createReleaseTest2() throws Exception { + Release expectedResponse = + Release.newBuilder() + .setName( + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setRenderStartTime(Timestamp.newBuilder().build()) + .setRenderEndTime(Timestamp.newBuilder().build()) + .setSkaffoldConfigUri("skaffoldConfigUri1907228268") + .setSkaffoldConfigPath("skaffoldConfigPath-1005630683") + .addAllBuildArtifacts(new ArrayList()) + .setDeliveryPipelineSnapshot(DeliveryPipeline.newBuilder().build()) + .addAllTargetSnapshots(new ArrayList()) + .setEtag("etag3123477") + .setSkaffoldVersion("skaffoldVersion229290234") + .putAllTargetArtifacts(new HashMap()) + .putAllTargetRenders(new HashMap()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createReleaseTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = + "projects/project-5586/locations/location-5586/deliveryPipelines/deliveryPipeline-5586"; + Release release = Release.newBuilder().build(); + String releaseId = "releaseId89607042"; + + Release actualResponse = client.createReleaseAsync(parent, release, releaseId).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 createReleaseExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-5586/locations/location-5586/deliveryPipelines/deliveryPipeline-5586"; + Release release = Release.newBuilder().build(); + String releaseId = "releaseId89607042"; + client.createReleaseAsync(parent, release, releaseId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void approveRolloutTest() throws Exception { + ApproveRolloutResponse expectedResponse = ApproveRolloutResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + RolloutName name = + RolloutName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]", "[ROLLOUT]"); + + ApproveRolloutResponse actualResponse = client.approveRollout(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 approveRolloutExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RolloutName name = + RolloutName.of( + "[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]", "[ROLLOUT]"); + client.approveRollout(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void approveRolloutTest2() throws Exception { + ApproveRolloutResponse expectedResponse = ApproveRolloutResponse.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-2057/locations/location-2057/deliveryPipelines/deliveryPipeline-2057/releases/release-2057/rollouts/rollout-2057"; + + ApproveRolloutResponse actualResponse = client.approveRollout(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 approveRolloutExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-2057/locations/location-2057/deliveryPipelines/deliveryPipeline-2057/releases/release-2057/rollouts/rollout-2057"; + client.approveRollout(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listRolloutsTest() throws Exception { + Rollout responsesElement = Rollout.newBuilder().build(); + ListRolloutsResponse expectedResponse = + ListRolloutsResponse.newBuilder() + .setNextPageToken("") + .addAllRollouts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ReleaseName parent = + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]"); + + ListRolloutsPagedResponse pagedListResponse = client.listRollouts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRolloutsList().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 listRolloutsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReleaseName parent = + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]"); + client.listRollouts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listRolloutsTest2() throws Exception { + Rollout responsesElement = Rollout.newBuilder().build(); + ListRolloutsResponse expectedResponse = + ListRolloutsResponse.newBuilder() + .setNextPageToken("") + .addAllRollouts(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-2532/locations/location-2532/deliveryPipelines/deliveryPipeline-2532/releases/release-2532"; + + ListRolloutsPagedResponse pagedListResponse = client.listRollouts(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRolloutsList().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 listRolloutsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-2532/locations/location-2532/deliveryPipelines/deliveryPipeline-2532/releases/release-2532"; + client.listRollouts(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getRolloutTest() throws Exception { + Rollout expectedResponse = + Rollout.newBuilder() + .setName( + RolloutName.of( + "[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]", "[ROLLOUT]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setApproveTime(Timestamp.newBuilder().build()) + .setEnqueueTime(Timestamp.newBuilder().build()) + .setDeployStartTime(Timestamp.newBuilder().build()) + .setDeployEndTime(Timestamp.newBuilder().build()) + .setTargetId("targetId-441951604") + .setFailureReason("failureReason-1990598546") + .setDeployingBuild("deployingBuild-1935837805") + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + RolloutName name = + RolloutName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]", "[ROLLOUT]"); + + Rollout actualResponse = client.getRollout(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 getRolloutExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RolloutName name = + RolloutName.of( + "[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]", "[ROLLOUT]"); + client.getRollout(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getRolloutTest2() throws Exception { + Rollout expectedResponse = + Rollout.newBuilder() + .setName( + RolloutName.of( + "[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]", "[ROLLOUT]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setApproveTime(Timestamp.newBuilder().build()) + .setEnqueueTime(Timestamp.newBuilder().build()) + .setDeployStartTime(Timestamp.newBuilder().build()) + .setDeployEndTime(Timestamp.newBuilder().build()) + .setTargetId("targetId-441951604") + .setFailureReason("failureReason-1990598546") + .setDeployingBuild("deployingBuild-1935837805") + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-2057/locations/location-2057/deliveryPipelines/deliveryPipeline-2057/releases/release-2057/rollouts/rollout-2057"; + + Rollout actualResponse = client.getRollout(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 getRolloutExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-2057/locations/location-2057/deliveryPipelines/deliveryPipeline-2057/releases/release-2057/rollouts/rollout-2057"; + client.getRollout(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createRolloutTest() throws Exception { + Rollout expectedResponse = + Rollout.newBuilder() + .setName( + RolloutName.of( + "[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]", "[ROLLOUT]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setApproveTime(Timestamp.newBuilder().build()) + .setEnqueueTime(Timestamp.newBuilder().build()) + .setDeployStartTime(Timestamp.newBuilder().build()) + .setDeployEndTime(Timestamp.newBuilder().build()) + .setTargetId("targetId-441951604") + .setFailureReason("failureReason-1990598546") + .setDeployingBuild("deployingBuild-1935837805") + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createRolloutTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + ReleaseName parent = + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]"); + Rollout rollout = Rollout.newBuilder().build(); + String rolloutId = "rolloutId551248556"; + + Rollout actualResponse = client.createRolloutAsync(parent, rollout, rolloutId).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 createRolloutExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ReleaseName parent = + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]"); + Rollout rollout = Rollout.newBuilder().build(); + String rolloutId = "rolloutId551248556"; + client.createRolloutAsync(parent, rollout, rolloutId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createRolloutTest2() throws Exception { + Rollout expectedResponse = + Rollout.newBuilder() + .setName( + RolloutName.of( + "[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]", "[ROLLOUT]") + .toString()) + .setUid("uid115792") + .setDescription("description-1724546052") + .putAllAnnotations(new HashMap()) + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setApproveTime(Timestamp.newBuilder().build()) + .setEnqueueTime(Timestamp.newBuilder().build()) + .setDeployStartTime(Timestamp.newBuilder().build()) + .setDeployEndTime(Timestamp.newBuilder().build()) + .setTargetId("targetId-441951604") + .setFailureReason("failureReason-1990598546") + .setDeployingBuild("deployingBuild-1935837805") + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createRolloutTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = + "projects/project-2532/locations/location-2532/deliveryPipelines/deliveryPipeline-2532/releases/release-2532"; + Rollout rollout = Rollout.newBuilder().build(); + String rolloutId = "rolloutId551248556"; + + Rollout actualResponse = client.createRolloutAsync(parent, rollout, rolloutId).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 createRolloutExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-2532/locations/location-2532/deliveryPipelines/deliveryPipeline-2532/releases/release-2532"; + Rollout rollout = Rollout.newBuilder().build(); + String rolloutId = "rolloutId551248556"; + client.createRolloutAsync(parent, rollout, rolloutId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getConfigTest() throws Exception { + Config expectedResponse = + Config.newBuilder() + .setName(ConfigName.of("[PROJECT]", "[LOCATION]").toString()) + .addAllSupportedVersions(new ArrayList()) + .setDefaultSkaffoldVersion("defaultSkaffoldVersion-1555289991") + .build(); + mockService.addResponse(expectedResponse); + + ConfigName name = ConfigName.of("[PROJECT]", "[LOCATION]"); + + Config actualResponse = client.getConfig(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 getConfigExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ConfigName name = ConfigName.of("[PROJECT]", "[LOCATION]"); + client.getConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConfigTest2() throws Exception { + Config expectedResponse = + Config.newBuilder() + .setName(ConfigName.of("[PROJECT]", "[LOCATION]").toString()) + .addAllSupportedVersions(new ArrayList()) + .setDefaultSkaffoldVersion("defaultSkaffoldVersion-1555289991") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-505/locations/location-505/config"; + + Config actualResponse = client.getConfig(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 getConfigExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-505/locations/location-505/config"; + client.getConfig(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/approverollout/AsyncApproveRollout.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/approverollout/AsyncApproveRollout.java new file mode 100644 index 000000000000..f63741bad2db --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/approverollout/AsyncApproveRollout.java @@ -0,0 +1,55 @@ +/* + * 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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_approverollout_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.ApproveRolloutRequest; +import com.google.cloud.deploy.v1.ApproveRolloutResponse; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.RolloutName; + +public class AsyncApproveRollout { + + public static void main(String[] args) throws Exception { + asyncApproveRollout(); + } + + public static void asyncApproveRollout() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ApproveRolloutRequest request = + ApproveRolloutRequest.newBuilder() + .setName( + RolloutName.of( + "[PROJECT]", + "[LOCATION]", + "[DELIVERY_PIPELINE]", + "[RELEASE]", + "[ROLLOUT]") + .toString()) + .setApproved(true) + .build(); + ApiFuture future = + cloudDeployClient.approveRolloutCallable().futureCall(request); + // Do something. + ApproveRolloutResponse response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_approverollout_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/approverollout/SyncApproveRollout.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/approverollout/SyncApproveRollout.java new file mode 100644 index 000000000000..3453ac844906 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/approverollout/SyncApproveRollout.java @@ -0,0 +1,51 @@ +/* + * 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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_approverollout_sync] +import com.google.cloud.deploy.v1.ApproveRolloutRequest; +import com.google.cloud.deploy.v1.ApproveRolloutResponse; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.RolloutName; + +public class SyncApproveRollout { + + public static void main(String[] args) throws Exception { + syncApproveRollout(); + } + + public static void syncApproveRollout() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ApproveRolloutRequest request = + ApproveRolloutRequest.newBuilder() + .setName( + RolloutName.of( + "[PROJECT]", + "[LOCATION]", + "[DELIVERY_PIPELINE]", + "[RELEASE]", + "[ROLLOUT]") + .toString()) + .setApproved(true) + .build(); + ApproveRolloutResponse response = cloudDeployClient.approveRollout(request); + } + } +} +// [END deploy_v1_generated_clouddeployclient_approverollout_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/approverollout/SyncApproveRolloutRolloutname.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/approverollout/SyncApproveRolloutRolloutname.java new file mode 100644 index 000000000000..49a2a4a6b541 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/approverollout/SyncApproveRolloutRolloutname.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_approverollout_rolloutname_sync] +import com.google.cloud.deploy.v1.ApproveRolloutResponse; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.RolloutName; + +public class SyncApproveRolloutRolloutname { + + public static void main(String[] args) throws Exception { + syncApproveRolloutRolloutname(); + } + + public static void syncApproveRolloutRolloutname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + RolloutName name = + RolloutName.of( + "[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]", "[ROLLOUT]"); + ApproveRolloutResponse response = cloudDeployClient.approveRollout(name); + } + } +} +// [END deploy_v1_generated_clouddeployclient_approverollout_rolloutname_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/approverollout/SyncApproveRolloutString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/approverollout/SyncApproveRolloutString.java new file mode 100644 index 000000000000..33ec2a6956b7 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/approverollout/SyncApproveRolloutString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_approverollout_string_sync] +import com.google.cloud.deploy.v1.ApproveRolloutResponse; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.RolloutName; + +public class SyncApproveRolloutString { + + public static void main(String[] args) throws Exception { + syncApproveRolloutString(); + } + + public static void syncApproveRolloutString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String name = + RolloutName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]", "[ROLLOUT]") + .toString(); + ApproveRolloutResponse response = cloudDeployClient.approveRollout(name); + } + } +} +// [END deploy_v1_generated_clouddeployclient_approverollout_string_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/create/SyncCreateSetCredentialsProvider.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..fc268ce0a35a --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/create/SyncCreateSetCredentialsProvider.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CloudDeploySettings; +import com.google.cloud.deploy.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. + CloudDeploySettings cloudDeploySettings = + CloudDeploySettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CloudDeployClient cloudDeployClient = CloudDeployClient.create(cloudDeploySettings); + } +} +// [END deploy_v1_generated_clouddeployclient_create_setcredentialsprovider_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/create/SyncCreateSetCredentialsProvider1.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..6f705c74cf3a --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/create/SyncCreateSetCredentialsProvider1.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_create_setcredentialsprovider1_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CloudDeploySettings; + +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. + CloudDeploySettings cloudDeploySettings = + CloudDeploySettings.newBuilder() + .setTransportChannelProvider( + CloudDeploySettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CloudDeployClient cloudDeployClient = CloudDeployClient.create(cloudDeploySettings); + } +} +// [END deploy_v1_generated_clouddeployclient_create_setcredentialsprovider1_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/create/SyncCreateSetEndpoint.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..bf4006d537c5 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/create/SyncCreateSetEndpoint.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_create_setendpoint_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CloudDeploySettings; +import com.google.cloud.deploy.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. + CloudDeploySettings cloudDeploySettings = + CloudDeploySettings.newBuilder().setEndpoint(myEndpoint).build(); + CloudDeployClient cloudDeployClient = CloudDeployClient.create(cloudDeploySettings); + } +} +// [END deploy_v1_generated_clouddeployclient_create_setendpoint_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/AsyncCreateDeliveryPipeline.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/AsyncCreateDeliveryPipeline.java new file mode 100644 index 000000000000..f064df753d49 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/AsyncCreateDeliveryPipeline.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createdeliverypipeline_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CreateDeliveryPipelineRequest; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.LocationName; +import com.google.longrunning.Operation; + +public class AsyncCreateDeliveryPipeline { + + public static void main(String[] args) throws Exception { + asyncCreateDeliveryPipeline(); + } + + public static void asyncCreateDeliveryPipeline() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + CreateDeliveryPipelineRequest request = + CreateDeliveryPipelineRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setDeliveryPipelineId("deliveryPipelineId-632411535") + .setDeliveryPipeline(DeliveryPipeline.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .build(); + ApiFuture future = + cloudDeployClient.createDeliveryPipelineCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createdeliverypipeline_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/AsyncCreateDeliveryPipelineLRO.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/AsyncCreateDeliveryPipelineLRO.java new file mode 100644 index 000000000000..eb87a911c10d --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/AsyncCreateDeliveryPipelineLRO.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createdeliverypipeline_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CreateDeliveryPipelineRequest; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.LocationName; +import com.google.cloud.deploy.v1.OperationMetadata; + +public class AsyncCreateDeliveryPipelineLRO { + + public static void main(String[] args) throws Exception { + asyncCreateDeliveryPipelineLRO(); + } + + public static void asyncCreateDeliveryPipelineLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + CreateDeliveryPipelineRequest request = + CreateDeliveryPipelineRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setDeliveryPipelineId("deliveryPipelineId-632411535") + .setDeliveryPipeline(DeliveryPipeline.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .build(); + OperationFuture future = + cloudDeployClient.createDeliveryPipelineOperationCallable().futureCall(request); + // Do something. + DeliveryPipeline response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createdeliverypipeline_lro_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/SyncCreateDeliveryPipeline.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/SyncCreateDeliveryPipeline.java new file mode 100644 index 000000000000..c5e385665296 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/SyncCreateDeliveryPipeline.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createdeliverypipeline_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CreateDeliveryPipelineRequest; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.LocationName; + +public class SyncCreateDeliveryPipeline { + + public static void main(String[] args) throws Exception { + syncCreateDeliveryPipeline(); + } + + public static void syncCreateDeliveryPipeline() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + CreateDeliveryPipelineRequest request = + CreateDeliveryPipelineRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setDeliveryPipelineId("deliveryPipelineId-632411535") + .setDeliveryPipeline(DeliveryPipeline.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .build(); + DeliveryPipeline response = cloudDeployClient.createDeliveryPipelineAsync(request).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createdeliverypipeline_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/SyncCreateDeliveryPipelineLocationnameDeliverypipelineString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/SyncCreateDeliveryPipelineLocationnameDeliverypipelineString.java new file mode 100644 index 000000000000..d8075a3b166c --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/SyncCreateDeliveryPipelineLocationnameDeliverypipelineString.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.deploy.v1.samples; + +// [START +// deploy_v1_generated_clouddeployclient_createdeliverypipeline_locationnamedeliverypipelinestring_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.LocationName; + +public class SyncCreateDeliveryPipelineLocationnameDeliverypipelineString { + + public static void main(String[] args) throws Exception { + syncCreateDeliveryPipelineLocationnameDeliverypipelineString(); + } + + public static void syncCreateDeliveryPipelineLocationnameDeliverypipelineString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + DeliveryPipeline deliveryPipeline = DeliveryPipeline.newBuilder().build(); + String deliveryPipelineId = "deliveryPipelineId-632411535"; + DeliveryPipeline response = + cloudDeployClient + .createDeliveryPipelineAsync(parent, deliveryPipeline, deliveryPipelineId) + .get(); + } + } +} +// [END +// deploy_v1_generated_clouddeployclient_createdeliverypipeline_locationnamedeliverypipelinestring_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/SyncCreateDeliveryPipelineStringDeliverypipelineString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/SyncCreateDeliveryPipelineStringDeliverypipelineString.java new file mode 100644 index 000000000000..efd07ab403b7 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createdeliverypipeline/SyncCreateDeliveryPipelineStringDeliverypipelineString.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.deploy.v1.samples; + +// [START +// deploy_v1_generated_clouddeployclient_createdeliverypipeline_stringdeliverypipelinestring_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.LocationName; + +public class SyncCreateDeliveryPipelineStringDeliverypipelineString { + + public static void main(String[] args) throws Exception { + syncCreateDeliveryPipelineStringDeliverypipelineString(); + } + + public static void syncCreateDeliveryPipelineStringDeliverypipelineString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + DeliveryPipeline deliveryPipeline = DeliveryPipeline.newBuilder().build(); + String deliveryPipelineId = "deliveryPipelineId-632411535"; + DeliveryPipeline response = + cloudDeployClient + .createDeliveryPipelineAsync(parent, deliveryPipeline, deliveryPipelineId) + .get(); + } + } +} +// [END +// deploy_v1_generated_clouddeployclient_createdeliverypipeline_stringdeliverypipelinestring_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/AsyncCreateRelease.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/AsyncCreateRelease.java new file mode 100644 index 000000000000..e1c63101d19d --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/AsyncCreateRelease.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createrelease_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CreateReleaseRequest; +import com.google.cloud.deploy.v1.DeliveryPipelineName; +import com.google.cloud.deploy.v1.Release; +import com.google.longrunning.Operation; + +public class AsyncCreateRelease { + + public static void main(String[] args) throws Exception { + asyncCreateRelease(); + } + + public static void asyncCreateRelease() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + CreateReleaseRequest request = + CreateReleaseRequest.newBuilder() + .setParent( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setReleaseId("releaseId89607042") + .setRelease(Release.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .build(); + ApiFuture future = cloudDeployClient.createReleaseCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createrelease_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/AsyncCreateReleaseLRO.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/AsyncCreateReleaseLRO.java new file mode 100644 index 000000000000..cc99688c0c89 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/AsyncCreateReleaseLRO.java @@ -0,0 +1,54 @@ +/* + * 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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createrelease_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CreateReleaseRequest; +import com.google.cloud.deploy.v1.DeliveryPipelineName; +import com.google.cloud.deploy.v1.OperationMetadata; +import com.google.cloud.deploy.v1.Release; + +public class AsyncCreateReleaseLRO { + + public static void main(String[] args) throws Exception { + asyncCreateReleaseLRO(); + } + + public static void asyncCreateReleaseLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + CreateReleaseRequest request = + CreateReleaseRequest.newBuilder() + .setParent( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setReleaseId("releaseId89607042") + .setRelease(Release.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .build(); + OperationFuture future = + cloudDeployClient.createReleaseOperationCallable().futureCall(request); + // Do something. + Release response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createrelease_lro_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/SyncCreateRelease.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/SyncCreateRelease.java new file mode 100644 index 000000000000..f6ff9e3e72ed --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/SyncCreateRelease.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createrelease_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CreateReleaseRequest; +import com.google.cloud.deploy.v1.DeliveryPipelineName; +import com.google.cloud.deploy.v1.Release; + +public class SyncCreateRelease { + + public static void main(String[] args) throws Exception { + syncCreateRelease(); + } + + public static void syncCreateRelease() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + CreateReleaseRequest request = + CreateReleaseRequest.newBuilder() + .setParent( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setReleaseId("releaseId89607042") + .setRelease(Release.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .build(); + Release response = cloudDeployClient.createReleaseAsync(request).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createrelease_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/SyncCreateReleaseDeliverypipelinenameReleaseString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/SyncCreateReleaseDeliverypipelinenameReleaseString.java new file mode 100644 index 000000000000..19edbd657ca9 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/SyncCreateReleaseDeliverypipelinenameReleaseString.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.deploy.v1.samples; + +// [START +// deploy_v1_generated_clouddeployclient_createrelease_deliverypipelinenamereleasestring_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipelineName; +import com.google.cloud.deploy.v1.Release; + +public class SyncCreateReleaseDeliverypipelinenameReleaseString { + + public static void main(String[] args) throws Exception { + syncCreateReleaseDeliverypipelinenameReleaseString(); + } + + public static void syncCreateReleaseDeliverypipelinenameReleaseString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + DeliveryPipelineName parent = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]"); + Release release = Release.newBuilder().build(); + String releaseId = "releaseId89607042"; + Release response = cloudDeployClient.createReleaseAsync(parent, release, releaseId).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createrelease_deliverypipelinenamereleasestring_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/SyncCreateReleaseStringReleaseString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/SyncCreateReleaseStringReleaseString.java new file mode 100644 index 000000000000..5a4a23d1f05e --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrelease/SyncCreateReleaseStringReleaseString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createrelease_stringreleasestring_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipelineName; +import com.google.cloud.deploy.v1.Release; + +public class SyncCreateReleaseStringReleaseString { + + public static void main(String[] args) throws Exception { + syncCreateReleaseStringReleaseString(); + } + + public static void syncCreateReleaseStringReleaseString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String parent = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]").toString(); + Release release = Release.newBuilder().build(); + String releaseId = "releaseId89607042"; + Release response = cloudDeployClient.createReleaseAsync(parent, release, releaseId).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createrelease_stringreleasestring_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/AsyncCreateRollout.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/AsyncCreateRollout.java new file mode 100644 index 000000000000..e3b99343ea2d --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/AsyncCreateRollout.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createrollout_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CreateRolloutRequest; +import com.google.cloud.deploy.v1.ReleaseName; +import com.google.cloud.deploy.v1.Rollout; +import com.google.longrunning.Operation; + +public class AsyncCreateRollout { + + public static void main(String[] args) throws Exception { + asyncCreateRollout(); + } + + public static void asyncCreateRollout() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + CreateRolloutRequest request = + CreateRolloutRequest.newBuilder() + .setParent( + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]") + .toString()) + .setRolloutId("rolloutId551248556") + .setRollout(Rollout.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .build(); + ApiFuture future = cloudDeployClient.createRolloutCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createrollout_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/AsyncCreateRolloutLRO.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/AsyncCreateRolloutLRO.java new file mode 100644 index 000000000000..2b752f3479e2 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/AsyncCreateRolloutLRO.java @@ -0,0 +1,54 @@ +/* + * 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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createrollout_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CreateRolloutRequest; +import com.google.cloud.deploy.v1.OperationMetadata; +import com.google.cloud.deploy.v1.ReleaseName; +import com.google.cloud.deploy.v1.Rollout; + +public class AsyncCreateRolloutLRO { + + public static void main(String[] args) throws Exception { + asyncCreateRolloutLRO(); + } + + public static void asyncCreateRolloutLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + CreateRolloutRequest request = + CreateRolloutRequest.newBuilder() + .setParent( + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]") + .toString()) + .setRolloutId("rolloutId551248556") + .setRollout(Rollout.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .build(); + OperationFuture future = + cloudDeployClient.createRolloutOperationCallable().futureCall(request); + // Do something. + Rollout response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createrollout_lro_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/SyncCreateRollout.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/SyncCreateRollout.java new file mode 100644 index 000000000000..96a48a7e6a46 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/SyncCreateRollout.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createrollout_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CreateRolloutRequest; +import com.google.cloud.deploy.v1.ReleaseName; +import com.google.cloud.deploy.v1.Rollout; + +public class SyncCreateRollout { + + public static void main(String[] args) throws Exception { + syncCreateRollout(); + } + + public static void syncCreateRollout() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + CreateRolloutRequest request = + CreateRolloutRequest.newBuilder() + .setParent( + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]") + .toString()) + .setRolloutId("rolloutId551248556") + .setRollout(Rollout.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .build(); + Rollout response = cloudDeployClient.createRolloutAsync(request).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createrollout_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/SyncCreateRolloutReleasenameRolloutString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/SyncCreateRolloutReleasenameRolloutString.java new file mode 100644 index 000000000000..4309b5b77903 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/SyncCreateRolloutReleasenameRolloutString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createrollout_releasenamerolloutstring_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.ReleaseName; +import com.google.cloud.deploy.v1.Rollout; + +public class SyncCreateRolloutReleasenameRolloutString { + + public static void main(String[] args) throws Exception { + syncCreateRolloutReleasenameRolloutString(); + } + + public static void syncCreateRolloutReleasenameRolloutString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ReleaseName parent = + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]"); + Rollout rollout = Rollout.newBuilder().build(); + String rolloutId = "rolloutId551248556"; + Rollout response = cloudDeployClient.createRolloutAsync(parent, rollout, rolloutId).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createrollout_releasenamerolloutstring_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/SyncCreateRolloutStringRolloutString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/SyncCreateRolloutStringRolloutString.java new file mode 100644 index 000000000000..9f9da471dd23 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createrollout/SyncCreateRolloutStringRolloutString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createrollout_stringrolloutstring_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.ReleaseName; +import com.google.cloud.deploy.v1.Rollout; + +public class SyncCreateRolloutStringRolloutString { + + public static void main(String[] args) throws Exception { + syncCreateRolloutStringRolloutString(); + } + + public static void syncCreateRolloutStringRolloutString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String parent = + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]").toString(); + Rollout rollout = Rollout.newBuilder().build(); + String rolloutId = "rolloutId551248556"; + Rollout response = cloudDeployClient.createRolloutAsync(parent, rollout, rolloutId).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createrollout_stringrolloutstring_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/AsyncCreateTarget.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/AsyncCreateTarget.java new file mode 100644 index 000000000000..a22cd34969c7 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/AsyncCreateTarget.java @@ -0,0 +1,51 @@ +/* + * 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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createtarget_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CreateTargetRequest; +import com.google.cloud.deploy.v1.LocationName; +import com.google.cloud.deploy.v1.Target; +import com.google.longrunning.Operation; + +public class AsyncCreateTarget { + + public static void main(String[] args) throws Exception { + asyncCreateTarget(); + } + + public static void asyncCreateTarget() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + CreateTargetRequest request = + CreateTargetRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setTargetId("targetId-441951604") + .setTarget(Target.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .build(); + ApiFuture future = cloudDeployClient.createTargetCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createtarget_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/AsyncCreateTargetLRO.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/AsyncCreateTargetLRO.java new file mode 100644 index 000000000000..ee3219d26c54 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/AsyncCreateTargetLRO.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createtarget_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CreateTargetRequest; +import com.google.cloud.deploy.v1.LocationName; +import com.google.cloud.deploy.v1.OperationMetadata; +import com.google.cloud.deploy.v1.Target; + +public class AsyncCreateTargetLRO { + + public static void main(String[] args) throws Exception { + asyncCreateTargetLRO(); + } + + public static void asyncCreateTargetLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + CreateTargetRequest request = + CreateTargetRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setTargetId("targetId-441951604") + .setTarget(Target.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .build(); + OperationFuture future = + cloudDeployClient.createTargetOperationCallable().futureCall(request); + // Do something. + Target response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createtarget_lro_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/SyncCreateTarget.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/SyncCreateTarget.java new file mode 100644 index 000000000000..9a3766c12f37 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/SyncCreateTarget.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createtarget_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.CreateTargetRequest; +import com.google.cloud.deploy.v1.LocationName; +import com.google.cloud.deploy.v1.Target; + +public class SyncCreateTarget { + + public static void main(String[] args) throws Exception { + syncCreateTarget(); + } + + public static void syncCreateTarget() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + CreateTargetRequest request = + CreateTargetRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setTargetId("targetId-441951604") + .setTarget(Target.newBuilder().build()) + .setRequestId("requestId693933066") + .setValidateOnly(true) + .build(); + Target response = cloudDeployClient.createTargetAsync(request).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createtarget_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/SyncCreateTargetLocationnameTargetString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/SyncCreateTargetLocationnameTargetString.java new file mode 100644 index 000000000000..d93d715b88eb --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/SyncCreateTargetLocationnameTargetString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createtarget_locationnametargetstring_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.LocationName; +import com.google.cloud.deploy.v1.Target; + +public class SyncCreateTargetLocationnameTargetString { + + public static void main(String[] args) throws Exception { + syncCreateTargetLocationnameTargetString(); + } + + public static void syncCreateTargetLocationnameTargetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Target target = Target.newBuilder().build(); + String targetId = "targetId-441951604"; + Target response = cloudDeployClient.createTargetAsync(parent, target, targetId).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createtarget_locationnametargetstring_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/SyncCreateTargetStringTargetString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/SyncCreateTargetStringTargetString.java new file mode 100644 index 000000000000..545f00a1a104 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/createtarget/SyncCreateTargetStringTargetString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_createtarget_stringtargetstring_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.LocationName; +import com.google.cloud.deploy.v1.Target; + +public class SyncCreateTargetStringTargetString { + + public static void main(String[] args) throws Exception { + syncCreateTargetStringTargetString(); + } + + public static void syncCreateTargetStringTargetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Target target = Target.newBuilder().build(); + String targetId = "targetId-441951604"; + Target response = cloudDeployClient.createTargetAsync(parent, target, targetId).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_createtarget_stringtargetstring_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/AsyncDeleteDeliveryPipeline.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/AsyncDeleteDeliveryPipeline.java new file mode 100644 index 000000000000..8c2310ef1019 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/AsyncDeleteDeliveryPipeline.java @@ -0,0 +1,54 @@ +/* + * 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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_deletedeliverypipeline_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeleteDeliveryPipelineRequest; +import com.google.cloud.deploy.v1.DeliveryPipelineName; +import com.google.longrunning.Operation; + +public class AsyncDeleteDeliveryPipeline { + + public static void main(String[] args) throws Exception { + asyncDeleteDeliveryPipeline(); + } + + public static void asyncDeleteDeliveryPipeline() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + DeleteDeliveryPipelineRequest request = + DeleteDeliveryPipelineRequest.newBuilder() + .setName( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setRequestId("requestId693933066") + .setAllowMissing(true) + .setValidateOnly(true) + .setForce(true) + .setEtag("etag3123477") + .build(); + ApiFuture future = + cloudDeployClient.deleteDeliveryPipelineCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_deletedeliverypipeline_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/AsyncDeleteDeliveryPipelineLRO.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/AsyncDeleteDeliveryPipelineLRO.java new file mode 100644 index 000000000000..190991eb3f3d --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/AsyncDeleteDeliveryPipelineLRO.java @@ -0,0 +1,55 @@ +/* + * 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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_deletedeliverypipeline_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeleteDeliveryPipelineRequest; +import com.google.cloud.deploy.v1.DeliveryPipelineName; +import com.google.cloud.deploy.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteDeliveryPipelineLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteDeliveryPipelineLRO(); + } + + public static void asyncDeleteDeliveryPipelineLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + DeleteDeliveryPipelineRequest request = + DeleteDeliveryPipelineRequest.newBuilder() + .setName( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setRequestId("requestId693933066") + .setAllowMissing(true) + .setValidateOnly(true) + .setForce(true) + .setEtag("etag3123477") + .build(); + OperationFuture future = + cloudDeployClient.deleteDeliveryPipelineOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_deletedeliverypipeline_lro_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/SyncDeleteDeliveryPipeline.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/SyncDeleteDeliveryPipeline.java new file mode 100644 index 000000000000..116ec5675d31 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/SyncDeleteDeliveryPipeline.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_deletedeliverypipeline_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeleteDeliveryPipelineRequest; +import com.google.cloud.deploy.v1.DeliveryPipelineName; + +public class SyncDeleteDeliveryPipeline { + + public static void main(String[] args) throws Exception { + syncDeleteDeliveryPipeline(); + } + + public static void syncDeleteDeliveryPipeline() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + DeleteDeliveryPipelineRequest request = + DeleteDeliveryPipelineRequest.newBuilder() + .setName( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setRequestId("requestId693933066") + .setAllowMissing(true) + .setValidateOnly(true) + .setForce(true) + .setEtag("etag3123477") + .build(); + cloudDeployClient.deleteDeliveryPipelineAsync(request).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_deletedeliverypipeline_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/SyncDeleteDeliveryPipelineDeliverypipelinename.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/SyncDeleteDeliveryPipelineDeliverypipelinename.java new file mode 100644 index 000000000000..97c2a445c613 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/SyncDeleteDeliveryPipelineDeliverypipelinename.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_deletedeliverypipeline_deliverypipelinename_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipelineName; + +public class SyncDeleteDeliveryPipelineDeliverypipelinename { + + public static void main(String[] args) throws Exception { + syncDeleteDeliveryPipelineDeliverypipelinename(); + } + + public static void syncDeleteDeliveryPipelineDeliverypipelinename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + DeliveryPipelineName name = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]"); + cloudDeployClient.deleteDeliveryPipelineAsync(name).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_deletedeliverypipeline_deliverypipelinename_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/SyncDeleteDeliveryPipelineString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/SyncDeleteDeliveryPipelineString.java new file mode 100644 index 000000000000..e9a6b9835c6f --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletedeliverypipeline/SyncDeleteDeliveryPipelineString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_deletedeliverypipeline_string_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipelineName; + +public class SyncDeleteDeliveryPipelineString { + + public static void main(String[] args) throws Exception { + syncDeleteDeliveryPipelineString(); + } + + public static void syncDeleteDeliveryPipelineString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String name = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]").toString(); + cloudDeployClient.deleteDeliveryPipelineAsync(name).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_deletedeliverypipeline_string_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/AsyncDeleteTarget.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/AsyncDeleteTarget.java new file mode 100644 index 000000000000..4f59c2b060b3 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/AsyncDeleteTarget.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_deletetarget_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeleteTargetRequest; +import com.google.cloud.deploy.v1.TargetName; +import com.google.longrunning.Operation; + +public class AsyncDeleteTarget { + + public static void main(String[] args) throws Exception { + asyncDeleteTarget(); + } + + public static void asyncDeleteTarget() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + DeleteTargetRequest request = + DeleteTargetRequest.newBuilder() + .setName(TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]").toString()) + .setRequestId("requestId693933066") + .setAllowMissing(true) + .setValidateOnly(true) + .setEtag("etag3123477") + .build(); + ApiFuture future = cloudDeployClient.deleteTargetCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_deletetarget_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/AsyncDeleteTargetLRO.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/AsyncDeleteTargetLRO.java new file mode 100644 index 000000000000..15c3f25415f6 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/AsyncDeleteTargetLRO.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_deletetarget_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeleteTargetRequest; +import com.google.cloud.deploy.v1.OperationMetadata; +import com.google.cloud.deploy.v1.TargetName; +import com.google.protobuf.Empty; + +public class AsyncDeleteTargetLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteTargetLRO(); + } + + public static void asyncDeleteTargetLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + DeleteTargetRequest request = + DeleteTargetRequest.newBuilder() + .setName(TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]").toString()) + .setRequestId("requestId693933066") + .setAllowMissing(true) + .setValidateOnly(true) + .setEtag("etag3123477") + .build(); + OperationFuture future = + cloudDeployClient.deleteTargetOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_deletetarget_lro_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/SyncDeleteTarget.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/SyncDeleteTarget.java new file mode 100644 index 000000000000..5e061306db9c --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/SyncDeleteTarget.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_deletetarget_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeleteTargetRequest; +import com.google.cloud.deploy.v1.TargetName; + +public class SyncDeleteTarget { + + public static void main(String[] args) throws Exception { + syncDeleteTarget(); + } + + public static void syncDeleteTarget() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + DeleteTargetRequest request = + DeleteTargetRequest.newBuilder() + .setName(TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]").toString()) + .setRequestId("requestId693933066") + .setAllowMissing(true) + .setValidateOnly(true) + .setEtag("etag3123477") + .build(); + cloudDeployClient.deleteTargetAsync(request).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_deletetarget_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/SyncDeleteTargetString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/SyncDeleteTargetString.java new file mode 100644 index 000000000000..26dd295aef0a --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/SyncDeleteTargetString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_deletetarget_string_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.TargetName; + +public class SyncDeleteTargetString { + + public static void main(String[] args) throws Exception { + syncDeleteTargetString(); + } + + public static void syncDeleteTargetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String name = TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]").toString(); + cloudDeployClient.deleteTargetAsync(name).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_deletetarget_string_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/SyncDeleteTargetTargetname.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/SyncDeleteTargetTargetname.java new file mode 100644 index 000000000000..20506cd11fc4 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/deletetarget/SyncDeleteTargetTargetname.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_deletetarget_targetname_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.TargetName; + +public class SyncDeleteTargetTargetname { + + public static void main(String[] args) throws Exception { + syncDeleteTargetTargetname(); + } + + public static void syncDeleteTargetTargetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + TargetName name = TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]"); + cloudDeployClient.deleteTargetAsync(name).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_deletetarget_targetname_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getconfig/AsyncGetConfig.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getconfig/AsyncGetConfig.java new file mode 100644 index 000000000000..90f969b85673 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getconfig/AsyncGetConfig.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getconfig_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.Config; +import com.google.cloud.deploy.v1.ConfigName; +import com.google.cloud.deploy.v1.GetConfigRequest; + +public class AsyncGetConfig { + + public static void main(String[] args) throws Exception { + asyncGetConfig(); + } + + public static void asyncGetConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + GetConfigRequest request = + GetConfigRequest.newBuilder() + .setName(ConfigName.of("[PROJECT]", "[LOCATION]").toString()) + .build(); + ApiFuture future = cloudDeployClient.getConfigCallable().futureCall(request); + // Do something. + Config response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getconfig_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getconfig/SyncGetConfig.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getconfig/SyncGetConfig.java new file mode 100644 index 000000000000..f14df410f773 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getconfig/SyncGetConfig.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getconfig_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.Config; +import com.google.cloud.deploy.v1.ConfigName; +import com.google.cloud.deploy.v1.GetConfigRequest; + +public class SyncGetConfig { + + public static void main(String[] args) throws Exception { + syncGetConfig(); + } + + public static void syncGetConfig() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + GetConfigRequest request = + GetConfigRequest.newBuilder() + .setName(ConfigName.of("[PROJECT]", "[LOCATION]").toString()) + .build(); + Config response = cloudDeployClient.getConfig(request); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getconfig_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getconfig/SyncGetConfigConfigname.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getconfig/SyncGetConfigConfigname.java new file mode 100644 index 000000000000..4908cd997ec9 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getconfig/SyncGetConfigConfigname.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getconfig_configname_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.Config; +import com.google.cloud.deploy.v1.ConfigName; + +public class SyncGetConfigConfigname { + + public static void main(String[] args) throws Exception { + syncGetConfigConfigname(); + } + + public static void syncGetConfigConfigname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ConfigName name = ConfigName.of("[PROJECT]", "[LOCATION]"); + Config response = cloudDeployClient.getConfig(name); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getconfig_configname_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getconfig/SyncGetConfigString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getconfig/SyncGetConfigString.java new file mode 100644 index 000000000000..54b2d239e1f7 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getconfig/SyncGetConfigString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getconfig_string_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.Config; +import com.google.cloud.deploy.v1.ConfigName; + +public class SyncGetConfigString { + + public static void main(String[] args) throws Exception { + syncGetConfigString(); + } + + public static void syncGetConfigString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String name = ConfigName.of("[PROJECT]", "[LOCATION]").toString(); + Config response = cloudDeployClient.getConfig(name); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getconfig_string_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getdeliverypipeline/AsyncGetDeliveryPipeline.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getdeliverypipeline/AsyncGetDeliveryPipeline.java new file mode 100644 index 000000000000..1154284abb79 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getdeliverypipeline/AsyncGetDeliveryPipeline.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getdeliverypipeline_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.DeliveryPipelineName; +import com.google.cloud.deploy.v1.GetDeliveryPipelineRequest; + +public class AsyncGetDeliveryPipeline { + + public static void main(String[] args) throws Exception { + asyncGetDeliveryPipeline(); + } + + public static void asyncGetDeliveryPipeline() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + GetDeliveryPipelineRequest request = + GetDeliveryPipelineRequest.newBuilder() + .setName( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .build(); + ApiFuture future = + cloudDeployClient.getDeliveryPipelineCallable().futureCall(request); + // Do something. + DeliveryPipeline response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getdeliverypipeline_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getdeliverypipeline/SyncGetDeliveryPipeline.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getdeliverypipeline/SyncGetDeliveryPipeline.java new file mode 100644 index 000000000000..b29533cbed68 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getdeliverypipeline/SyncGetDeliveryPipeline.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getdeliverypipeline_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.DeliveryPipelineName; +import com.google.cloud.deploy.v1.GetDeliveryPipelineRequest; + +public class SyncGetDeliveryPipeline { + + public static void main(String[] args) throws Exception { + syncGetDeliveryPipeline(); + } + + public static void syncGetDeliveryPipeline() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + GetDeliveryPipelineRequest request = + GetDeliveryPipelineRequest.newBuilder() + .setName( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .build(); + DeliveryPipeline response = cloudDeployClient.getDeliveryPipeline(request); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getdeliverypipeline_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getdeliverypipeline/SyncGetDeliveryPipelineDeliverypipelinename.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getdeliverypipeline/SyncGetDeliveryPipelineDeliverypipelinename.java new file mode 100644 index 000000000000..c6c11e3101c7 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getdeliverypipeline/SyncGetDeliveryPipelineDeliverypipelinename.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getdeliverypipeline_deliverypipelinename_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.DeliveryPipelineName; + +public class SyncGetDeliveryPipelineDeliverypipelinename { + + public static void main(String[] args) throws Exception { + syncGetDeliveryPipelineDeliverypipelinename(); + } + + public static void syncGetDeliveryPipelineDeliverypipelinename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + DeliveryPipelineName name = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]"); + DeliveryPipeline response = cloudDeployClient.getDeliveryPipeline(name); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getdeliverypipeline_deliverypipelinename_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getdeliverypipeline/SyncGetDeliveryPipelineString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getdeliverypipeline/SyncGetDeliveryPipelineString.java new file mode 100644 index 000000000000..1a5e2e4d0f3e --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getdeliverypipeline/SyncGetDeliveryPipelineString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getdeliverypipeline_string_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.DeliveryPipelineName; + +public class SyncGetDeliveryPipelineString { + + public static void main(String[] args) throws Exception { + syncGetDeliveryPipelineString(); + } + + public static void syncGetDeliveryPipelineString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String name = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]").toString(); + DeliveryPipeline response = cloudDeployClient.getDeliveryPipeline(name); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getdeliverypipeline_string_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrelease/AsyncGetRelease.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrelease/AsyncGetRelease.java new file mode 100644 index 000000000000..dd5c692f275c --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrelease/AsyncGetRelease.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getrelease_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.GetReleaseRequest; +import com.google.cloud.deploy.v1.Release; +import com.google.cloud.deploy.v1.ReleaseName; + +public class AsyncGetRelease { + + public static void main(String[] args) throws Exception { + asyncGetRelease(); + } + + public static void asyncGetRelease() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + GetReleaseRequest request = + GetReleaseRequest.newBuilder() + .setName( + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]") + .toString()) + .build(); + ApiFuture future = cloudDeployClient.getReleaseCallable().futureCall(request); + // Do something. + Release response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getrelease_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrelease/SyncGetRelease.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrelease/SyncGetRelease.java new file mode 100644 index 000000000000..58f906be3d52 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrelease/SyncGetRelease.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getrelease_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.GetReleaseRequest; +import com.google.cloud.deploy.v1.Release; +import com.google.cloud.deploy.v1.ReleaseName; + +public class SyncGetRelease { + + public static void main(String[] args) throws Exception { + syncGetRelease(); + } + + public static void syncGetRelease() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + GetReleaseRequest request = + GetReleaseRequest.newBuilder() + .setName( + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]") + .toString()) + .build(); + Release response = cloudDeployClient.getRelease(request); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getrelease_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrelease/SyncGetReleaseReleasename.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrelease/SyncGetReleaseReleasename.java new file mode 100644 index 000000000000..61100faf7f60 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrelease/SyncGetReleaseReleasename.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getrelease_releasename_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.Release; +import com.google.cloud.deploy.v1.ReleaseName; + +public class SyncGetReleaseReleasename { + + public static void main(String[] args) throws Exception { + syncGetReleaseReleasename(); + } + + public static void syncGetReleaseReleasename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ReleaseName name = + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]"); + Release response = cloudDeployClient.getRelease(name); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getrelease_releasename_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrelease/SyncGetReleaseString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrelease/SyncGetReleaseString.java new file mode 100644 index 000000000000..327560ec7a55 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrelease/SyncGetReleaseString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getrelease_string_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.Release; +import com.google.cloud.deploy.v1.ReleaseName; + +public class SyncGetReleaseString { + + public static void main(String[] args) throws Exception { + syncGetReleaseString(); + } + + public static void syncGetReleaseString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String name = + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]").toString(); + Release response = cloudDeployClient.getRelease(name); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getrelease_string_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrollout/AsyncGetRollout.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrollout/AsyncGetRollout.java new file mode 100644 index 000000000000..09329818af11 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrollout/AsyncGetRollout.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getrollout_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.GetRolloutRequest; +import com.google.cloud.deploy.v1.Rollout; +import com.google.cloud.deploy.v1.RolloutName; + +public class AsyncGetRollout { + + public static void main(String[] args) throws Exception { + asyncGetRollout(); + } + + public static void asyncGetRollout() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + GetRolloutRequest request = + GetRolloutRequest.newBuilder() + .setName( + RolloutName.of( + "[PROJECT]", + "[LOCATION]", + "[DELIVERY_PIPELINE]", + "[RELEASE]", + "[ROLLOUT]") + .toString()) + .build(); + ApiFuture future = cloudDeployClient.getRolloutCallable().futureCall(request); + // Do something. + Rollout response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getrollout_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrollout/SyncGetRollout.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrollout/SyncGetRollout.java new file mode 100644 index 000000000000..d94f94a5fbd2 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrollout/SyncGetRollout.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getrollout_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.GetRolloutRequest; +import com.google.cloud.deploy.v1.Rollout; +import com.google.cloud.deploy.v1.RolloutName; + +public class SyncGetRollout { + + public static void main(String[] args) throws Exception { + syncGetRollout(); + } + + public static void syncGetRollout() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + GetRolloutRequest request = + GetRolloutRequest.newBuilder() + .setName( + RolloutName.of( + "[PROJECT]", + "[LOCATION]", + "[DELIVERY_PIPELINE]", + "[RELEASE]", + "[ROLLOUT]") + .toString()) + .build(); + Rollout response = cloudDeployClient.getRollout(request); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getrollout_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrollout/SyncGetRolloutRolloutname.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrollout/SyncGetRolloutRolloutname.java new file mode 100644 index 000000000000..beef71bd8823 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrollout/SyncGetRolloutRolloutname.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getrollout_rolloutname_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.Rollout; +import com.google.cloud.deploy.v1.RolloutName; + +public class SyncGetRolloutRolloutname { + + public static void main(String[] args) throws Exception { + syncGetRolloutRolloutname(); + } + + public static void syncGetRolloutRolloutname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + RolloutName name = + RolloutName.of( + "[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]", "[ROLLOUT]"); + Rollout response = cloudDeployClient.getRollout(name); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getrollout_rolloutname_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrollout/SyncGetRolloutString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrollout/SyncGetRolloutString.java new file mode 100644 index 000000000000..4aebcee5f8f3 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/getrollout/SyncGetRolloutString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_getrollout_string_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.Rollout; +import com.google.cloud.deploy.v1.RolloutName; + +public class SyncGetRolloutString { + + public static void main(String[] args) throws Exception { + syncGetRolloutString(); + } + + public static void syncGetRolloutString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String name = + RolloutName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]", "[ROLLOUT]") + .toString(); + Rollout response = cloudDeployClient.getRollout(name); + } + } +} +// [END deploy_v1_generated_clouddeployclient_getrollout_string_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/gettarget/AsyncGetTarget.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/gettarget/AsyncGetTarget.java new file mode 100644 index 000000000000..7d167b1ad618 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/gettarget/AsyncGetTarget.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_gettarget_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.GetTargetRequest; +import com.google.cloud.deploy.v1.Target; +import com.google.cloud.deploy.v1.TargetName; + +public class AsyncGetTarget { + + public static void main(String[] args) throws Exception { + asyncGetTarget(); + } + + public static void asyncGetTarget() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + GetTargetRequest request = + GetTargetRequest.newBuilder() + .setName(TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]").toString()) + .build(); + ApiFuture future = cloudDeployClient.getTargetCallable().futureCall(request); + // Do something. + Target response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_gettarget_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/gettarget/SyncGetTarget.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/gettarget/SyncGetTarget.java new file mode 100644 index 000000000000..163714c184fb --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/gettarget/SyncGetTarget.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_gettarget_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.GetTargetRequest; +import com.google.cloud.deploy.v1.Target; +import com.google.cloud.deploy.v1.TargetName; + +public class SyncGetTarget { + + public static void main(String[] args) throws Exception { + syncGetTarget(); + } + + public static void syncGetTarget() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + GetTargetRequest request = + GetTargetRequest.newBuilder() + .setName(TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]").toString()) + .build(); + Target response = cloudDeployClient.getTarget(request); + } + } +} +// [END deploy_v1_generated_clouddeployclient_gettarget_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/gettarget/SyncGetTargetString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/gettarget/SyncGetTargetString.java new file mode 100644 index 000000000000..1fa3ddcfaa4b --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/gettarget/SyncGetTargetString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_gettarget_string_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.Target; +import com.google.cloud.deploy.v1.TargetName; + +public class SyncGetTargetString { + + public static void main(String[] args) throws Exception { + syncGetTargetString(); + } + + public static void syncGetTargetString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String name = TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]").toString(); + Target response = cloudDeployClient.getTarget(name); + } + } +} +// [END deploy_v1_generated_clouddeployclient_gettarget_string_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/gettarget/SyncGetTargetTargetname.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/gettarget/SyncGetTargetTargetname.java new file mode 100644 index 000000000000..e47461866d09 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/gettarget/SyncGetTargetTargetname.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_gettarget_targetname_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.Target; +import com.google.cloud.deploy.v1.TargetName; + +public class SyncGetTargetTargetname { + + public static void main(String[] args) throws Exception { + syncGetTargetTargetname(); + } + + public static void syncGetTargetTargetname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + TargetName name = TargetName.of("[PROJECT]", "[LOCATION]", "[TARGET]"); + Target response = cloudDeployClient.getTarget(name); + } + } +} +// [END deploy_v1_generated_clouddeployclient_gettarget_targetname_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/AsyncListDeliveryPipelines.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/AsyncListDeliveryPipelines.java new file mode 100644 index 000000000000..24e4fa050536 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/AsyncListDeliveryPipelines.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listdeliverypipelines_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.ListDeliveryPipelinesRequest; +import com.google.cloud.deploy.v1.LocationName; + +public class AsyncListDeliveryPipelines { + + public static void main(String[] args) throws Exception { + asyncListDeliveryPipelines(); + } + + public static void asyncListDeliveryPipelines() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ListDeliveryPipelinesRequest request = + ListDeliveryPipelinesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + cloudDeployClient.listDeliveryPipelinesPagedCallable().futureCall(request); + // Do something. + for (DeliveryPipeline element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listdeliverypipelines_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/AsyncListDeliveryPipelinesPaged.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/AsyncListDeliveryPipelinesPaged.java new file mode 100644 index 000000000000..dad0b42b9c83 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/AsyncListDeliveryPipelinesPaged.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listdeliverypipelines_paged_async] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.ListDeliveryPipelinesRequest; +import com.google.cloud.deploy.v1.ListDeliveryPipelinesResponse; +import com.google.cloud.deploy.v1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListDeliveryPipelinesPaged { + + public static void main(String[] args) throws Exception { + asyncListDeliveryPipelinesPaged(); + } + + public static void asyncListDeliveryPipelinesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ListDeliveryPipelinesRequest request = + ListDeliveryPipelinesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListDeliveryPipelinesResponse response = + cloudDeployClient.listDeliveryPipelinesCallable().call(request); + for (DeliveryPipeline element : response.getDeliveryPipelinesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listdeliverypipelines_paged_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/SyncListDeliveryPipelines.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/SyncListDeliveryPipelines.java new file mode 100644 index 000000000000..240c1dcd5c25 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/SyncListDeliveryPipelines.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listdeliverypipelines_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.ListDeliveryPipelinesRequest; +import com.google.cloud.deploy.v1.LocationName; + +public class SyncListDeliveryPipelines { + + public static void main(String[] args) throws Exception { + syncListDeliveryPipelines(); + } + + public static void syncListDeliveryPipelines() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ListDeliveryPipelinesRequest request = + ListDeliveryPipelinesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (DeliveryPipeline element : + cloudDeployClient.listDeliveryPipelines(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listdeliverypipelines_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/SyncListDeliveryPipelinesLocationname.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/SyncListDeliveryPipelinesLocationname.java new file mode 100644 index 000000000000..a5c1b374c581 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/SyncListDeliveryPipelinesLocationname.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listdeliverypipelines_locationname_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.LocationName; + +public class SyncListDeliveryPipelinesLocationname { + + public static void main(String[] args) throws Exception { + syncListDeliveryPipelinesLocationname(); + } + + public static void syncListDeliveryPipelinesLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (DeliveryPipeline element : + cloudDeployClient.listDeliveryPipelines(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listdeliverypipelines_locationname_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/SyncListDeliveryPipelinesString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/SyncListDeliveryPipelinesString.java new file mode 100644 index 000000000000..e13a4d2133a9 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listdeliverypipelines/SyncListDeliveryPipelinesString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listdeliverypipelines_string_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.LocationName; + +public class SyncListDeliveryPipelinesString { + + public static void main(String[] args) throws Exception { + syncListDeliveryPipelinesString(); + } + + public static void syncListDeliveryPipelinesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (DeliveryPipeline element : + cloudDeployClient.listDeliveryPipelines(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listdeliverypipelines_string_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/AsyncListReleases.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/AsyncListReleases.java new file mode 100644 index 000000000000..cf321ad5ae42 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/AsyncListReleases.java @@ -0,0 +1,54 @@ +/* + * 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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listreleases_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipelineName; +import com.google.cloud.deploy.v1.ListReleasesRequest; +import com.google.cloud.deploy.v1.Release; + +public class AsyncListReleases { + + public static void main(String[] args) throws Exception { + asyncListReleases(); + } + + public static void asyncListReleases() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ListReleasesRequest request = + ListReleasesRequest.newBuilder() + .setParent( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = cloudDeployClient.listReleasesPagedCallable().futureCall(request); + // Do something. + for (Release element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listreleases_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/AsyncListReleasesPaged.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/AsyncListReleasesPaged.java new file mode 100644 index 000000000000..deaa2a66d1f5 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/AsyncListReleasesPaged.java @@ -0,0 +1,62 @@ +/* + * 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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listreleases_paged_async] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipelineName; +import com.google.cloud.deploy.v1.ListReleasesRequest; +import com.google.cloud.deploy.v1.ListReleasesResponse; +import com.google.cloud.deploy.v1.Release; +import com.google.common.base.Strings; + +public class AsyncListReleasesPaged { + + public static void main(String[] args) throws Exception { + asyncListReleasesPaged(); + } + + public static void asyncListReleasesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ListReleasesRequest request = + ListReleasesRequest.newBuilder() + .setParent( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListReleasesResponse response = cloudDeployClient.listReleasesCallable().call(request); + for (Release element : response.getReleasesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listreleases_paged_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/SyncListReleases.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/SyncListReleases.java new file mode 100644 index 000000000000..7563a9fcd1e4 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/SyncListReleases.java @@ -0,0 +1,51 @@ +/* + * 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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listreleases_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipelineName; +import com.google.cloud.deploy.v1.ListReleasesRequest; +import com.google.cloud.deploy.v1.Release; + +public class SyncListReleases { + + public static void main(String[] args) throws Exception { + syncListReleases(); + } + + public static void syncListReleases() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ListReleasesRequest request = + ListReleasesRequest.newBuilder() + .setParent( + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Release element : cloudDeployClient.listReleases(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listreleases_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/SyncListReleasesDeliverypipelinename.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/SyncListReleasesDeliverypipelinename.java new file mode 100644 index 000000000000..7e330ae80b81 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/SyncListReleasesDeliverypipelinename.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listreleases_deliverypipelinename_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipelineName; +import com.google.cloud.deploy.v1.Release; + +public class SyncListReleasesDeliverypipelinename { + + public static void main(String[] args) throws Exception { + syncListReleasesDeliverypipelinename(); + } + + public static void syncListReleasesDeliverypipelinename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + DeliveryPipelineName parent = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]"); + for (Release element : cloudDeployClient.listReleases(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listreleases_deliverypipelinename_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/SyncListReleasesString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/SyncListReleasesString.java new file mode 100644 index 000000000000..7d94b266ef54 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listreleases/SyncListReleasesString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listreleases_string_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipelineName; +import com.google.cloud.deploy.v1.Release; + +public class SyncListReleasesString { + + public static void main(String[] args) throws Exception { + syncListReleasesString(); + } + + public static void syncListReleasesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String parent = + DeliveryPipelineName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]").toString(); + for (Release element : cloudDeployClient.listReleases(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listreleases_string_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/AsyncListRollouts.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/AsyncListRollouts.java new file mode 100644 index 000000000000..22fe376ef54d --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/AsyncListRollouts.java @@ -0,0 +1,54 @@ +/* + * 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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listrollouts_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.ListRolloutsRequest; +import com.google.cloud.deploy.v1.ReleaseName; +import com.google.cloud.deploy.v1.Rollout; + +public class AsyncListRollouts { + + public static void main(String[] args) throws Exception { + asyncListRollouts(); + } + + public static void asyncListRollouts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ListRolloutsRequest request = + ListRolloutsRequest.newBuilder() + .setParent( + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = cloudDeployClient.listRolloutsPagedCallable().futureCall(request); + // Do something. + for (Rollout element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listrollouts_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/AsyncListRolloutsPaged.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/AsyncListRolloutsPaged.java new file mode 100644 index 000000000000..8762da8bbeea --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/AsyncListRolloutsPaged.java @@ -0,0 +1,62 @@ +/* + * 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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listrollouts_paged_async] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.ListRolloutsRequest; +import com.google.cloud.deploy.v1.ListRolloutsResponse; +import com.google.cloud.deploy.v1.ReleaseName; +import com.google.cloud.deploy.v1.Rollout; +import com.google.common.base.Strings; + +public class AsyncListRolloutsPaged { + + public static void main(String[] args) throws Exception { + asyncListRolloutsPaged(); + } + + public static void asyncListRolloutsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ListRolloutsRequest request = + ListRolloutsRequest.newBuilder() + .setParent( + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListRolloutsResponse response = cloudDeployClient.listRolloutsCallable().call(request); + for (Rollout element : response.getRolloutsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listrollouts_paged_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/SyncListRollouts.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/SyncListRollouts.java new file mode 100644 index 000000000000..fe0049ef9e01 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/SyncListRollouts.java @@ -0,0 +1,51 @@ +/* + * 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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listrollouts_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.ListRolloutsRequest; +import com.google.cloud.deploy.v1.ReleaseName; +import com.google.cloud.deploy.v1.Rollout; + +public class SyncListRollouts { + + public static void main(String[] args) throws Exception { + syncListRollouts(); + } + + public static void syncListRollouts() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ListRolloutsRequest request = + ListRolloutsRequest.newBuilder() + .setParent( + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Rollout element : cloudDeployClient.listRollouts(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listrollouts_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/SyncListRolloutsReleasename.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/SyncListRolloutsReleasename.java new file mode 100644 index 000000000000..52d4c7d842c5 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/SyncListRolloutsReleasename.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listrollouts_releasename_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.ReleaseName; +import com.google.cloud.deploy.v1.Rollout; + +public class SyncListRolloutsReleasename { + + public static void main(String[] args) throws Exception { + syncListRolloutsReleasename(); + } + + public static void syncListRolloutsReleasename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ReleaseName parent = + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]"); + for (Rollout element : cloudDeployClient.listRollouts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listrollouts_releasename_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/SyncListRolloutsString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/SyncListRolloutsString.java new file mode 100644 index 000000000000..50c608cc4c71 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listrollouts/SyncListRolloutsString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listrollouts_string_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.ReleaseName; +import com.google.cloud.deploy.v1.Rollout; + +public class SyncListRolloutsString { + + public static void main(String[] args) throws Exception { + syncListRolloutsString(); + } + + public static void syncListRolloutsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String parent = + ReleaseName.of("[PROJECT]", "[LOCATION]", "[DELIVERY_PIPELINE]", "[RELEASE]").toString(); + for (Rollout element : cloudDeployClient.listRollouts(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listrollouts_string_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/AsyncListTargets.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/AsyncListTargets.java new file mode 100644 index 000000000000..f5af26997f1c --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/AsyncListTargets.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listtargets_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.ListTargetsRequest; +import com.google.cloud.deploy.v1.LocationName; +import com.google.cloud.deploy.v1.Target; + +public class AsyncListTargets { + + public static void main(String[] args) throws Exception { + asyncListTargets(); + } + + public static void asyncListTargets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ListTargetsRequest request = + ListTargetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = cloudDeployClient.listTargetsPagedCallable().futureCall(request); + // Do something. + for (Target element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listtargets_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/AsyncListTargetsPaged.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/AsyncListTargetsPaged.java new file mode 100644 index 000000000000..83be9cb31fed --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/AsyncListTargetsPaged.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listtargets_paged_async] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.ListTargetsRequest; +import com.google.cloud.deploy.v1.ListTargetsResponse; +import com.google.cloud.deploy.v1.LocationName; +import com.google.cloud.deploy.v1.Target; +import com.google.common.base.Strings; + +public class AsyncListTargetsPaged { + + public static void main(String[] args) throws Exception { + asyncListTargetsPaged(); + } + + public static void asyncListTargetsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ListTargetsRequest request = + ListTargetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListTargetsResponse response = cloudDeployClient.listTargetsCallable().call(request); + for (Target element : response.getTargetsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listtargets_paged_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/SyncListTargets.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/SyncListTargets.java new file mode 100644 index 000000000000..448be9c43499 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/SyncListTargets.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listtargets_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.ListTargetsRequest; +import com.google.cloud.deploy.v1.LocationName; +import com.google.cloud.deploy.v1.Target; + +public class SyncListTargets { + + public static void main(String[] args) throws Exception { + syncListTargets(); + } + + public static void syncListTargets() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + ListTargetsRequest request = + ListTargetsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Target element : cloudDeployClient.listTargets(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listtargets_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/SyncListTargetsLocationname.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/SyncListTargetsLocationname.java new file mode 100644 index 000000000000..d52c055f42aa --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/SyncListTargetsLocationname.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listtargets_locationname_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.LocationName; +import com.google.cloud.deploy.v1.Target; + +public class SyncListTargetsLocationname { + + public static void main(String[] args) throws Exception { + syncListTargetsLocationname(); + } + + public static void syncListTargetsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Target element : cloudDeployClient.listTargets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listtargets_locationname_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/SyncListTargetsString.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/SyncListTargetsString.java new file mode 100644 index 000000000000..68b446728d31 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/listtargets/SyncListTargetsString.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_listtargets_string_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.LocationName; +import com.google.cloud.deploy.v1.Target; + +public class SyncListTargetsString { + + public static void main(String[] args) throws Exception { + syncListTargetsString(); + } + + public static void syncListTargetsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Target element : cloudDeployClient.listTargets(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END deploy_v1_generated_clouddeployclient_listtargets_string_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatedeliverypipeline/AsyncUpdateDeliveryPipeline.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatedeliverypipeline/AsyncUpdateDeliveryPipeline.java new file mode 100644 index 000000000000..9aa6d48df5bb --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatedeliverypipeline/AsyncUpdateDeliveryPipeline.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_updatedeliverypipeline_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.UpdateDeliveryPipelineRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateDeliveryPipeline { + + public static void main(String[] args) throws Exception { + asyncUpdateDeliveryPipeline(); + } + + public static void asyncUpdateDeliveryPipeline() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + UpdateDeliveryPipelineRequest request = + UpdateDeliveryPipelineRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setDeliveryPipeline(DeliveryPipeline.newBuilder().build()) + .setRequestId("requestId693933066") + .setAllowMissing(true) + .setValidateOnly(true) + .build(); + ApiFuture future = + cloudDeployClient.updateDeliveryPipelineCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_updatedeliverypipeline_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatedeliverypipeline/AsyncUpdateDeliveryPipelineLRO.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatedeliverypipeline/AsyncUpdateDeliveryPipelineLRO.java new file mode 100644 index 000000000000..60c9c7e6613c --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatedeliverypipeline/AsyncUpdateDeliveryPipelineLRO.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_updatedeliverypipeline_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.OperationMetadata; +import com.google.cloud.deploy.v1.UpdateDeliveryPipelineRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateDeliveryPipelineLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateDeliveryPipelineLRO(); + } + + public static void asyncUpdateDeliveryPipelineLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + UpdateDeliveryPipelineRequest request = + UpdateDeliveryPipelineRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setDeliveryPipeline(DeliveryPipeline.newBuilder().build()) + .setRequestId("requestId693933066") + .setAllowMissing(true) + .setValidateOnly(true) + .build(); + OperationFuture future = + cloudDeployClient.updateDeliveryPipelineOperationCallable().futureCall(request); + // Do something. + DeliveryPipeline response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_updatedeliverypipeline_lro_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatedeliverypipeline/SyncUpdateDeliveryPipeline.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatedeliverypipeline/SyncUpdateDeliveryPipeline.java new file mode 100644 index 000000000000..8f074ba2cc56 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatedeliverypipeline/SyncUpdateDeliveryPipeline.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_updatedeliverypipeline_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.cloud.deploy.v1.UpdateDeliveryPipelineRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateDeliveryPipeline { + + public static void main(String[] args) throws Exception { + syncUpdateDeliveryPipeline(); + } + + public static void syncUpdateDeliveryPipeline() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + UpdateDeliveryPipelineRequest request = + UpdateDeliveryPipelineRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setDeliveryPipeline(DeliveryPipeline.newBuilder().build()) + .setRequestId("requestId693933066") + .setAllowMissing(true) + .setValidateOnly(true) + .build(); + DeliveryPipeline response = cloudDeployClient.updateDeliveryPipelineAsync(request).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_updatedeliverypipeline_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatedeliverypipeline/SyncUpdateDeliveryPipelineDeliverypipelineFieldmask.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatedeliverypipeline/SyncUpdateDeliveryPipelineDeliverypipelineFieldmask.java new file mode 100644 index 000000000000..c609b84a2591 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatedeliverypipeline/SyncUpdateDeliveryPipelineDeliverypipelineFieldmask.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.deploy.v1.samples; + +// [START +// deploy_v1_generated_clouddeployclient_updatedeliverypipeline_deliverypipelinefieldmask_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.DeliveryPipeline; +import com.google.protobuf.FieldMask; + +public class SyncUpdateDeliveryPipelineDeliverypipelineFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateDeliveryPipelineDeliverypipelineFieldmask(); + } + + public static void syncUpdateDeliveryPipelineDeliverypipelineFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + DeliveryPipeline deliveryPipeline = DeliveryPipeline.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + DeliveryPipeline response = + cloudDeployClient.updateDeliveryPipelineAsync(deliveryPipeline, updateMask).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_updatedeliverypipeline_deliverypipelinefieldmask_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatetarget/AsyncUpdateTarget.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatetarget/AsyncUpdateTarget.java new file mode 100644 index 000000000000..5d35077a4ac6 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatetarget/AsyncUpdateTarget.java @@ -0,0 +1,51 @@ +/* + * 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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_updatetarget_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.Target; +import com.google.cloud.deploy.v1.UpdateTargetRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateTarget { + + public static void main(String[] args) throws Exception { + asyncUpdateTarget(); + } + + public static void asyncUpdateTarget() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + UpdateTargetRequest request = + UpdateTargetRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setTarget(Target.newBuilder().build()) + .setRequestId("requestId693933066") + .setAllowMissing(true) + .setValidateOnly(true) + .build(); + ApiFuture future = cloudDeployClient.updateTargetCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_updatetarget_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatetarget/AsyncUpdateTargetLRO.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatetarget/AsyncUpdateTargetLRO.java new file mode 100644 index 000000000000..ef5730fb2486 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatetarget/AsyncUpdateTargetLRO.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_updatetarget_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.OperationMetadata; +import com.google.cloud.deploy.v1.Target; +import com.google.cloud.deploy.v1.UpdateTargetRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateTargetLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateTargetLRO(); + } + + public static void asyncUpdateTargetLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + UpdateTargetRequest request = + UpdateTargetRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setTarget(Target.newBuilder().build()) + .setRequestId("requestId693933066") + .setAllowMissing(true) + .setValidateOnly(true) + .build(); + OperationFuture future = + cloudDeployClient.updateTargetOperationCallable().futureCall(request); + // Do something. + Target response = future.get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_updatetarget_lro_async] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatetarget/SyncUpdateTarget.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatetarget/SyncUpdateTarget.java new file mode 100644 index 000000000000..c5d8c9a8e555 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatetarget/SyncUpdateTarget.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_updatetarget_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.Target; +import com.google.cloud.deploy.v1.UpdateTargetRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateTarget { + + public static void main(String[] args) throws Exception { + syncUpdateTarget(); + } + + public static void syncUpdateTarget() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + UpdateTargetRequest request = + UpdateTargetRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setTarget(Target.newBuilder().build()) + .setRequestId("requestId693933066") + .setAllowMissing(true) + .setValidateOnly(true) + .build(); + Target response = cloudDeployClient.updateTargetAsync(request).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_updatetarget_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatetarget/SyncUpdateTargetTargetFieldmask.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatetarget/SyncUpdateTargetTargetFieldmask.java new file mode 100644 index 000000000000..af1b106f19fc --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeployclient/updatetarget/SyncUpdateTargetTargetFieldmask.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeployclient_updatetarget_targetfieldmask_sync] +import com.google.cloud.deploy.v1.CloudDeployClient; +import com.google.cloud.deploy.v1.Target; +import com.google.protobuf.FieldMask; + +public class SyncUpdateTargetTargetFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateTargetTargetFieldmask(); + } + + public static void syncUpdateTargetTargetFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudDeployClient cloudDeployClient = CloudDeployClient.create()) { + Target target = Target.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Target response = cloudDeployClient.updateTargetAsync(target, updateMask).get(); + } + } +} +// [END deploy_v1_generated_clouddeployclient_updatetarget_targetfieldmask_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeploysettings/getdeliverypipeline/SyncGetDeliveryPipeline.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeploysettings/getdeliverypipeline/SyncGetDeliveryPipeline.java new file mode 100644 index 000000000000..c7dfb62be9c2 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/clouddeploysettings/getdeliverypipeline/SyncGetDeliveryPipeline.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.deploy.v1.samples; + +// [START deploy_v1_generated_clouddeploysettings_getdeliverypipeline_sync] +import com.google.cloud.deploy.v1.CloudDeploySettings; +import java.time.Duration; + +public class SyncGetDeliveryPipeline { + + public static void main(String[] args) throws Exception { + syncGetDeliveryPipeline(); + } + + public static void syncGetDeliveryPipeline() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CloudDeploySettings.Builder cloudDeploySettingsBuilder = CloudDeploySettings.newBuilder(); + cloudDeploySettingsBuilder + .getDeliveryPipelineSettings() + .setRetrySettings( + cloudDeploySettingsBuilder + .getDeliveryPipelineSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CloudDeploySettings cloudDeploySettings = cloudDeploySettingsBuilder.build(); + } +} +// [END deploy_v1_generated_clouddeploysettings_getdeliverypipeline_sync] diff --git a/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/stub/clouddeploystubsettings/getdeliverypipeline/SyncGetDeliveryPipeline.java b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/stub/clouddeploystubsettings/getdeliverypipeline/SyncGetDeliveryPipeline.java new file mode 100644 index 000000000000..21f2a6001a20 --- /dev/null +++ b/java-deploy/samples/snippets/generated/com/google/cloud/deploy/v1/stub/clouddeploystubsettings/getdeliverypipeline/SyncGetDeliveryPipeline.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.deploy.v1.stub.samples; + +// [START deploy_v1_generated_clouddeploystubsettings_getdeliverypipeline_sync] +import com.google.cloud.deploy.v1.stub.CloudDeployStubSettings; +import java.time.Duration; + +public class SyncGetDeliveryPipeline { + + public static void main(String[] args) throws Exception { + syncGetDeliveryPipeline(); + } + + public static void syncGetDeliveryPipeline() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CloudDeployStubSettings.Builder cloudDeploySettingsBuilder = + CloudDeployStubSettings.newBuilder(); + cloudDeploySettingsBuilder + .getDeliveryPipelineSettings() + .setRetrySettings( + cloudDeploySettingsBuilder + .getDeliveryPipelineSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CloudDeployStubSettings cloudDeploySettings = cloudDeploySettingsBuilder.build(); + } +} +// [END deploy_v1_generated_clouddeploystubsettings_getdeliverypipeline_sync]