diff --git a/google-cloud-gke-backup/pom.xml b/google-cloud-gke-backup/pom.xml index 21424b6..94ae6ef 100644 --- a/google-cloud-gke-backup/pom.xml +++ b/google-cloud-gke-backup/pom.xml @@ -58,6 +58,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -77,12 +81,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/BackupForGKEClient.java b/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/BackupForGKEClient.java index df8883f..6b2f2b2 100644 --- a/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/BackupForGKEClient.java +++ b/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/BackupForGKEClient.java @@ -19,6 +19,7 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -30,7 +31,6 @@ import com.google.cloud.gkebackup.v1.stub.BackupForGKEStubSettings; 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; @@ -103,13 +103,28 @@ * BackupForGKEClient backupForGKEClient = BackupForGKEClient.create(backupForGKESettings); * } * + *

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.
+ * BackupForGKESettings backupForGKESettings =
+ *     BackupForGKESettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             BackupForGKESettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * BackupForGKEClient backupForGKEClient = BackupForGKEClient.create(backupForGKESettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class BackupForGKEClient implements BackgroundResource { private final BackupForGKESettings settings; private final BackupForGKEStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of BackupForGKEClient with default settings. */ public static final BackupForGKEClient create() throws IOException { @@ -140,13 +155,17 @@ public static final BackupForGKEClient create(BackupForGKEStub stub) { protected BackupForGKEClient(BackupForGKESettings settings) throws IOException { this.settings = settings; this.stub = ((BackupForGKEStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } protected BackupForGKEClient(BackupForGKEStub 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 BackupForGKESettings getSettings() { @@ -161,10 +180,18 @@ public BackupForGKEStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Creates a new BackupPlan in a given location. diff --git a/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/BackupForGKESettings.java b/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/BackupForGKESettings.java index 508b0df..c4202fe 100644 --- a/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/BackupForGKESettings.java +++ b/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/BackupForGKESettings.java @@ -28,6 +28,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; @@ -305,11 +306,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return BackupForGKEStubSettings.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 BackupForGKEStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return BackupForGKEStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return BackupForGKEStubSettings.defaultTransportChannelProvider(); } @@ -319,11 +327,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return BackupForGKEStubSettings.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); @@ -361,6 +375,11 @@ private static Builder createDefault() { return new Builder(BackupForGKEStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(BackupForGKEStubSettings.newHttpJsonBuilder()); + } + public BackupForGKEStubSettings.Builder getStubSettingsBuilder() { return ((BackupForGKEStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/stub/BackupForGKEStub.java b/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/stub/BackupForGKEStub.java index 6d23904..ebe803f 100644 --- a/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/stub/BackupForGKEStub.java +++ b/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/stub/BackupForGKEStub.java @@ -78,7 +78,11 @@ public abstract class BackupForGKEStub 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 OperationCallable diff --git a/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/stub/BackupForGKEStubSettings.java b/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/stub/BackupForGKEStubSettings.java index c3f7e52..854c954 100644 --- a/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/stub/BackupForGKEStubSettings.java +++ b/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/stub/BackupForGKEStubSettings.java @@ -33,6 +33,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; @@ -748,6 +751,11 @@ public BackupForGKEStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcBackupForGKEStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonBackupForGKEStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -780,18 +788,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(BackupForGKEStubSettings.class)) @@ -799,11 +814,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(BackupForGKEStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return BackupForGKEStubSettings.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); @@ -1149,6 +1183,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 .createBackupPlanSettings() diff --git a/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/stub/HttpJsonBackupForGKECallableFactory.java b/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/stub/HttpJsonBackupForGKECallableFactory.java new file mode 100644 index 0000000..b8fe504 --- /dev/null +++ b/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/stub/HttpJsonBackupForGKECallableFactory.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.gkebackup.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 BackupForGKE service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonBackupForGKECallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/stub/HttpJsonBackupForGKEStub.java b/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/stub/HttpJsonBackupForGKEStub.java new file mode 100644 index 0000000..a726aa1 --- /dev/null +++ b/google-cloud-gke-backup/src/main/java/com/google/cloud/gkebackup/v1/stub/HttpJsonBackupForGKEStub.java @@ -0,0 +1,1713 @@ +/* + * 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.gkebackup.v1.stub; + +import static com.google.cloud.gkebackup.v1.BackupForGKEClient.ListBackupPlansPagedResponse; +import static com.google.cloud.gkebackup.v1.BackupForGKEClient.ListBackupsPagedResponse; +import static com.google.cloud.gkebackup.v1.BackupForGKEClient.ListRestorePlansPagedResponse; +import static com.google.cloud.gkebackup.v1.BackupForGKEClient.ListRestoresPagedResponse; +import static com.google.cloud.gkebackup.v1.BackupForGKEClient.ListVolumeBackupsPagedResponse; +import static com.google.cloud.gkebackup.v1.BackupForGKEClient.ListVolumeRestoresPagedResponse; + +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.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.CreateBackupPlanRequest; +import com.google.cloud.gkebackup.v1.CreateBackupRequest; +import com.google.cloud.gkebackup.v1.CreateRestorePlanRequest; +import com.google.cloud.gkebackup.v1.CreateRestoreRequest; +import com.google.cloud.gkebackup.v1.DeleteBackupPlanRequest; +import com.google.cloud.gkebackup.v1.DeleteBackupRequest; +import com.google.cloud.gkebackup.v1.DeleteRestorePlanRequest; +import com.google.cloud.gkebackup.v1.DeleteRestoreRequest; +import com.google.cloud.gkebackup.v1.GetBackupPlanRequest; +import com.google.cloud.gkebackup.v1.GetBackupRequest; +import com.google.cloud.gkebackup.v1.GetRestorePlanRequest; +import com.google.cloud.gkebackup.v1.GetRestoreRequest; +import com.google.cloud.gkebackup.v1.GetVolumeBackupRequest; +import com.google.cloud.gkebackup.v1.GetVolumeRestoreRequest; +import com.google.cloud.gkebackup.v1.ListBackupPlansRequest; +import com.google.cloud.gkebackup.v1.ListBackupPlansResponse; +import com.google.cloud.gkebackup.v1.ListBackupsRequest; +import com.google.cloud.gkebackup.v1.ListBackupsResponse; +import com.google.cloud.gkebackup.v1.ListRestorePlansRequest; +import com.google.cloud.gkebackup.v1.ListRestorePlansResponse; +import com.google.cloud.gkebackup.v1.ListRestoresRequest; +import com.google.cloud.gkebackup.v1.ListRestoresResponse; +import com.google.cloud.gkebackup.v1.ListVolumeBackupsRequest; +import com.google.cloud.gkebackup.v1.ListVolumeBackupsResponse; +import com.google.cloud.gkebackup.v1.ListVolumeRestoresRequest; +import com.google.cloud.gkebackup.v1.ListVolumeRestoresResponse; +import com.google.cloud.gkebackup.v1.OperationMetadata; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestorePlan; +import com.google.cloud.gkebackup.v1.UpdateBackupPlanRequest; +import com.google.cloud.gkebackup.v1.UpdateBackupRequest; +import com.google.cloud.gkebackup.v1.UpdateRestorePlanRequest; +import com.google.cloud.gkebackup.v1.UpdateRestoreRequest; +import com.google.cloud.gkebackup.v1.VolumeBackup; +import com.google.cloud.gkebackup.v1.VolumeRestore; +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 BackupForGKE service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonBackupForGKEStub extends BackupForGKEStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(BackupPlan.getDescriptor()) + .add(Empty.getDescriptor()) + .add(Restore.getDescriptor()) + .add(RestorePlan.getDescriptor()) + .add(Backup.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createBackupPlanMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/CreateBackupPlan") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/backupPlans", + 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, "backupPlanId", request.getBackupPlanId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("backupPlan", request.getBackupPlan())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateBackupPlanRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listBackupPlansMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/ListBackupPlans") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/backupPlans", + 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(ListBackupPlansResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getBackupPlanMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/GetBackupPlan") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/backupPlans/*}", + 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(BackupPlan.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateBackupPlanMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/UpdateBackupPlan") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{backupPlan.name=projects/*/locations/*/backupPlans/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "backupPlan.name", request.getBackupPlan().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("backupPlan", request.getBackupPlan())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateBackupPlanRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteBackupPlanMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/DeleteBackupPlan") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/backupPlans/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "etag", request.getEtag()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteBackupPlanRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + createBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/CreateBackup") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/backupPlans/*}/backups", + 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, "backupId", request.getBackupId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("backup", request.getBackup())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateBackupRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listBackupsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/ListBackups") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/backupPlans/*}/backups", + 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(ListBackupsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/GetBackup") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/backupPlans/*/backups/*}", + 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(Backup.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/UpdateBackup") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{backup.name=projects/*/locations/*/backupPlans/*/backups/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "backup.name", request.getBackup().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("backup", request.getBackup())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateBackupRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/DeleteBackup") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/backupPlans/*/backups/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "etag", request.getEtag()); + serializer.putQueryParam(fields, "force", request.getForce()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteBackupRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listVolumeBackupsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/ListVolumeBackups") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/backupPlans/*/backups/*}/volumeBackups", + 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(ListVolumeBackupsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getVolumeBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/GetVolumeBackup") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/backupPlans/*/backups/*/volumeBackups/*}", + 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(VolumeBackup.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createRestorePlanMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/CreateRestorePlan") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/restorePlans", + 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, "restorePlanId", request.getRestorePlanId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("restorePlan", request.getRestorePlan())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateRestorePlanRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listRestorePlansMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/ListRestorePlans") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/restorePlans", + 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(ListRestorePlansResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getRestorePlanMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/GetRestorePlan") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/restorePlans/*}", + 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(RestorePlan.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateRestorePlanMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/UpdateRestorePlan") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{restorePlan.name=projects/*/locations/*/restorePlans/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "restorePlan.name", request.getRestorePlan().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("restorePlan", request.getRestorePlan())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateRestorePlanRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteRestorePlanMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/DeleteRestorePlan") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/restorePlans/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "etag", request.getEtag()); + serializer.putQueryParam(fields, "force", request.getForce()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteRestorePlanRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + createRestoreMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/CreateRestore") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/restorePlans/*}/restores", + 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, "restoreId", request.getRestoreId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("restore", request.getRestore())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateRestoreRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listRestoresMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/ListRestores") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/restorePlans/*}/restores", + 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(ListRestoresResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getRestoreMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/GetRestore") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/restorePlans/*/restores/*}", + 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(Restore.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + updateRestoreMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/UpdateRestore") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{restore.name=projects/*/locations/*/restorePlans/*/restores/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "restore.name", request.getRestore().getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "updateMask", request.getUpdateMask()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create().toBody("restore", request.getRestore())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateRestoreRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteRestoreMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/DeleteRestore") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/restorePlans/*/restores/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putQueryParam(fields, "etag", request.getEtag()); + serializer.putQueryParam(fields, "force", request.getForce()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteRestoreRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listVolumeRestoresMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/ListVolumeRestores") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/restorePlans/*/restores/*}/volumeRestores", + 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(ListVolumeRestoresResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getVolumeRestoreMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.gkebackup.v1.BackupForGKE/GetVolumeRestore") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/restorePlans/*/restores/*/volumeRestores/*}", + 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(VolumeRestore.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable createBackupPlanCallable; + private final OperationCallable + createBackupPlanOperationCallable; + private final UnaryCallable + listBackupPlansCallable; + private final UnaryCallable + listBackupPlansPagedCallable; + private final UnaryCallable getBackupPlanCallable; + private final UnaryCallable updateBackupPlanCallable; + private final OperationCallable + updateBackupPlanOperationCallable; + private final UnaryCallable deleteBackupPlanCallable; + private final OperationCallable + deleteBackupPlanOperationCallable; + private final UnaryCallable createBackupCallable; + private final OperationCallable + createBackupOperationCallable; + private final UnaryCallable listBackupsCallable; + private final UnaryCallable + listBackupsPagedCallable; + private final UnaryCallable getBackupCallable; + private final UnaryCallable updateBackupCallable; + private final OperationCallable + updateBackupOperationCallable; + private final UnaryCallable deleteBackupCallable; + private final OperationCallable + deleteBackupOperationCallable; + private final UnaryCallable + listVolumeBackupsCallable; + private final UnaryCallable + listVolumeBackupsPagedCallable; + private final UnaryCallable getVolumeBackupCallable; + private final UnaryCallable createRestorePlanCallable; + private final OperationCallable + createRestorePlanOperationCallable; + private final UnaryCallable + listRestorePlansCallable; + private final UnaryCallable + listRestorePlansPagedCallable; + private final UnaryCallable getRestorePlanCallable; + private final UnaryCallable updateRestorePlanCallable; + private final OperationCallable + updateRestorePlanOperationCallable; + private final UnaryCallable deleteRestorePlanCallable; + private final OperationCallable + deleteRestorePlanOperationCallable; + private final UnaryCallable createRestoreCallable; + private final OperationCallable + createRestoreOperationCallable; + private final UnaryCallable listRestoresCallable; + private final UnaryCallable + listRestoresPagedCallable; + private final UnaryCallable getRestoreCallable; + private final UnaryCallable updateRestoreCallable; + private final OperationCallable + updateRestoreOperationCallable; + private final UnaryCallable deleteRestoreCallable; + private final OperationCallable + deleteRestoreOperationCallable; + private final UnaryCallable + listVolumeRestoresCallable; + private final UnaryCallable + listVolumeRestoresPagedCallable; + private final UnaryCallable getVolumeRestoreCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonBackupForGKEStub create(BackupForGKEStubSettings settings) + throws IOException { + return new HttpJsonBackupForGKEStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonBackupForGKEStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonBackupForGKEStub( + BackupForGKEStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonBackupForGKEStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonBackupForGKEStub( + BackupForGKEStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonBackupForGKEStub, 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 HttpJsonBackupForGKEStub(BackupForGKEStubSettings settings, ClientContext clientContext) + throws IOException { + this(settings, clientContext, new HttpJsonBackupForGKECallableFactory()); + } + + /** + * Constructs an instance of HttpJsonBackupForGKEStub, 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 HttpJsonBackupForGKEStub( + BackupForGKEStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings createBackupPlanTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createBackupPlanMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listBackupPlansTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listBackupPlansMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getBackupPlanTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBackupPlanMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateBackupPlanTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateBackupPlanMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteBackupPlanTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteBackupPlanMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listBackupsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listBackupsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listVolumeBackupsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listVolumeBackupsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getVolumeBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getVolumeBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createRestorePlanTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createRestorePlanMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listRestorePlansTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listRestorePlansMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getRestorePlanTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getRestorePlanMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateRestorePlanTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateRestorePlanMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteRestorePlanTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteRestorePlanMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createRestoreTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createRestoreMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listRestoresTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listRestoresMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getRestoreTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getRestoreMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateRestoreTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateRestoreMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteRestoreTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteRestoreMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listVolumeRestoresTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listVolumeRestoresMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getVolumeRestoreTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getVolumeRestoreMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createBackupPlanCallable = + callableFactory.createUnaryCallable( + createBackupPlanTransportSettings, settings.createBackupPlanSettings(), clientContext); + this.createBackupPlanOperationCallable = + callableFactory.createOperationCallable( + createBackupPlanTransportSettings, + settings.createBackupPlanOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listBackupPlansCallable = + callableFactory.createUnaryCallable( + listBackupPlansTransportSettings, settings.listBackupPlansSettings(), clientContext); + this.listBackupPlansPagedCallable = + callableFactory.createPagedCallable( + listBackupPlansTransportSettings, settings.listBackupPlansSettings(), clientContext); + this.getBackupPlanCallable = + callableFactory.createUnaryCallable( + getBackupPlanTransportSettings, settings.getBackupPlanSettings(), clientContext); + this.updateBackupPlanCallable = + callableFactory.createUnaryCallable( + updateBackupPlanTransportSettings, settings.updateBackupPlanSettings(), clientContext); + this.updateBackupPlanOperationCallable = + callableFactory.createOperationCallable( + updateBackupPlanTransportSettings, + settings.updateBackupPlanOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteBackupPlanCallable = + callableFactory.createUnaryCallable( + deleteBackupPlanTransportSettings, settings.deleteBackupPlanSettings(), clientContext); + this.deleteBackupPlanOperationCallable = + callableFactory.createOperationCallable( + deleteBackupPlanTransportSettings, + settings.deleteBackupPlanOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.createBackupCallable = + callableFactory.createUnaryCallable( + createBackupTransportSettings, settings.createBackupSettings(), clientContext); + this.createBackupOperationCallable = + callableFactory.createOperationCallable( + createBackupTransportSettings, + settings.createBackupOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listBackupsCallable = + callableFactory.createUnaryCallable( + listBackupsTransportSettings, settings.listBackupsSettings(), clientContext); + this.listBackupsPagedCallable = + callableFactory.createPagedCallable( + listBackupsTransportSettings, settings.listBackupsSettings(), clientContext); + this.getBackupCallable = + callableFactory.createUnaryCallable( + getBackupTransportSettings, settings.getBackupSettings(), clientContext); + this.updateBackupCallable = + callableFactory.createUnaryCallable( + updateBackupTransportSettings, settings.updateBackupSettings(), clientContext); + this.updateBackupOperationCallable = + callableFactory.createOperationCallable( + updateBackupTransportSettings, + settings.updateBackupOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteBackupCallable = + callableFactory.createUnaryCallable( + deleteBackupTransportSettings, settings.deleteBackupSettings(), clientContext); + this.deleteBackupOperationCallable = + callableFactory.createOperationCallable( + deleteBackupTransportSettings, + settings.deleteBackupOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listVolumeBackupsCallable = + callableFactory.createUnaryCallable( + listVolumeBackupsTransportSettings, + settings.listVolumeBackupsSettings(), + clientContext); + this.listVolumeBackupsPagedCallable = + callableFactory.createPagedCallable( + listVolumeBackupsTransportSettings, + settings.listVolumeBackupsSettings(), + clientContext); + this.getVolumeBackupCallable = + callableFactory.createUnaryCallable( + getVolumeBackupTransportSettings, settings.getVolumeBackupSettings(), clientContext); + this.createRestorePlanCallable = + callableFactory.createUnaryCallable( + createRestorePlanTransportSettings, + settings.createRestorePlanSettings(), + clientContext); + this.createRestorePlanOperationCallable = + callableFactory.createOperationCallable( + createRestorePlanTransportSettings, + settings.createRestorePlanOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listRestorePlansCallable = + callableFactory.createUnaryCallable( + listRestorePlansTransportSettings, settings.listRestorePlansSettings(), clientContext); + this.listRestorePlansPagedCallable = + callableFactory.createPagedCallable( + listRestorePlansTransportSettings, settings.listRestorePlansSettings(), clientContext); + this.getRestorePlanCallable = + callableFactory.createUnaryCallable( + getRestorePlanTransportSettings, settings.getRestorePlanSettings(), clientContext); + this.updateRestorePlanCallable = + callableFactory.createUnaryCallable( + updateRestorePlanTransportSettings, + settings.updateRestorePlanSettings(), + clientContext); + this.updateRestorePlanOperationCallable = + callableFactory.createOperationCallable( + updateRestorePlanTransportSettings, + settings.updateRestorePlanOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteRestorePlanCallable = + callableFactory.createUnaryCallable( + deleteRestorePlanTransportSettings, + settings.deleteRestorePlanSettings(), + clientContext); + this.deleteRestorePlanOperationCallable = + callableFactory.createOperationCallable( + deleteRestorePlanTransportSettings, + settings.deleteRestorePlanOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.createRestoreCallable = + callableFactory.createUnaryCallable( + createRestoreTransportSettings, settings.createRestoreSettings(), clientContext); + this.createRestoreOperationCallable = + callableFactory.createOperationCallable( + createRestoreTransportSettings, + settings.createRestoreOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listRestoresCallable = + callableFactory.createUnaryCallable( + listRestoresTransportSettings, settings.listRestoresSettings(), clientContext); + this.listRestoresPagedCallable = + callableFactory.createPagedCallable( + listRestoresTransportSettings, settings.listRestoresSettings(), clientContext); + this.getRestoreCallable = + callableFactory.createUnaryCallable( + getRestoreTransportSettings, settings.getRestoreSettings(), clientContext); + this.updateRestoreCallable = + callableFactory.createUnaryCallable( + updateRestoreTransportSettings, settings.updateRestoreSettings(), clientContext); + this.updateRestoreOperationCallable = + callableFactory.createOperationCallable( + updateRestoreTransportSettings, + settings.updateRestoreOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteRestoreCallable = + callableFactory.createUnaryCallable( + deleteRestoreTransportSettings, settings.deleteRestoreSettings(), clientContext); + this.deleteRestoreOperationCallable = + callableFactory.createOperationCallable( + deleteRestoreTransportSettings, + settings.deleteRestoreOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.listVolumeRestoresCallable = + callableFactory.createUnaryCallable( + listVolumeRestoresTransportSettings, + settings.listVolumeRestoresSettings(), + clientContext); + this.listVolumeRestoresPagedCallable = + callableFactory.createPagedCallable( + listVolumeRestoresTransportSettings, + settings.listVolumeRestoresSettings(), + clientContext); + this.getVolumeRestoreCallable = + callableFactory.createUnaryCallable( + getVolumeRestoreTransportSettings, settings.getVolumeRestoreSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createBackupPlanMethodDescriptor); + methodDescriptors.add(listBackupPlansMethodDescriptor); + methodDescriptors.add(getBackupPlanMethodDescriptor); + methodDescriptors.add(updateBackupPlanMethodDescriptor); + methodDescriptors.add(deleteBackupPlanMethodDescriptor); + methodDescriptors.add(createBackupMethodDescriptor); + methodDescriptors.add(listBackupsMethodDescriptor); + methodDescriptors.add(getBackupMethodDescriptor); + methodDescriptors.add(updateBackupMethodDescriptor); + methodDescriptors.add(deleteBackupMethodDescriptor); + methodDescriptors.add(listVolumeBackupsMethodDescriptor); + methodDescriptors.add(getVolumeBackupMethodDescriptor); + methodDescriptors.add(createRestorePlanMethodDescriptor); + methodDescriptors.add(listRestorePlansMethodDescriptor); + methodDescriptors.add(getRestorePlanMethodDescriptor); + methodDescriptors.add(updateRestorePlanMethodDescriptor); + methodDescriptors.add(deleteRestorePlanMethodDescriptor); + methodDescriptors.add(createRestoreMethodDescriptor); + methodDescriptors.add(listRestoresMethodDescriptor); + methodDescriptors.add(getRestoreMethodDescriptor); + methodDescriptors.add(updateRestoreMethodDescriptor); + methodDescriptors.add(deleteRestoreMethodDescriptor); + methodDescriptors.add(listVolumeRestoresMethodDescriptor); + methodDescriptors.add(getVolumeRestoreMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable createBackupPlanCallable() { + return createBackupPlanCallable; + } + + @Override + public OperationCallable + createBackupPlanOperationCallable() { + return createBackupPlanOperationCallable; + } + + @Override + public UnaryCallable listBackupPlansCallable() { + return listBackupPlansCallable; + } + + @Override + public UnaryCallable + listBackupPlansPagedCallable() { + return listBackupPlansPagedCallable; + } + + @Override + public UnaryCallable getBackupPlanCallable() { + return getBackupPlanCallable; + } + + @Override + public UnaryCallable updateBackupPlanCallable() { + return updateBackupPlanCallable; + } + + @Override + public OperationCallable + updateBackupPlanOperationCallable() { + return updateBackupPlanOperationCallable; + } + + @Override + public UnaryCallable deleteBackupPlanCallable() { + return deleteBackupPlanCallable; + } + + @Override + public OperationCallable + deleteBackupPlanOperationCallable() { + return deleteBackupPlanOperationCallable; + } + + @Override + public UnaryCallable createBackupCallable() { + return createBackupCallable; + } + + @Override + public OperationCallable + createBackupOperationCallable() { + return createBackupOperationCallable; + } + + @Override + public UnaryCallable listBackupsCallable() { + return listBackupsCallable; + } + + @Override + public UnaryCallable listBackupsPagedCallable() { + return listBackupsPagedCallable; + } + + @Override + public UnaryCallable getBackupCallable() { + return getBackupCallable; + } + + @Override + public UnaryCallable updateBackupCallable() { + return updateBackupCallable; + } + + @Override + public OperationCallable + updateBackupOperationCallable() { + return updateBackupOperationCallable; + } + + @Override + public UnaryCallable deleteBackupCallable() { + return deleteBackupCallable; + } + + @Override + public OperationCallable + deleteBackupOperationCallable() { + return deleteBackupOperationCallable; + } + + @Override + public UnaryCallable + listVolumeBackupsCallable() { + return listVolumeBackupsCallable; + } + + @Override + public UnaryCallable + listVolumeBackupsPagedCallable() { + return listVolumeBackupsPagedCallable; + } + + @Override + public UnaryCallable getVolumeBackupCallable() { + return getVolumeBackupCallable; + } + + @Override + public UnaryCallable createRestorePlanCallable() { + return createRestorePlanCallable; + } + + @Override + public OperationCallable + createRestorePlanOperationCallable() { + return createRestorePlanOperationCallable; + } + + @Override + public UnaryCallable + listRestorePlansCallable() { + return listRestorePlansCallable; + } + + @Override + public UnaryCallable + listRestorePlansPagedCallable() { + return listRestorePlansPagedCallable; + } + + @Override + public UnaryCallable getRestorePlanCallable() { + return getRestorePlanCallable; + } + + @Override + public UnaryCallable updateRestorePlanCallable() { + return updateRestorePlanCallable; + } + + @Override + public OperationCallable + updateRestorePlanOperationCallable() { + return updateRestorePlanOperationCallable; + } + + @Override + public UnaryCallable deleteRestorePlanCallable() { + return deleteRestorePlanCallable; + } + + @Override + public OperationCallable + deleteRestorePlanOperationCallable() { + return deleteRestorePlanOperationCallable; + } + + @Override + public UnaryCallable createRestoreCallable() { + return createRestoreCallable; + } + + @Override + public OperationCallable + createRestoreOperationCallable() { + return createRestoreOperationCallable; + } + + @Override + public UnaryCallable listRestoresCallable() { + return listRestoresCallable; + } + + @Override + public UnaryCallable listRestoresPagedCallable() { + return listRestoresPagedCallable; + } + + @Override + public UnaryCallable getRestoreCallable() { + return getRestoreCallable; + } + + @Override + public UnaryCallable updateRestoreCallable() { + return updateRestoreCallable; + } + + @Override + public OperationCallable + updateRestoreOperationCallable() { + return updateRestoreOperationCallable; + } + + @Override + public UnaryCallable deleteRestoreCallable() { + return deleteRestoreCallable; + } + + @Override + public OperationCallable + deleteRestoreOperationCallable() { + return deleteRestoreOperationCallable; + } + + @Override + public UnaryCallable + listVolumeRestoresCallable() { + return listVolumeRestoresCallable; + } + + @Override + public UnaryCallable + listVolumeRestoresPagedCallable() { + return listVolumeRestoresPagedCallable; + } + + @Override + public UnaryCallable getVolumeRestoreCallable() { + return getVolumeRestoreCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/google-cloud-gke-backup/src/test/java/com/google/cloud/gkebackup/v1/BackupForGKEClientHttpJsonTest.java b/google-cloud-gke-backup/src/test/java/com/google/cloud/gkebackup/v1/BackupForGKEClientHttpJsonTest.java new file mode 100644 index 0000000..c534baa --- /dev/null +++ b/google-cloud-gke-backup/src/test/java/com/google/cloud/gkebackup/v1/BackupForGKEClientHttpJsonTest.java @@ -0,0 +1,2744 @@ +/* + * 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.gkebackup.v1; + +import static com.google.cloud.gkebackup.v1.BackupForGKEClient.ListBackupPlansPagedResponse; +import static com.google.cloud.gkebackup.v1.BackupForGKEClient.ListBackupsPagedResponse; +import static com.google.cloud.gkebackup.v1.BackupForGKEClient.ListRestorePlansPagedResponse; +import static com.google.cloud.gkebackup.v1.BackupForGKEClient.ListRestoresPagedResponse; +import static com.google.cloud.gkebackup.v1.BackupForGKEClient.ListVolumeBackupsPagedResponse; +import static com.google.cloud.gkebackup.v1.BackupForGKEClient.ListVolumeRestoresPagedResponse; + +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.gkebackup.v1.stub.HttpJsonBackupForGKEStub; +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.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 BackupForGKEClientHttpJsonTest { + private static MockHttpService mockService; + private static BackupForGKEClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonBackupForGKEStub.getMethodDescriptors(), + BackupForGKESettings.getDefaultEndpoint()); + BackupForGKESettings settings = + BackupForGKESettings.newHttpJsonBuilder() + .setTransportChannelProvider( + BackupForGKESettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = BackupForGKEClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createBackupPlanTest() throws Exception { + BackupPlan expectedResponse = + BackupPlan.newBuilder() + .setName(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setCluster("cluster872092154") + .setRetentionPolicy(BackupPlan.RetentionPolicy.newBuilder().build()) + .putAllLabels(new HashMap()) + .setBackupSchedule(BackupPlan.Schedule.newBuilder().build()) + .setEtag("etag3123477") + .setDeactivated(true) + .setBackupConfig(BackupPlan.BackupConfig.newBuilder().build()) + .setProtectedPodCount(-1494678716) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createBackupPlanTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + BackupPlan backupPlan = BackupPlan.newBuilder().build(); + String backupPlanId = "backupPlanId-84871546"; + + BackupPlan actualResponse = + client.createBackupPlanAsync(parent, backupPlan, backupPlanId).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 createBackupPlanExceptionTest() 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]"); + BackupPlan backupPlan = BackupPlan.newBuilder().build(); + String backupPlanId = "backupPlanId-84871546"; + client.createBackupPlanAsync(parent, backupPlan, backupPlanId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createBackupPlanTest2() throws Exception { + BackupPlan expectedResponse = + BackupPlan.newBuilder() + .setName(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setCluster("cluster872092154") + .setRetentionPolicy(BackupPlan.RetentionPolicy.newBuilder().build()) + .putAllLabels(new HashMap()) + .setBackupSchedule(BackupPlan.Schedule.newBuilder().build()) + .setEtag("etag3123477") + .setDeactivated(true) + .setBackupConfig(BackupPlan.BackupConfig.newBuilder().build()) + .setProtectedPodCount(-1494678716) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createBackupPlanTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + BackupPlan backupPlan = BackupPlan.newBuilder().build(); + String backupPlanId = "backupPlanId-84871546"; + + BackupPlan actualResponse = + client.createBackupPlanAsync(parent, backupPlan, backupPlanId).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 createBackupPlanExceptionTest2() 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"; + BackupPlan backupPlan = BackupPlan.newBuilder().build(); + String backupPlanId = "backupPlanId-84871546"; + client.createBackupPlanAsync(parent, backupPlan, backupPlanId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listBackupPlansTest() throws Exception { + BackupPlan responsesElement = BackupPlan.newBuilder().build(); + ListBackupPlansResponse expectedResponse = + ListBackupPlansResponse.newBuilder() + .setNextPageToken("") + .addAllBackupPlans(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListBackupPlansPagedResponse pagedListResponse = client.listBackupPlans(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getBackupPlansList().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 listBackupPlansExceptionTest() 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.listBackupPlans(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupPlansTest2() throws Exception { + BackupPlan responsesElement = BackupPlan.newBuilder().build(); + ListBackupPlansResponse expectedResponse = + ListBackupPlansResponse.newBuilder() + .setNextPageToken("") + .addAllBackupPlans(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListBackupPlansPagedResponse pagedListResponse = client.listBackupPlans(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getBackupPlansList().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 listBackupPlansExceptionTest2() 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.listBackupPlans(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupPlanTest() throws Exception { + BackupPlan expectedResponse = + BackupPlan.newBuilder() + .setName(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setCluster("cluster872092154") + .setRetentionPolicy(BackupPlan.RetentionPolicy.newBuilder().build()) + .putAllLabels(new HashMap()) + .setBackupSchedule(BackupPlan.Schedule.newBuilder().build()) + .setEtag("etag3123477") + .setDeactivated(true) + .setBackupConfig(BackupPlan.BackupConfig.newBuilder().build()) + .setProtectedPodCount(-1494678716) + .build(); + mockService.addResponse(expectedResponse); + + BackupPlanName name = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]"); + + BackupPlan actualResponse = client.getBackupPlan(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 getBackupPlanExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupPlanName name = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]"); + client.getBackupPlan(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupPlanTest2() throws Exception { + BackupPlan expectedResponse = + BackupPlan.newBuilder() + .setName(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setCluster("cluster872092154") + .setRetentionPolicy(BackupPlan.RetentionPolicy.newBuilder().build()) + .putAllLabels(new HashMap()) + .setBackupSchedule(BackupPlan.Schedule.newBuilder().build()) + .setEtag("etag3123477") + .setDeactivated(true) + .setBackupConfig(BackupPlan.BackupConfig.newBuilder().build()) + .setProtectedPodCount(-1494678716) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3970/locations/location-3970/backupPlans/backupPlan-3970"; + + BackupPlan actualResponse = client.getBackupPlan(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 getBackupPlanExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3970/locations/location-3970/backupPlans/backupPlan-3970"; + client.getBackupPlan(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateBackupPlanTest() throws Exception { + BackupPlan expectedResponse = + BackupPlan.newBuilder() + .setName(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setCluster("cluster872092154") + .setRetentionPolicy(BackupPlan.RetentionPolicy.newBuilder().build()) + .putAllLabels(new HashMap()) + .setBackupSchedule(BackupPlan.Schedule.newBuilder().build()) + .setEtag("etag3123477") + .setDeactivated(true) + .setBackupConfig(BackupPlan.BackupConfig.newBuilder().build()) + .setProtectedPodCount(-1494678716) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateBackupPlanTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + BackupPlan backupPlan = + BackupPlan.newBuilder() + .setName(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setCluster("cluster872092154") + .setRetentionPolicy(BackupPlan.RetentionPolicy.newBuilder().build()) + .putAllLabels(new HashMap()) + .setBackupSchedule(BackupPlan.Schedule.newBuilder().build()) + .setEtag("etag3123477") + .setDeactivated(true) + .setBackupConfig(BackupPlan.BackupConfig.newBuilder().build()) + .setProtectedPodCount(-1494678716) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + BackupPlan actualResponse = client.updateBackupPlanAsync(backupPlan, 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 updateBackupPlanExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupPlan backupPlan = + BackupPlan.newBuilder() + .setName(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setCluster("cluster872092154") + .setRetentionPolicy(BackupPlan.RetentionPolicy.newBuilder().build()) + .putAllLabels(new HashMap()) + .setBackupSchedule(BackupPlan.Schedule.newBuilder().build()) + .setEtag("etag3123477") + .setDeactivated(true) + .setBackupConfig(BackupPlan.BackupConfig.newBuilder().build()) + .setProtectedPodCount(-1494678716) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateBackupPlanAsync(backupPlan, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteBackupPlanTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteBackupPlanTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + BackupPlanName name = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]"); + + client.deleteBackupPlanAsync(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 deleteBackupPlanExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupPlanName name = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]"); + client.deleteBackupPlanAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteBackupPlanTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteBackupPlanTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-3970/locations/location-3970/backupPlans/backupPlan-3970"; + + client.deleteBackupPlanAsync(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 deleteBackupPlanExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3970/locations/location-3970/backupPlans/backupPlan-3970"; + client.deleteBackupPlanAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createBackupTest() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setManual(true) + .putAllLabels(new HashMap()) + .setDeleteLockDays(-1638724265) + .setDeleteLockExpireTime(Timestamp.newBuilder().build()) + .setRetainDays(-1380805807) + .setRetainExpireTime(Timestamp.newBuilder().build()) + .setEncryptionKey(EncryptionKey.newBuilder().build()) + .setContainsVolumeData(true) + .setContainsSecrets(true) + .setClusterMetadata(Backup.ClusterMetadata.newBuilder().build()) + .setStateReason("stateReason1148834357") + .setCompleteTime(Timestamp.newBuilder().build()) + .setResourceCount(287552926) + .setVolumeCount(-1362665558) + .setSizeBytes(-1796325715) + .setEtag("etag3123477") + .setDescription("description-1724546052") + .setPodCount(977657493) + .setConfigBackupSizeBytes(-606785139) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createBackupTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + BackupPlanName parent = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]"); + Backup backup = Backup.newBuilder().build(); + String backupId = "backupId2121930365"; + + Backup actualResponse = client.createBackupAsync(parent, backup, backupId).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 createBackupExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupPlanName parent = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]"); + Backup backup = Backup.newBuilder().build(); + String backupId = "backupId2121930365"; + client.createBackupAsync(parent, backup, backupId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createBackupTest2() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setManual(true) + .putAllLabels(new HashMap()) + .setDeleteLockDays(-1638724265) + .setDeleteLockExpireTime(Timestamp.newBuilder().build()) + .setRetainDays(-1380805807) + .setRetainExpireTime(Timestamp.newBuilder().build()) + .setEncryptionKey(EncryptionKey.newBuilder().build()) + .setContainsVolumeData(true) + .setContainsSecrets(true) + .setClusterMetadata(Backup.ClusterMetadata.newBuilder().build()) + .setStateReason("stateReason1148834357") + .setCompleteTime(Timestamp.newBuilder().build()) + .setResourceCount(287552926) + .setVolumeCount(-1362665558) + .setSizeBytes(-1796325715) + .setEtag("etag3123477") + .setDescription("description-1724546052") + .setPodCount(977657493) + .setConfigBackupSizeBytes(-606785139) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createBackupTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-4819/locations/location-4819/backupPlans/backupPlan-4819"; + Backup backup = Backup.newBuilder().build(); + String backupId = "backupId2121930365"; + + Backup actualResponse = client.createBackupAsync(parent, backup, backupId).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 createBackupExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-4819/locations/location-4819/backupPlans/backupPlan-4819"; + Backup backup = Backup.newBuilder().build(); + String backupId = "backupId2121930365"; + client.createBackupAsync(parent, backup, backupId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listBackupsTest() throws Exception { + Backup responsesElement = Backup.newBuilder().build(); + ListBackupsResponse expectedResponse = + ListBackupsResponse.newBuilder() + .setNextPageToken("") + .addAllBackups(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + BackupPlanName parent = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]"); + + ListBackupsPagedResponse pagedListResponse = client.listBackups(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getBackupsList().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 listBackupsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupPlanName parent = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]"); + client.listBackups(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listBackupsTest2() throws Exception { + Backup responsesElement = Backup.newBuilder().build(); + ListBackupsResponse expectedResponse = + ListBackupsResponse.newBuilder() + .setNextPageToken("") + .addAllBackups(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-4819/locations/location-4819/backupPlans/backupPlan-4819"; + + ListBackupsPagedResponse pagedListResponse = client.listBackups(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getBackupsList().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 listBackupsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-4819/locations/location-4819/backupPlans/backupPlan-4819"; + client.listBackups(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupTest() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setManual(true) + .putAllLabels(new HashMap()) + .setDeleteLockDays(-1638724265) + .setDeleteLockExpireTime(Timestamp.newBuilder().build()) + .setRetainDays(-1380805807) + .setRetainExpireTime(Timestamp.newBuilder().build()) + .setEncryptionKey(EncryptionKey.newBuilder().build()) + .setContainsVolumeData(true) + .setContainsSecrets(true) + .setClusterMetadata(Backup.ClusterMetadata.newBuilder().build()) + .setStateReason("stateReason1148834357") + .setCompleteTime(Timestamp.newBuilder().build()) + .setResourceCount(287552926) + .setVolumeCount(-1362665558) + .setSizeBytes(-1796325715) + .setEtag("etag3123477") + .setDescription("description-1724546052") + .setPodCount(977657493) + .setConfigBackupSizeBytes(-606785139) + .build(); + mockService.addResponse(expectedResponse); + + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]"); + + Backup actualResponse = client.getBackup(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 getBackupExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]"); + client.getBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getBackupTest2() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setManual(true) + .putAllLabels(new HashMap()) + .setDeleteLockDays(-1638724265) + .setDeleteLockExpireTime(Timestamp.newBuilder().build()) + .setRetainDays(-1380805807) + .setRetainExpireTime(Timestamp.newBuilder().build()) + .setEncryptionKey(EncryptionKey.newBuilder().build()) + .setContainsVolumeData(true) + .setContainsSecrets(true) + .setClusterMetadata(Backup.ClusterMetadata.newBuilder().build()) + .setStateReason("stateReason1148834357") + .setCompleteTime(Timestamp.newBuilder().build()) + .setResourceCount(287552926) + .setVolumeCount(-1362665558) + .setSizeBytes(-1796325715) + .setEtag("etag3123477") + .setDescription("description-1724546052") + .setPodCount(977657493) + .setConfigBackupSizeBytes(-606785139) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-4101/locations/location-4101/backupPlans/backupPlan-4101/backups/backup-4101"; + + Backup actualResponse = client.getBackup(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 getBackupExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4101/locations/location-4101/backupPlans/backupPlan-4101/backups/backup-4101"; + client.getBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateBackupTest() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setManual(true) + .putAllLabels(new HashMap()) + .setDeleteLockDays(-1638724265) + .setDeleteLockExpireTime(Timestamp.newBuilder().build()) + .setRetainDays(-1380805807) + .setRetainExpireTime(Timestamp.newBuilder().build()) + .setEncryptionKey(EncryptionKey.newBuilder().build()) + .setContainsVolumeData(true) + .setContainsSecrets(true) + .setClusterMetadata(Backup.ClusterMetadata.newBuilder().build()) + .setStateReason("stateReason1148834357") + .setCompleteTime(Timestamp.newBuilder().build()) + .setResourceCount(287552926) + .setVolumeCount(-1362665558) + .setSizeBytes(-1796325715) + .setEtag("etag3123477") + .setDescription("description-1724546052") + .setPodCount(977657493) + .setConfigBackupSizeBytes(-606785139) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateBackupTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Backup backup = + Backup.newBuilder() + .setName( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setManual(true) + .putAllLabels(new HashMap()) + .setDeleteLockDays(-1638724265) + .setDeleteLockExpireTime(Timestamp.newBuilder().build()) + .setRetainDays(-1380805807) + .setRetainExpireTime(Timestamp.newBuilder().build()) + .setEncryptionKey(EncryptionKey.newBuilder().build()) + .setContainsVolumeData(true) + .setContainsSecrets(true) + .setClusterMetadata(Backup.ClusterMetadata.newBuilder().build()) + .setStateReason("stateReason1148834357") + .setCompleteTime(Timestamp.newBuilder().build()) + .setResourceCount(287552926) + .setVolumeCount(-1362665558) + .setSizeBytes(-1796325715) + .setEtag("etag3123477") + .setDescription("description-1724546052") + .setPodCount(977657493) + .setConfigBackupSizeBytes(-606785139) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Backup actualResponse = client.updateBackupAsync(backup, 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 updateBackupExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Backup backup = + Backup.newBuilder() + .setName( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setManual(true) + .putAllLabels(new HashMap()) + .setDeleteLockDays(-1638724265) + .setDeleteLockExpireTime(Timestamp.newBuilder().build()) + .setRetainDays(-1380805807) + .setRetainExpireTime(Timestamp.newBuilder().build()) + .setEncryptionKey(EncryptionKey.newBuilder().build()) + .setContainsVolumeData(true) + .setContainsSecrets(true) + .setClusterMetadata(Backup.ClusterMetadata.newBuilder().build()) + .setStateReason("stateReason1148834357") + .setCompleteTime(Timestamp.newBuilder().build()) + .setResourceCount(287552926) + .setVolumeCount(-1362665558) + .setSizeBytes(-1796325715) + .setEtag("etag3123477") + .setDescription("description-1724546052") + .setPodCount(977657493) + .setConfigBackupSizeBytes(-606785139) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateBackupAsync(backup, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteBackupTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteBackupTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]"); + + client.deleteBackupAsync(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 deleteBackupExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]"); + client.deleteBackupAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteBackupTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteBackupTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = + "projects/project-4101/locations/location-4101/backupPlans/backupPlan-4101/backups/backup-4101"; + + client.deleteBackupAsync(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 deleteBackupExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4101/locations/location-4101/backupPlans/backupPlan-4101/backups/backup-4101"; + client.deleteBackupAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listVolumeBackupsTest() throws Exception { + VolumeBackup responsesElement = VolumeBackup.newBuilder().build(); + ListVolumeBackupsResponse expectedResponse = + ListVolumeBackupsResponse.newBuilder() + .setNextPageToken("") + .addAllVolumeBackups(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + BackupName parent = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]"); + + ListVolumeBackupsPagedResponse pagedListResponse = client.listVolumeBackups(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVolumeBackupsList().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 listVolumeBackupsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + BackupName parent = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]"); + client.listVolumeBackups(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listVolumeBackupsTest2() throws Exception { + VolumeBackup responsesElement = VolumeBackup.newBuilder().build(); + ListVolumeBackupsResponse expectedResponse = + ListVolumeBackupsResponse.newBuilder() + .setNextPageToken("") + .addAllVolumeBackups(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-634/locations/location-634/backupPlans/backupPlan-634/backups/backup-634"; + + ListVolumeBackupsPagedResponse pagedListResponse = client.listVolumeBackups(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVolumeBackupsList().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 listVolumeBackupsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-634/locations/location-634/backupPlans/backupPlan-634/backups/backup-634"; + client.listVolumeBackups(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVolumeBackupTest() throws Exception { + VolumeBackup expectedResponse = + VolumeBackup.newBuilder() + .setName( + VolumeBackupName.of( + "[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]", "[VOLUME_BACKUP]") + .toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSourcePvc(NamespacedName.newBuilder().build()) + .setVolumeBackupHandle("volumeBackupHandle190274244") + .setStorageBytes(2035244455) + .setDiskSizeBytes(-275393905) + .setCompleteTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + VolumeBackupName name = + VolumeBackupName.of( + "[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]", "[VOLUME_BACKUP]"); + + VolumeBackup actualResponse = client.getVolumeBackup(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 getVolumeBackupExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + VolumeBackupName name = + VolumeBackupName.of( + "[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]", "[VOLUME_BACKUP]"); + client.getVolumeBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVolumeBackupTest2() throws Exception { + VolumeBackup expectedResponse = + VolumeBackup.newBuilder() + .setName( + VolumeBackupName.of( + "[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]", "[VOLUME_BACKUP]") + .toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setSourcePvc(NamespacedName.newBuilder().build()) + .setVolumeBackupHandle("volumeBackupHandle190274244") + .setStorageBytes(2035244455) + .setDiskSizeBytes(-275393905) + .setCompleteTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-222/locations/location-222/backupPlans/backupPlan-222/backups/backup-222/volumeBackups/volumeBackup-222"; + + VolumeBackup actualResponse = client.getVolumeBackup(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 getVolumeBackupExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-222/locations/location-222/backupPlans/backupPlan-222/backups/backup-222/volumeBackups/volumeBackup-222"; + client.getVolumeBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createRestorePlanTest() throws Exception { + RestorePlan expectedResponse = + RestorePlan.newBuilder() + .setName(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setBackupPlan(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setCluster("cluster872092154") + .setRestoreConfig(RestoreConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createRestorePlanTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + RestorePlan restorePlan = RestorePlan.newBuilder().build(); + String restorePlanId = "restorePlanId-857896366"; + + RestorePlan actualResponse = + client.createRestorePlanAsync(parent, restorePlan, restorePlanId).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 createRestorePlanExceptionTest() 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]"); + RestorePlan restorePlan = RestorePlan.newBuilder().build(); + String restorePlanId = "restorePlanId-857896366"; + client.createRestorePlanAsync(parent, restorePlan, restorePlanId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createRestorePlanTest2() throws Exception { + RestorePlan expectedResponse = + RestorePlan.newBuilder() + .setName(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setBackupPlan(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setCluster("cluster872092154") + .setRestoreConfig(RestoreConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createRestorePlanTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + RestorePlan restorePlan = RestorePlan.newBuilder().build(); + String restorePlanId = "restorePlanId-857896366"; + + RestorePlan actualResponse = + client.createRestorePlanAsync(parent, restorePlan, restorePlanId).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 createRestorePlanExceptionTest2() 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"; + RestorePlan restorePlan = RestorePlan.newBuilder().build(); + String restorePlanId = "restorePlanId-857896366"; + client.createRestorePlanAsync(parent, restorePlan, restorePlanId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listRestorePlansTest() throws Exception { + RestorePlan responsesElement = RestorePlan.newBuilder().build(); + ListRestorePlansResponse expectedResponse = + ListRestorePlansResponse.newBuilder() + .setNextPageToken("") + .addAllRestorePlans(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListRestorePlansPagedResponse pagedListResponse = client.listRestorePlans(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRestorePlansList().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 listRestorePlansExceptionTest() 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.listRestorePlans(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listRestorePlansTest2() throws Exception { + RestorePlan responsesElement = RestorePlan.newBuilder().build(); + ListRestorePlansResponse expectedResponse = + ListRestorePlansResponse.newBuilder() + .setNextPageToken("") + .addAllRestorePlans(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListRestorePlansPagedResponse pagedListResponse = client.listRestorePlans(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRestorePlansList().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 listRestorePlansExceptionTest2() 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.listRestorePlans(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getRestorePlanTest() throws Exception { + RestorePlan expectedResponse = + RestorePlan.newBuilder() + .setName(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setBackupPlan(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setCluster("cluster872092154") + .setRestoreConfig(RestoreConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + RestorePlanName name = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]"); + + RestorePlan actualResponse = client.getRestorePlan(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 getRestorePlanExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestorePlanName name = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]"); + client.getRestorePlan(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getRestorePlanTest2() throws Exception { + RestorePlan expectedResponse = + RestorePlan.newBuilder() + .setName(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setBackupPlan(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setCluster("cluster872092154") + .setRestoreConfig(RestoreConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-4908/locations/location-4908/restorePlans/restorePlan-4908"; + + RestorePlan actualResponse = client.getRestorePlan(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 getRestorePlanExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-4908/locations/location-4908/restorePlans/restorePlan-4908"; + client.getRestorePlan(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateRestorePlanTest() throws Exception { + RestorePlan expectedResponse = + RestorePlan.newBuilder() + .setName(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setBackupPlan(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setCluster("cluster872092154") + .setRestoreConfig(RestoreConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateRestorePlanTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RestorePlan restorePlan = + RestorePlan.newBuilder() + .setName(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setBackupPlan(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setCluster("cluster872092154") + .setRestoreConfig(RestoreConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + RestorePlan actualResponse = client.updateRestorePlanAsync(restorePlan, 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 updateRestorePlanExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestorePlan restorePlan = + RestorePlan.newBuilder() + .setName(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setBackupPlan( + BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setCluster("cluster872092154") + .setRestoreConfig(RestoreConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateRestorePlanAsync(restorePlan, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteRestorePlanTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteRestorePlanTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RestorePlanName name = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]"); + + client.deleteRestorePlanAsync(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 deleteRestorePlanExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestorePlanName name = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]"); + client.deleteRestorePlanAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteRestorePlanTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteRestorePlanTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-4908/locations/location-4908/restorePlans/restorePlan-4908"; + + client.deleteRestorePlanAsync(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 deleteRestorePlanExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-4908/locations/location-4908/restorePlans/restorePlan-4908"; + client.deleteRestorePlanAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createRestoreTest() throws Exception { + Restore expectedResponse = + Restore.newBuilder() + .setName( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setBackup( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setCluster("cluster872092154") + .setRestoreConfig(RestoreConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .setStateReason("stateReason1148834357") + .setCompleteTime(Timestamp.newBuilder().build()) + .setResourcesRestoredCount(882879616) + .setResourcesExcludedCount(-338652236) + .setResourcesFailedCount(217904743) + .setVolumesRestoredCount(1005533068) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createRestoreTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RestorePlanName parent = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]"); + Restore restore = Restore.newBuilder().build(); + String restoreId = "restoreId-1845465015"; + + Restore actualResponse = client.createRestoreAsync(parent, restore, restoreId).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 createRestoreExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestorePlanName parent = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]"); + Restore restore = Restore.newBuilder().build(); + String restoreId = "restoreId-1845465015"; + client.createRestoreAsync(parent, restore, restoreId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createRestoreTest2() throws Exception { + Restore expectedResponse = + Restore.newBuilder() + .setName( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setBackup( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setCluster("cluster872092154") + .setRestoreConfig(RestoreConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .setStateReason("stateReason1148834357") + .setCompleteTime(Timestamp.newBuilder().build()) + .setResourcesRestoredCount(882879616) + .setResourcesExcludedCount(-338652236) + .setResourcesFailedCount(217904743) + .setVolumesRestoredCount(1005533068) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createRestoreTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-6563/locations/location-6563/restorePlans/restorePlan-6563"; + Restore restore = Restore.newBuilder().build(); + String restoreId = "restoreId-1845465015"; + + Restore actualResponse = client.createRestoreAsync(parent, restore, restoreId).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 createRestoreExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6563/locations/location-6563/restorePlans/restorePlan-6563"; + Restore restore = Restore.newBuilder().build(); + String restoreId = "restoreId-1845465015"; + client.createRestoreAsync(parent, restore, restoreId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listRestoresTest() throws Exception { + Restore responsesElement = Restore.newBuilder().build(); + ListRestoresResponse expectedResponse = + ListRestoresResponse.newBuilder() + .setNextPageToken("") + .addAllRestores(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + RestorePlanName parent = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]"); + + ListRestoresPagedResponse pagedListResponse = client.listRestores(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRestoresList().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 listRestoresExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestorePlanName parent = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]"); + client.listRestores(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listRestoresTest2() throws Exception { + Restore responsesElement = Restore.newBuilder().build(); + ListRestoresResponse expectedResponse = + ListRestoresResponse.newBuilder() + .setNextPageToken("") + .addAllRestores(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6563/locations/location-6563/restorePlans/restorePlan-6563"; + + ListRestoresPagedResponse pagedListResponse = client.listRestores(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getRestoresList().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 listRestoresExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6563/locations/location-6563/restorePlans/restorePlan-6563"; + client.listRestores(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getRestoreTest() throws Exception { + Restore expectedResponse = + Restore.newBuilder() + .setName( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setBackup( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setCluster("cluster872092154") + .setRestoreConfig(RestoreConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .setStateReason("stateReason1148834357") + .setCompleteTime(Timestamp.newBuilder().build()) + .setResourcesRestoredCount(882879616) + .setResourcesExcludedCount(-338652236) + .setResourcesFailedCount(217904743) + .setVolumesRestoredCount(1005533068) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + RestoreName name = RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]"); + + Restore actualResponse = client.getRestore(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 getRestoreExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestoreName name = RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]"); + client.getRestore(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getRestoreTest2() throws Exception { + Restore expectedResponse = + Restore.newBuilder() + .setName( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setBackup( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setCluster("cluster872092154") + .setRestoreConfig(RestoreConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .setStateReason("stateReason1148834357") + .setCompleteTime(Timestamp.newBuilder().build()) + .setResourcesRestoredCount(882879616) + .setResourcesExcludedCount(-338652236) + .setResourcesFailedCount(217904743) + .setVolumesRestoredCount(1005533068) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-77/locations/location-77/restorePlans/restorePlan-77/restores/restore-77"; + + Restore actualResponse = client.getRestore(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 getRestoreExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-77/locations/location-77/restorePlans/restorePlan-77/restores/restore-77"; + client.getRestore(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateRestoreTest() throws Exception { + Restore expectedResponse = + Restore.newBuilder() + .setName( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setBackup( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setCluster("cluster872092154") + .setRestoreConfig(RestoreConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .setStateReason("stateReason1148834357") + .setCompleteTime(Timestamp.newBuilder().build()) + .setResourcesRestoredCount(882879616) + .setResourcesExcludedCount(-338652236) + .setResourcesFailedCount(217904743) + .setVolumesRestoredCount(1005533068) + .setEtag("etag3123477") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateRestoreTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Restore restore = + Restore.newBuilder() + .setName( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]").toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setBackup( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setCluster("cluster872092154") + .setRestoreConfig(RestoreConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .setStateReason("stateReason1148834357") + .setCompleteTime(Timestamp.newBuilder().build()) + .setResourcesRestoredCount(882879616) + .setResourcesExcludedCount(-338652236) + .setResourcesFailedCount(217904743) + .setVolumesRestoredCount(1005533068) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Restore actualResponse = client.updateRestoreAsync(restore, 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 updateRestoreExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Restore restore = + Restore.newBuilder() + .setName( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]") + .toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setDescription("description-1724546052") + .setBackup( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setCluster("cluster872092154") + .setRestoreConfig(RestoreConfig.newBuilder().build()) + .putAllLabels(new HashMap()) + .setStateReason("stateReason1148834357") + .setCompleteTime(Timestamp.newBuilder().build()) + .setResourcesRestoredCount(882879616) + .setResourcesExcludedCount(-338652236) + .setResourcesFailedCount(217904743) + .setVolumesRestoredCount(1005533068) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateRestoreAsync(restore, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteRestoreTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteRestoreTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RestoreName name = RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]"); + + client.deleteRestoreAsync(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 deleteRestoreExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestoreName name = RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]"); + client.deleteRestoreAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteRestoreTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteRestoreTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = + "projects/project-77/locations/location-77/restorePlans/restorePlan-77/restores/restore-77"; + + client.deleteRestoreAsync(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 deleteRestoreExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-77/locations/location-77/restorePlans/restorePlan-77/restores/restore-77"; + client.deleteRestoreAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void listVolumeRestoresTest() throws Exception { + VolumeRestore responsesElement = VolumeRestore.newBuilder().build(); + ListVolumeRestoresResponse expectedResponse = + ListVolumeRestoresResponse.newBuilder() + .setNextPageToken("") + .addAllVolumeRestores(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + RestoreName parent = RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]"); + + ListVolumeRestoresPagedResponse pagedListResponse = client.listVolumeRestores(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVolumeRestoresList().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 listVolumeRestoresExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestoreName parent = RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]"); + client.listVolumeRestores(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listVolumeRestoresTest2() throws Exception { + VolumeRestore responsesElement = VolumeRestore.newBuilder().build(); + ListVolumeRestoresResponse expectedResponse = + ListVolumeRestoresResponse.newBuilder() + .setNextPageToken("") + .addAllVolumeRestores(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-1186/locations/location-1186/restorePlans/restorePlan-1186/restores/restore-1186"; + + ListVolumeRestoresPagedResponse pagedListResponse = client.listVolumeRestores(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVolumeRestoresList().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 listVolumeRestoresExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-1186/locations/location-1186/restorePlans/restorePlan-1186/restores/restore-1186"; + client.listVolumeRestores(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVolumeRestoreTest() throws Exception { + VolumeRestore expectedResponse = + VolumeRestore.newBuilder() + .setName( + VolumeRestoreName.of( + "[PROJECT]", + "[LOCATION]", + "[RESTORE_PLAN]", + "[RESTORE]", + "[VOLUME_RESTORE]") + .toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setVolumeBackup("volumeBackup2099842428") + .setTargetPvc(NamespacedName.newBuilder().build()) + .setVolumeHandle("volumeHandle-2023029278") + .setCompleteTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + VolumeRestoreName name = + VolumeRestoreName.of( + "[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]", "[VOLUME_RESTORE]"); + + VolumeRestore actualResponse = client.getVolumeRestore(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 getVolumeRestoreExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + VolumeRestoreName name = + VolumeRestoreName.of( + "[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]", "[VOLUME_RESTORE]"); + client.getVolumeRestore(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVolumeRestoreTest2() throws Exception { + VolumeRestore expectedResponse = + VolumeRestore.newBuilder() + .setName( + VolumeRestoreName.of( + "[PROJECT]", + "[LOCATION]", + "[RESTORE_PLAN]", + "[RESTORE]", + "[VOLUME_RESTORE]") + .toString()) + .setUid("uid115792") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setVolumeBackup("volumeBackup2099842428") + .setTargetPvc(NamespacedName.newBuilder().build()) + .setVolumeHandle("volumeHandle-2023029278") + .setCompleteTime(Timestamp.newBuilder().build()) + .setStateMessage("stateMessage1128185398") + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-5658/locations/location-5658/restorePlans/restorePlan-5658/restores/restore-5658/volumeRestores/volumeRestore-5658"; + + VolumeRestore actualResponse = client.getVolumeRestore(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 getVolumeRestoreExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-5658/locations/location-5658/restorePlans/restorePlan-5658/restores/restore-5658/volumeRestores/volumeRestore-5658"; + client.getVolumeRestore(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 0000000..14347da --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupForGKESettings; +import com.google.cloud.gkebackup.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. + BackupForGKESettings backupForGKESettings = + BackupForGKESettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + BackupForGKEClient backupForGKEClient = BackupForGKEClient.create(backupForGKESettings); + } +} +// [END gkebackup_v1_generated_backupforgkeclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 0000000..9595c03 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_create_setcredentialsprovider1_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupForGKESettings; + +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. + BackupForGKESettings backupForGKESettings = + BackupForGKESettings.newBuilder() + .setTransportChannelProvider( + BackupForGKESettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + BackupForGKEClient backupForGKEClient = BackupForGKEClient.create(backupForGKESettings); + } +} +// [END gkebackup_v1_generated_backupforgkeclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 0000000..c0a8397 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_create_setendpoint_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupForGKESettings; +import com.google.cloud.gkebackup.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. + BackupForGKESettings backupForGKESettings = + BackupForGKESettings.newBuilder().setEndpoint(myEndpoint).build(); + BackupForGKEClient backupForGKEClient = BackupForGKEClient.create(backupForGKESettings); + } +} +// [END gkebackup_v1_generated_backupforgkeclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/AsyncCreateBackup.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/AsyncCreateBackup.java new file mode 100644 index 0000000..17c27d0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/AsyncCreateBackup.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createbackup_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; +import com.google.cloud.gkebackup.v1.CreateBackupRequest; +import com.google.longrunning.Operation; + +public class AsyncCreateBackup { + + public static void main(String[] args) throws Exception { + asyncCreateBackup(); + } + + public static void asyncCreateBackup() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + CreateBackupRequest request = + CreateBackupRequest.newBuilder() + .setParent(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setBackup(Backup.newBuilder().build()) + .setBackupId("backupId2121930365") + .build(); + ApiFuture future = backupForGKEClient.createBackupCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createbackup_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/AsyncCreateBackupLRO.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/AsyncCreateBackupLRO.java new file mode 100644 index 0000000..aa3d3f4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/AsyncCreateBackupLRO.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createbackup_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; +import com.google.cloud.gkebackup.v1.CreateBackupRequest; +import com.google.cloud.gkebackup.v1.OperationMetadata; + +public class AsyncCreateBackupLRO { + + public static void main(String[] args) throws Exception { + asyncCreateBackupLRO(); + } + + public static void asyncCreateBackupLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + CreateBackupRequest request = + CreateBackupRequest.newBuilder() + .setParent(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setBackup(Backup.newBuilder().build()) + .setBackupId("backupId2121930365") + .build(); + OperationFuture future = + backupForGKEClient.createBackupOperationCallable().futureCall(request); + // Do something. + Backup response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createbackup_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/SyncCreateBackup.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/SyncCreateBackup.java new file mode 100644 index 0000000..a342df3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/SyncCreateBackup.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createbackup_sync] +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; +import com.google.cloud.gkebackup.v1.CreateBackupRequest; + +public class SyncCreateBackup { + + public static void main(String[] args) throws Exception { + syncCreateBackup(); + } + + public static void syncCreateBackup() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + CreateBackupRequest request = + CreateBackupRequest.newBuilder() + .setParent(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setBackup(Backup.newBuilder().build()) + .setBackupId("backupId2121930365") + .build(); + Backup response = backupForGKEClient.createBackupAsync(request).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createbackup_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/SyncCreateBackupBackupplannameBackupString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/SyncCreateBackupBackupplannameBackupString.java new file mode 100644 index 0000000..80cdb5c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/SyncCreateBackupBackupplannameBackupString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createbackup_backupplannamebackupstring_sync] +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; + +public class SyncCreateBackupBackupplannameBackupString { + + public static void main(String[] args) throws Exception { + syncCreateBackupBackupplannameBackupString(); + } + + public static void syncCreateBackupBackupplannameBackupString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + BackupPlanName parent = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]"); + Backup backup = Backup.newBuilder().build(); + String backupId = "backupId2121930365"; + Backup response = backupForGKEClient.createBackupAsync(parent, backup, backupId).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createbackup_backupplannamebackupstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/SyncCreateBackupStringBackupString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/SyncCreateBackupStringBackupString.java new file mode 100644 index 0000000..f5b3f89 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackup/SyncCreateBackupStringBackupString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createbackup_stringbackupstring_sync] +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; + +public class SyncCreateBackupStringBackupString { + + public static void main(String[] args) throws Exception { + syncCreateBackupStringBackupString(); + } + + public static void syncCreateBackupStringBackupString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String parent = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString(); + Backup backup = Backup.newBuilder().build(); + String backupId = "backupId2121930365"; + Backup response = backupForGKEClient.createBackupAsync(parent, backup, backupId).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createbackup_stringbackupstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/AsyncCreateBackupPlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/AsyncCreateBackupPlan.java new file mode 100644 index 0000000..9e798ab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/AsyncCreateBackupPlan.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createbackupplan_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.CreateBackupPlanRequest; +import com.google.cloud.gkebackup.v1.LocationName; +import com.google.longrunning.Operation; + +public class AsyncCreateBackupPlan { + + public static void main(String[] args) throws Exception { + asyncCreateBackupPlan(); + } + + public static void asyncCreateBackupPlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + CreateBackupPlanRequest request = + CreateBackupPlanRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setBackupPlan(BackupPlan.newBuilder().build()) + .setBackupPlanId("backupPlanId-84871546") + .build(); + ApiFuture future = + backupForGKEClient.createBackupPlanCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createbackupplan_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/AsyncCreateBackupPlanLRO.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/AsyncCreateBackupPlanLRO.java new file mode 100644 index 0000000..9f66284 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/AsyncCreateBackupPlanLRO.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createbackupplan_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.CreateBackupPlanRequest; +import com.google.cloud.gkebackup.v1.LocationName; +import com.google.cloud.gkebackup.v1.OperationMetadata; + +public class AsyncCreateBackupPlanLRO { + + public static void main(String[] args) throws Exception { + asyncCreateBackupPlanLRO(); + } + + public static void asyncCreateBackupPlanLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + CreateBackupPlanRequest request = + CreateBackupPlanRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setBackupPlan(BackupPlan.newBuilder().build()) + .setBackupPlanId("backupPlanId-84871546") + .build(); + OperationFuture future = + backupForGKEClient.createBackupPlanOperationCallable().futureCall(request); + // Do something. + BackupPlan response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createbackupplan_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/SyncCreateBackupPlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/SyncCreateBackupPlan.java new file mode 100644 index 0000000..176bb43 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/SyncCreateBackupPlan.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createbackupplan_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.CreateBackupPlanRequest; +import com.google.cloud.gkebackup.v1.LocationName; + +public class SyncCreateBackupPlan { + + public static void main(String[] args) throws Exception { + syncCreateBackupPlan(); + } + + public static void syncCreateBackupPlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + CreateBackupPlanRequest request = + CreateBackupPlanRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setBackupPlan(BackupPlan.newBuilder().build()) + .setBackupPlanId("backupPlanId-84871546") + .build(); + BackupPlan response = backupForGKEClient.createBackupPlanAsync(request).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createbackupplan_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/SyncCreateBackupPlanLocationnameBackupplanString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/SyncCreateBackupPlanLocationnameBackupplanString.java new file mode 100644 index 0000000..44cdaeb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/SyncCreateBackupPlanLocationnameBackupplanString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createbackupplan_locationnamebackupplanstring_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.LocationName; + +public class SyncCreateBackupPlanLocationnameBackupplanString { + + public static void main(String[] args) throws Exception { + syncCreateBackupPlanLocationnameBackupplanString(); + } + + public static void syncCreateBackupPlanLocationnameBackupplanString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + BackupPlan backupPlan = BackupPlan.newBuilder().build(); + String backupPlanId = "backupPlanId-84871546"; + BackupPlan response = + backupForGKEClient.createBackupPlanAsync(parent, backupPlan, backupPlanId).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createbackupplan_locationnamebackupplanstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/SyncCreateBackupPlanStringBackupplanString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/SyncCreateBackupPlanStringBackupplanString.java new file mode 100644 index 0000000..5d6bef5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createbackupplan/SyncCreateBackupPlanStringBackupplanString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createbackupplan_stringbackupplanstring_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.LocationName; + +public class SyncCreateBackupPlanStringBackupplanString { + + public static void main(String[] args) throws Exception { + syncCreateBackupPlanStringBackupplanString(); + } + + public static void syncCreateBackupPlanStringBackupplanString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + BackupPlan backupPlan = BackupPlan.newBuilder().build(); + String backupPlanId = "backupPlanId-84871546"; + BackupPlan response = + backupForGKEClient.createBackupPlanAsync(parent, backupPlan, backupPlanId).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createbackupplan_stringbackupplanstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/AsyncCreateRestore.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/AsyncCreateRestore.java new file mode 100644 index 0000000..ff4343a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/AsyncCreateRestore.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createrestore_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.CreateRestoreRequest; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestorePlanName; +import com.google.longrunning.Operation; + +public class AsyncCreateRestore { + + public static void main(String[] args) throws Exception { + asyncCreateRestore(); + } + + public static void asyncCreateRestore() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + CreateRestoreRequest request = + CreateRestoreRequest.newBuilder() + .setParent(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setRestore(Restore.newBuilder().build()) + .setRestoreId("restoreId-1845465015") + .build(); + ApiFuture future = backupForGKEClient.createRestoreCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createrestore_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/AsyncCreateRestoreLRO.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/AsyncCreateRestoreLRO.java new file mode 100644 index 0000000..1594b35 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/AsyncCreateRestoreLRO.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createrestore_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.CreateRestoreRequest; +import com.google.cloud.gkebackup.v1.OperationMetadata; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestorePlanName; + +public class AsyncCreateRestoreLRO { + + public static void main(String[] args) throws Exception { + asyncCreateRestoreLRO(); + } + + public static void asyncCreateRestoreLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + CreateRestoreRequest request = + CreateRestoreRequest.newBuilder() + .setParent(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setRestore(Restore.newBuilder().build()) + .setRestoreId("restoreId-1845465015") + .build(); + OperationFuture future = + backupForGKEClient.createRestoreOperationCallable().futureCall(request); + // Do something. + Restore response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createrestore_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/SyncCreateRestore.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/SyncCreateRestore.java new file mode 100644 index 0000000..b2da6da --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/SyncCreateRestore.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createrestore_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.CreateRestoreRequest; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestorePlanName; + +public class SyncCreateRestore { + + public static void main(String[] args) throws Exception { + syncCreateRestore(); + } + + public static void syncCreateRestore() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + CreateRestoreRequest request = + CreateRestoreRequest.newBuilder() + .setParent(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setRestore(Restore.newBuilder().build()) + .setRestoreId("restoreId-1845465015") + .build(); + Restore response = backupForGKEClient.createRestoreAsync(request).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createrestore_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/SyncCreateRestoreRestoreplannameRestoreString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/SyncCreateRestoreRestoreplannameRestoreString.java new file mode 100644 index 0000000..854b2d9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/SyncCreateRestoreRestoreplannameRestoreString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createrestore_restoreplannamerestorestring_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestorePlanName; + +public class SyncCreateRestoreRestoreplannameRestoreString { + + public static void main(String[] args) throws Exception { + syncCreateRestoreRestoreplannameRestoreString(); + } + + public static void syncCreateRestoreRestoreplannameRestoreString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + RestorePlanName parent = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]"); + Restore restore = Restore.newBuilder().build(); + String restoreId = "restoreId-1845465015"; + Restore response = backupForGKEClient.createRestoreAsync(parent, restore, restoreId).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createrestore_restoreplannamerestorestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/SyncCreateRestoreStringRestoreString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/SyncCreateRestoreStringRestoreString.java new file mode 100644 index 0000000..05b4239 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestore/SyncCreateRestoreStringRestoreString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createrestore_stringrestorestring_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestorePlanName; + +public class SyncCreateRestoreStringRestoreString { + + public static void main(String[] args) throws Exception { + syncCreateRestoreStringRestoreString(); + } + + public static void syncCreateRestoreStringRestoreString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String parent = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString(); + Restore restore = Restore.newBuilder().build(); + String restoreId = "restoreId-1845465015"; + Restore response = backupForGKEClient.createRestoreAsync(parent, restore, restoreId).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createrestore_stringrestorestring_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/AsyncCreateRestorePlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/AsyncCreateRestorePlan.java new file mode 100644 index 0000000..1766d58 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/AsyncCreateRestorePlan.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createrestoreplan_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.CreateRestorePlanRequest; +import com.google.cloud.gkebackup.v1.LocationName; +import com.google.cloud.gkebackup.v1.RestorePlan; +import com.google.longrunning.Operation; + +public class AsyncCreateRestorePlan { + + public static void main(String[] args) throws Exception { + asyncCreateRestorePlan(); + } + + public static void asyncCreateRestorePlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + CreateRestorePlanRequest request = + CreateRestorePlanRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setRestorePlan(RestorePlan.newBuilder().build()) + .setRestorePlanId("restorePlanId-857896366") + .build(); + ApiFuture future = + backupForGKEClient.createRestorePlanCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createrestoreplan_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/AsyncCreateRestorePlanLRO.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/AsyncCreateRestorePlanLRO.java new file mode 100644 index 0000000..8b13c02 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/AsyncCreateRestorePlanLRO.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createrestoreplan_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.CreateRestorePlanRequest; +import com.google.cloud.gkebackup.v1.LocationName; +import com.google.cloud.gkebackup.v1.OperationMetadata; +import com.google.cloud.gkebackup.v1.RestorePlan; + +public class AsyncCreateRestorePlanLRO { + + public static void main(String[] args) throws Exception { + asyncCreateRestorePlanLRO(); + } + + public static void asyncCreateRestorePlanLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + CreateRestorePlanRequest request = + CreateRestorePlanRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setRestorePlan(RestorePlan.newBuilder().build()) + .setRestorePlanId("restorePlanId-857896366") + .build(); + OperationFuture future = + backupForGKEClient.createRestorePlanOperationCallable().futureCall(request); + // Do something. + RestorePlan response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createrestoreplan_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/SyncCreateRestorePlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/SyncCreateRestorePlan.java new file mode 100644 index 0000000..4de75bb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/SyncCreateRestorePlan.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createrestoreplan_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.CreateRestorePlanRequest; +import com.google.cloud.gkebackup.v1.LocationName; +import com.google.cloud.gkebackup.v1.RestorePlan; + +public class SyncCreateRestorePlan { + + public static void main(String[] args) throws Exception { + syncCreateRestorePlan(); + } + + public static void syncCreateRestorePlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + CreateRestorePlanRequest request = + CreateRestorePlanRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setRestorePlan(RestorePlan.newBuilder().build()) + .setRestorePlanId("restorePlanId-857896366") + .build(); + RestorePlan response = backupForGKEClient.createRestorePlanAsync(request).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createrestoreplan_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/SyncCreateRestorePlanLocationnameRestoreplanString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/SyncCreateRestorePlanLocationnameRestoreplanString.java new file mode 100644 index 0000000..e63f372 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/SyncCreateRestorePlanLocationnameRestoreplanString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createrestoreplan_locationnamerestoreplanstring_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.LocationName; +import com.google.cloud.gkebackup.v1.RestorePlan; + +public class SyncCreateRestorePlanLocationnameRestoreplanString { + + public static void main(String[] args) throws Exception { + syncCreateRestorePlanLocationnameRestoreplanString(); + } + + public static void syncCreateRestorePlanLocationnameRestoreplanString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + RestorePlan restorePlan = RestorePlan.newBuilder().build(); + String restorePlanId = "restorePlanId-857896366"; + RestorePlan response = + backupForGKEClient.createRestorePlanAsync(parent, restorePlan, restorePlanId).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createrestoreplan_locationnamerestoreplanstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/SyncCreateRestorePlanStringRestoreplanString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/SyncCreateRestorePlanStringRestoreplanString.java new file mode 100644 index 0000000..fb91d85 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/createrestoreplan/SyncCreateRestorePlanStringRestoreplanString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_createrestoreplan_stringrestoreplanstring_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.LocationName; +import com.google.cloud.gkebackup.v1.RestorePlan; + +public class SyncCreateRestorePlanStringRestoreplanString { + + public static void main(String[] args) throws Exception { + syncCreateRestorePlanStringRestoreplanString(); + } + + public static void syncCreateRestorePlanStringRestoreplanString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + RestorePlan restorePlan = RestorePlan.newBuilder().build(); + String restorePlanId = "restorePlanId-857896366"; + RestorePlan response = + backupForGKEClient.createRestorePlanAsync(parent, restorePlan, restorePlanId).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_createrestoreplan_stringrestoreplanstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/AsyncDeleteBackup.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/AsyncDeleteBackup.java new file mode 100644 index 0000000..8ff39a6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/AsyncDeleteBackup.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deletebackup_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupName; +import com.google.cloud.gkebackup.v1.DeleteBackupRequest; +import com.google.longrunning.Operation; + +public class AsyncDeleteBackup { + + public static void main(String[] args) throws Exception { + asyncDeleteBackup(); + } + + public static void asyncDeleteBackup() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + DeleteBackupRequest request = + DeleteBackupRequest.newBuilder() + .setName( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setEtag("etag3123477") + .setForce(true) + .build(); + ApiFuture future = backupForGKEClient.deleteBackupCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deletebackup_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/AsyncDeleteBackupLRO.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/AsyncDeleteBackupLRO.java new file mode 100644 index 0000000..455b027 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/AsyncDeleteBackupLRO.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deletebackup_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupName; +import com.google.cloud.gkebackup.v1.DeleteBackupRequest; +import com.google.cloud.gkebackup.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteBackupLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteBackupLRO(); + } + + public static void asyncDeleteBackupLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + DeleteBackupRequest request = + DeleteBackupRequest.newBuilder() + .setName( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setEtag("etag3123477") + .setForce(true) + .build(); + OperationFuture future = + backupForGKEClient.deleteBackupOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deletebackup_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/SyncDeleteBackup.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/SyncDeleteBackup.java new file mode 100644 index 0000000..810cd8c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/SyncDeleteBackup.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deletebackup_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupName; +import com.google.cloud.gkebackup.v1.DeleteBackupRequest; +import com.google.protobuf.Empty; + +public class SyncDeleteBackup { + + public static void main(String[] args) throws Exception { + syncDeleteBackup(); + } + + public static void syncDeleteBackup() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + DeleteBackupRequest request = + DeleteBackupRequest.newBuilder() + .setName( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setEtag("etag3123477") + .setForce(true) + .build(); + backupForGKEClient.deleteBackupAsync(request).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deletebackup_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/SyncDeleteBackupBackupname.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/SyncDeleteBackupBackupname.java new file mode 100644 index 0000000..ef03ce1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/SyncDeleteBackupBackupname.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deletebackup_backupname_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupName; +import com.google.protobuf.Empty; + +public class SyncDeleteBackupBackupname { + + public static void main(String[] args) throws Exception { + syncDeleteBackupBackupname(); + } + + public static void syncDeleteBackupBackupname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]"); + backupForGKEClient.deleteBackupAsync(name).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deletebackup_backupname_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/SyncDeleteBackupString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/SyncDeleteBackupString.java new file mode 100644 index 0000000..d458f78 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackup/SyncDeleteBackupString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deletebackup_string_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupName; +import com.google.protobuf.Empty; + +public class SyncDeleteBackupString { + + public static void main(String[] args) throws Exception { + syncDeleteBackupString(); + } + + public static void syncDeleteBackupString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String name = + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString(); + backupForGKEClient.deleteBackupAsync(name).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deletebackup_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/AsyncDeleteBackupPlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/AsyncDeleteBackupPlan.java new file mode 100644 index 0000000..5bdd63d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/AsyncDeleteBackupPlan.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deletebackupplan_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; +import com.google.cloud.gkebackup.v1.DeleteBackupPlanRequest; +import com.google.longrunning.Operation; + +public class AsyncDeleteBackupPlan { + + public static void main(String[] args) throws Exception { + asyncDeleteBackupPlan(); + } + + public static void asyncDeleteBackupPlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + DeleteBackupPlanRequest request = + DeleteBackupPlanRequest.newBuilder() + .setName(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setEtag("etag3123477") + .build(); + ApiFuture future = + backupForGKEClient.deleteBackupPlanCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deletebackupplan_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/AsyncDeleteBackupPlanLRO.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/AsyncDeleteBackupPlanLRO.java new file mode 100644 index 0000000..f724288 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/AsyncDeleteBackupPlanLRO.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deletebackupplan_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; +import com.google.cloud.gkebackup.v1.DeleteBackupPlanRequest; +import com.google.cloud.gkebackup.v1.OperationMetadata; +import com.google.protobuf.Empty; + +public class AsyncDeleteBackupPlanLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteBackupPlanLRO(); + } + + public static void asyncDeleteBackupPlanLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + DeleteBackupPlanRequest request = + DeleteBackupPlanRequest.newBuilder() + .setName(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setEtag("etag3123477") + .build(); + OperationFuture future = + backupForGKEClient.deleteBackupPlanOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deletebackupplan_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/SyncDeleteBackupPlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/SyncDeleteBackupPlan.java new file mode 100644 index 0000000..9202ce0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/SyncDeleteBackupPlan.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deletebackupplan_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; +import com.google.cloud.gkebackup.v1.DeleteBackupPlanRequest; +import com.google.protobuf.Empty; + +public class SyncDeleteBackupPlan { + + public static void main(String[] args) throws Exception { + syncDeleteBackupPlan(); + } + + public static void syncDeleteBackupPlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + DeleteBackupPlanRequest request = + DeleteBackupPlanRequest.newBuilder() + .setName(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setEtag("etag3123477") + .build(); + backupForGKEClient.deleteBackupPlanAsync(request).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deletebackupplan_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/SyncDeleteBackupPlanBackupplanname.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/SyncDeleteBackupPlanBackupplanname.java new file mode 100644 index 0000000..e6a7d49 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/SyncDeleteBackupPlanBackupplanname.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deletebackupplan_backupplanname_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; +import com.google.protobuf.Empty; + +public class SyncDeleteBackupPlanBackupplanname { + + public static void main(String[] args) throws Exception { + syncDeleteBackupPlanBackupplanname(); + } + + public static void syncDeleteBackupPlanBackupplanname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + BackupPlanName name = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]"); + backupForGKEClient.deleteBackupPlanAsync(name).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deletebackupplan_backupplanname_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/SyncDeleteBackupPlanString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/SyncDeleteBackupPlanString.java new file mode 100644 index 0000000..91e51af --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deletebackupplan/SyncDeleteBackupPlanString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deletebackupplan_string_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; +import com.google.protobuf.Empty; + +public class SyncDeleteBackupPlanString { + + public static void main(String[] args) throws Exception { + syncDeleteBackupPlanString(); + } + + public static void syncDeleteBackupPlanString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String name = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString(); + backupForGKEClient.deleteBackupPlanAsync(name).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deletebackupplan_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/AsyncDeleteRestore.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/AsyncDeleteRestore.java new file mode 100644 index 0000000..77d10ff --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/AsyncDeleteRestore.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deleterestore_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.DeleteRestoreRequest; +import com.google.cloud.gkebackup.v1.RestoreName; +import com.google.longrunning.Operation; + +public class AsyncDeleteRestore { + + public static void main(String[] args) throws Exception { + asyncDeleteRestore(); + } + + public static void asyncDeleteRestore() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + DeleteRestoreRequest request = + DeleteRestoreRequest.newBuilder() + .setName( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]") + .toString()) + .setEtag("etag3123477") + .setForce(true) + .build(); + ApiFuture future = backupForGKEClient.deleteRestoreCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deleterestore_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/AsyncDeleteRestoreLRO.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/AsyncDeleteRestoreLRO.java new file mode 100644 index 0000000..930ecb6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/AsyncDeleteRestoreLRO.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deleterestore_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.DeleteRestoreRequest; +import com.google.cloud.gkebackup.v1.OperationMetadata; +import com.google.cloud.gkebackup.v1.RestoreName; +import com.google.protobuf.Empty; + +public class AsyncDeleteRestoreLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteRestoreLRO(); + } + + public static void asyncDeleteRestoreLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + DeleteRestoreRequest request = + DeleteRestoreRequest.newBuilder() + .setName( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]") + .toString()) + .setEtag("etag3123477") + .setForce(true) + .build(); + OperationFuture future = + backupForGKEClient.deleteRestoreOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deleterestore_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/SyncDeleteRestore.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/SyncDeleteRestore.java new file mode 100644 index 0000000..4897328 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/SyncDeleteRestore.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deleterestore_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.DeleteRestoreRequest; +import com.google.cloud.gkebackup.v1.RestoreName; +import com.google.protobuf.Empty; + +public class SyncDeleteRestore { + + public static void main(String[] args) throws Exception { + syncDeleteRestore(); + } + + public static void syncDeleteRestore() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + DeleteRestoreRequest request = + DeleteRestoreRequest.newBuilder() + .setName( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]") + .toString()) + .setEtag("etag3123477") + .setForce(true) + .build(); + backupForGKEClient.deleteRestoreAsync(request).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deleterestore_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/SyncDeleteRestoreRestorename.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/SyncDeleteRestoreRestorename.java new file mode 100644 index 0000000..27b5226 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/SyncDeleteRestoreRestorename.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deleterestore_restorename_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.RestoreName; +import com.google.protobuf.Empty; + +public class SyncDeleteRestoreRestorename { + + public static void main(String[] args) throws Exception { + syncDeleteRestoreRestorename(); + } + + public static void syncDeleteRestoreRestorename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + RestoreName name = RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]"); + backupForGKEClient.deleteRestoreAsync(name).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deleterestore_restorename_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/SyncDeleteRestoreString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/SyncDeleteRestoreString.java new file mode 100644 index 0000000..09bba86 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestore/SyncDeleteRestoreString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deleterestore_string_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.RestoreName; +import com.google.protobuf.Empty; + +public class SyncDeleteRestoreString { + + public static void main(String[] args) throws Exception { + syncDeleteRestoreString(); + } + + public static void syncDeleteRestoreString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String name = + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]").toString(); + backupForGKEClient.deleteRestoreAsync(name).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deleterestore_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/AsyncDeleteRestorePlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/AsyncDeleteRestorePlan.java new file mode 100644 index 0000000..a01554b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/AsyncDeleteRestorePlan.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deleterestoreplan_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.DeleteRestorePlanRequest; +import com.google.cloud.gkebackup.v1.RestorePlanName; +import com.google.longrunning.Operation; + +public class AsyncDeleteRestorePlan { + + public static void main(String[] args) throws Exception { + asyncDeleteRestorePlan(); + } + + public static void asyncDeleteRestorePlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + DeleteRestorePlanRequest request = + DeleteRestorePlanRequest.newBuilder() + .setName(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setEtag("etag3123477") + .setForce(true) + .build(); + ApiFuture future = + backupForGKEClient.deleteRestorePlanCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deleterestoreplan_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/AsyncDeleteRestorePlanLRO.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/AsyncDeleteRestorePlanLRO.java new file mode 100644 index 0000000..b60c32e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/AsyncDeleteRestorePlanLRO.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deleterestoreplan_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.DeleteRestorePlanRequest; +import com.google.cloud.gkebackup.v1.OperationMetadata; +import com.google.cloud.gkebackup.v1.RestorePlanName; +import com.google.protobuf.Empty; + +public class AsyncDeleteRestorePlanLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteRestorePlanLRO(); + } + + public static void asyncDeleteRestorePlanLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + DeleteRestorePlanRequest request = + DeleteRestorePlanRequest.newBuilder() + .setName(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setEtag("etag3123477") + .setForce(true) + .build(); + OperationFuture future = + backupForGKEClient.deleteRestorePlanOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deleterestoreplan_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/SyncDeleteRestorePlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/SyncDeleteRestorePlan.java new file mode 100644 index 0000000..11e81cb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/SyncDeleteRestorePlan.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deleterestoreplan_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.DeleteRestorePlanRequest; +import com.google.cloud.gkebackup.v1.RestorePlanName; +import com.google.protobuf.Empty; + +public class SyncDeleteRestorePlan { + + public static void main(String[] args) throws Exception { + syncDeleteRestorePlan(); + } + + public static void syncDeleteRestorePlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + DeleteRestorePlanRequest request = + DeleteRestorePlanRequest.newBuilder() + .setName(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setEtag("etag3123477") + .setForce(true) + .build(); + backupForGKEClient.deleteRestorePlanAsync(request).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deleterestoreplan_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/SyncDeleteRestorePlanRestoreplanname.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/SyncDeleteRestorePlanRestoreplanname.java new file mode 100644 index 0000000..c3aceb6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/SyncDeleteRestorePlanRestoreplanname.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deleterestoreplan_restoreplanname_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.RestorePlanName; +import com.google.protobuf.Empty; + +public class SyncDeleteRestorePlanRestoreplanname { + + public static void main(String[] args) throws Exception { + syncDeleteRestorePlanRestoreplanname(); + } + + public static void syncDeleteRestorePlanRestoreplanname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + RestorePlanName name = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]"); + backupForGKEClient.deleteRestorePlanAsync(name).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deleterestoreplan_restoreplanname_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/SyncDeleteRestorePlanString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/SyncDeleteRestorePlanString.java new file mode 100644 index 0000000..96f3ace --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/deleterestoreplan/SyncDeleteRestorePlanString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_deleterestoreplan_string_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.RestorePlanName; +import com.google.protobuf.Empty; + +public class SyncDeleteRestorePlanString { + + public static void main(String[] args) throws Exception { + syncDeleteRestorePlanString(); + } + + public static void syncDeleteRestorePlanString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String name = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString(); + backupForGKEClient.deleteRestorePlanAsync(name).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_deleterestoreplan_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackup/AsyncGetBackup.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackup/AsyncGetBackup.java new file mode 100644 index 0000000..40f62e6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackup/AsyncGetBackup.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getbackup_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupName; +import com.google.cloud.gkebackup.v1.GetBackupRequest; + +public class AsyncGetBackup { + + public static void main(String[] args) throws Exception { + asyncGetBackup(); + } + + public static void asyncGetBackup() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + GetBackupRequest request = + GetBackupRequest.newBuilder() + .setName( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .build(); + ApiFuture future = backupForGKEClient.getBackupCallable().futureCall(request); + // Do something. + Backup response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getbackup_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackup/SyncGetBackup.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackup/SyncGetBackup.java new file mode 100644 index 0000000..f7a6d98 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackup/SyncGetBackup.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getbackup_sync] +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupName; +import com.google.cloud.gkebackup.v1.GetBackupRequest; + +public class SyncGetBackup { + + public static void main(String[] args) throws Exception { + syncGetBackup(); + } + + public static void syncGetBackup() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + GetBackupRequest request = + GetBackupRequest.newBuilder() + .setName( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .build(); + Backup response = backupForGKEClient.getBackup(request); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getbackup_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackup/SyncGetBackupBackupname.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackup/SyncGetBackupBackupname.java new file mode 100644 index 0000000..a8bde94 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackup/SyncGetBackupBackupname.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getbackup_backupname_sync] +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupName; + +public class SyncGetBackupBackupname { + + public static void main(String[] args) throws Exception { + syncGetBackupBackupname(); + } + + public static void syncGetBackupBackupname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]"); + Backup response = backupForGKEClient.getBackup(name); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getbackup_backupname_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackup/SyncGetBackupString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackup/SyncGetBackupString.java new file mode 100644 index 0000000..258ea4c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackup/SyncGetBackupString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getbackup_string_sync] +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupName; + +public class SyncGetBackupString { + + public static void main(String[] args) throws Exception { + syncGetBackupString(); + } + + public static void syncGetBackupString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String name = + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString(); + Backup response = backupForGKEClient.getBackup(name); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getbackup_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackupplan/AsyncGetBackupPlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackupplan/AsyncGetBackupPlan.java new file mode 100644 index 0000000..5fcb5a2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackupplan/AsyncGetBackupPlan.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getbackupplan_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.BackupPlanName; +import com.google.cloud.gkebackup.v1.GetBackupPlanRequest; + +public class AsyncGetBackupPlan { + + public static void main(String[] args) throws Exception { + asyncGetBackupPlan(); + } + + public static void asyncGetBackupPlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + GetBackupPlanRequest request = + GetBackupPlanRequest.newBuilder() + .setName(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .build(); + ApiFuture future = backupForGKEClient.getBackupPlanCallable().futureCall(request); + // Do something. + BackupPlan response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getbackupplan_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackupplan/SyncGetBackupPlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackupplan/SyncGetBackupPlan.java new file mode 100644 index 0000000..ab13acd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackupplan/SyncGetBackupPlan.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getbackupplan_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.BackupPlanName; +import com.google.cloud.gkebackup.v1.GetBackupPlanRequest; + +public class SyncGetBackupPlan { + + public static void main(String[] args) throws Exception { + syncGetBackupPlan(); + } + + public static void syncGetBackupPlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + GetBackupPlanRequest request = + GetBackupPlanRequest.newBuilder() + .setName(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .build(); + BackupPlan response = backupForGKEClient.getBackupPlan(request); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getbackupplan_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackupplan/SyncGetBackupPlanBackupplanname.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackupplan/SyncGetBackupPlanBackupplanname.java new file mode 100644 index 0000000..8394614 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackupplan/SyncGetBackupPlanBackupplanname.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getbackupplan_backupplanname_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.BackupPlanName; + +public class SyncGetBackupPlanBackupplanname { + + public static void main(String[] args) throws Exception { + syncGetBackupPlanBackupplanname(); + } + + public static void syncGetBackupPlanBackupplanname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + BackupPlanName name = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]"); + BackupPlan response = backupForGKEClient.getBackupPlan(name); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getbackupplan_backupplanname_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackupplan/SyncGetBackupPlanString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackupplan/SyncGetBackupPlanString.java new file mode 100644 index 0000000..989b888 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getbackupplan/SyncGetBackupPlanString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getbackupplan_string_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.BackupPlanName; + +public class SyncGetBackupPlanString { + + public static void main(String[] args) throws Exception { + syncGetBackupPlanString(); + } + + public static void syncGetBackupPlanString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String name = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString(); + BackupPlan response = backupForGKEClient.getBackupPlan(name); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getbackupplan_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestore/AsyncGetRestore.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestore/AsyncGetRestore.java new file mode 100644 index 0000000..a7d8b42 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestore/AsyncGetRestore.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getrestore_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.GetRestoreRequest; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestoreName; + +public class AsyncGetRestore { + + public static void main(String[] args) throws Exception { + asyncGetRestore(); + } + + public static void asyncGetRestore() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + GetRestoreRequest request = + GetRestoreRequest.newBuilder() + .setName( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]") + .toString()) + .build(); + ApiFuture future = backupForGKEClient.getRestoreCallable().futureCall(request); + // Do something. + Restore response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getrestore_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestore/SyncGetRestore.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestore/SyncGetRestore.java new file mode 100644 index 0000000..f7671ee --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestore/SyncGetRestore.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getrestore_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.GetRestoreRequest; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestoreName; + +public class SyncGetRestore { + + public static void main(String[] args) throws Exception { + syncGetRestore(); + } + + public static void syncGetRestore() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + GetRestoreRequest request = + GetRestoreRequest.newBuilder() + .setName( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]") + .toString()) + .build(); + Restore response = backupForGKEClient.getRestore(request); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getrestore_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestore/SyncGetRestoreRestorename.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestore/SyncGetRestoreRestorename.java new file mode 100644 index 0000000..8898955 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestore/SyncGetRestoreRestorename.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getrestore_restorename_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestoreName; + +public class SyncGetRestoreRestorename { + + public static void main(String[] args) throws Exception { + syncGetRestoreRestorename(); + } + + public static void syncGetRestoreRestorename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + RestoreName name = RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]"); + Restore response = backupForGKEClient.getRestore(name); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getrestore_restorename_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestore/SyncGetRestoreString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestore/SyncGetRestoreString.java new file mode 100644 index 0000000..6634bb2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestore/SyncGetRestoreString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getrestore_string_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestoreName; + +public class SyncGetRestoreString { + + public static void main(String[] args) throws Exception { + syncGetRestoreString(); + } + + public static void syncGetRestoreString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String name = + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]").toString(); + Restore response = backupForGKEClient.getRestore(name); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getrestore_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestoreplan/AsyncGetRestorePlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestoreplan/AsyncGetRestorePlan.java new file mode 100644 index 0000000..f23c62c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestoreplan/AsyncGetRestorePlan.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getrestoreplan_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.GetRestorePlanRequest; +import com.google.cloud.gkebackup.v1.RestorePlan; +import com.google.cloud.gkebackup.v1.RestorePlanName; + +public class AsyncGetRestorePlan { + + public static void main(String[] args) throws Exception { + asyncGetRestorePlan(); + } + + public static void asyncGetRestorePlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + GetRestorePlanRequest request = + GetRestorePlanRequest.newBuilder() + .setName(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .build(); + ApiFuture future = + backupForGKEClient.getRestorePlanCallable().futureCall(request); + // Do something. + RestorePlan response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getrestoreplan_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestoreplan/SyncGetRestorePlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestoreplan/SyncGetRestorePlan.java new file mode 100644 index 0000000..99c1762 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestoreplan/SyncGetRestorePlan.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getrestoreplan_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.GetRestorePlanRequest; +import com.google.cloud.gkebackup.v1.RestorePlan; +import com.google.cloud.gkebackup.v1.RestorePlanName; + +public class SyncGetRestorePlan { + + public static void main(String[] args) throws Exception { + syncGetRestorePlan(); + } + + public static void syncGetRestorePlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + GetRestorePlanRequest request = + GetRestorePlanRequest.newBuilder() + .setName(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .build(); + RestorePlan response = backupForGKEClient.getRestorePlan(request); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getrestoreplan_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestoreplan/SyncGetRestorePlanRestoreplanname.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestoreplan/SyncGetRestorePlanRestoreplanname.java new file mode 100644 index 0000000..7457c4a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestoreplan/SyncGetRestorePlanRestoreplanname.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getrestoreplan_restoreplanname_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.RestorePlan; +import com.google.cloud.gkebackup.v1.RestorePlanName; + +public class SyncGetRestorePlanRestoreplanname { + + public static void main(String[] args) throws Exception { + syncGetRestorePlanRestoreplanname(); + } + + public static void syncGetRestorePlanRestoreplanname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + RestorePlanName name = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]"); + RestorePlan response = backupForGKEClient.getRestorePlan(name); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getrestoreplan_restoreplanname_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestoreplan/SyncGetRestorePlanString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestoreplan/SyncGetRestorePlanString.java new file mode 100644 index 0000000..f4a75a7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getrestoreplan/SyncGetRestorePlanString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getrestoreplan_string_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.RestorePlan; +import com.google.cloud.gkebackup.v1.RestorePlanName; + +public class SyncGetRestorePlanString { + + public static void main(String[] args) throws Exception { + syncGetRestorePlanString(); + } + + public static void syncGetRestorePlanString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String name = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString(); + RestorePlan response = backupForGKEClient.getRestorePlan(name); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getrestoreplan_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumebackup/AsyncGetVolumeBackup.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumebackup/AsyncGetVolumeBackup.java new file mode 100644 index 0000000..af3e814 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumebackup/AsyncGetVolumeBackup.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getvolumebackup_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.GetVolumeBackupRequest; +import com.google.cloud.gkebackup.v1.VolumeBackup; +import com.google.cloud.gkebackup.v1.VolumeBackupName; + +public class AsyncGetVolumeBackup { + + public static void main(String[] args) throws Exception { + asyncGetVolumeBackup(); + } + + public static void asyncGetVolumeBackup() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + GetVolumeBackupRequest request = + GetVolumeBackupRequest.newBuilder() + .setName( + VolumeBackupName.of( + "[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]", "[VOLUME_BACKUP]") + .toString()) + .build(); + ApiFuture future = + backupForGKEClient.getVolumeBackupCallable().futureCall(request); + // Do something. + VolumeBackup response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getvolumebackup_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumebackup/SyncGetVolumeBackup.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumebackup/SyncGetVolumeBackup.java new file mode 100644 index 0000000..79e3d2e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumebackup/SyncGetVolumeBackup.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getvolumebackup_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.GetVolumeBackupRequest; +import com.google.cloud.gkebackup.v1.VolumeBackup; +import com.google.cloud.gkebackup.v1.VolumeBackupName; + +public class SyncGetVolumeBackup { + + public static void main(String[] args) throws Exception { + syncGetVolumeBackup(); + } + + public static void syncGetVolumeBackup() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + GetVolumeBackupRequest request = + GetVolumeBackupRequest.newBuilder() + .setName( + VolumeBackupName.of( + "[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]", "[VOLUME_BACKUP]") + .toString()) + .build(); + VolumeBackup response = backupForGKEClient.getVolumeBackup(request); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getvolumebackup_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumebackup/SyncGetVolumeBackupString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumebackup/SyncGetVolumeBackupString.java new file mode 100644 index 0000000..248a50d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumebackup/SyncGetVolumeBackupString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getvolumebackup_string_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.VolumeBackup; +import com.google.cloud.gkebackup.v1.VolumeBackupName; + +public class SyncGetVolumeBackupString { + + public static void main(String[] args) throws Exception { + syncGetVolumeBackupString(); + } + + public static void syncGetVolumeBackupString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String name = + VolumeBackupName.of( + "[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]", "[VOLUME_BACKUP]") + .toString(); + VolumeBackup response = backupForGKEClient.getVolumeBackup(name); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getvolumebackup_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumebackup/SyncGetVolumeBackupVolumebackupname.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumebackup/SyncGetVolumeBackupVolumebackupname.java new file mode 100644 index 0000000..d3c0234 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumebackup/SyncGetVolumeBackupVolumebackupname.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getvolumebackup_volumebackupname_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.VolumeBackup; +import com.google.cloud.gkebackup.v1.VolumeBackupName; + +public class SyncGetVolumeBackupVolumebackupname { + + public static void main(String[] args) throws Exception { + syncGetVolumeBackupVolumebackupname(); + } + + public static void syncGetVolumeBackupVolumebackupname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + VolumeBackupName name = + VolumeBackupName.of( + "[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]", "[VOLUME_BACKUP]"); + VolumeBackup response = backupForGKEClient.getVolumeBackup(name); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getvolumebackup_volumebackupname_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumerestore/AsyncGetVolumeRestore.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumerestore/AsyncGetVolumeRestore.java new file mode 100644 index 0000000..1910214 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumerestore/AsyncGetVolumeRestore.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getvolumerestore_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.GetVolumeRestoreRequest; +import com.google.cloud.gkebackup.v1.VolumeRestore; +import com.google.cloud.gkebackup.v1.VolumeRestoreName; + +public class AsyncGetVolumeRestore { + + public static void main(String[] args) throws Exception { + asyncGetVolumeRestore(); + } + + public static void asyncGetVolumeRestore() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + GetVolumeRestoreRequest request = + GetVolumeRestoreRequest.newBuilder() + .setName( + VolumeRestoreName.of( + "[PROJECT]", + "[LOCATION]", + "[RESTORE_PLAN]", + "[RESTORE]", + "[VOLUME_RESTORE]") + .toString()) + .build(); + ApiFuture future = + backupForGKEClient.getVolumeRestoreCallable().futureCall(request); + // Do something. + VolumeRestore response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getvolumerestore_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumerestore/SyncGetVolumeRestore.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumerestore/SyncGetVolumeRestore.java new file mode 100644 index 0000000..66c3559 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumerestore/SyncGetVolumeRestore.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getvolumerestore_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.GetVolumeRestoreRequest; +import com.google.cloud.gkebackup.v1.VolumeRestore; +import com.google.cloud.gkebackup.v1.VolumeRestoreName; + +public class SyncGetVolumeRestore { + + public static void main(String[] args) throws Exception { + syncGetVolumeRestore(); + } + + public static void syncGetVolumeRestore() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + GetVolumeRestoreRequest request = + GetVolumeRestoreRequest.newBuilder() + .setName( + VolumeRestoreName.of( + "[PROJECT]", + "[LOCATION]", + "[RESTORE_PLAN]", + "[RESTORE]", + "[VOLUME_RESTORE]") + .toString()) + .build(); + VolumeRestore response = backupForGKEClient.getVolumeRestore(request); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getvolumerestore_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumerestore/SyncGetVolumeRestoreString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumerestore/SyncGetVolumeRestoreString.java new file mode 100644 index 0000000..423ae9b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumerestore/SyncGetVolumeRestoreString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getvolumerestore_string_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.VolumeRestore; +import com.google.cloud.gkebackup.v1.VolumeRestoreName; + +public class SyncGetVolumeRestoreString { + + public static void main(String[] args) throws Exception { + syncGetVolumeRestoreString(); + } + + public static void syncGetVolumeRestoreString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String name = + VolumeRestoreName.of( + "[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]", "[VOLUME_RESTORE]") + .toString(); + VolumeRestore response = backupForGKEClient.getVolumeRestore(name); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getvolumerestore_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumerestore/SyncGetVolumeRestoreVolumerestorename.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumerestore/SyncGetVolumeRestoreVolumerestorename.java new file mode 100644 index 0000000..b7b2a4d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/getvolumerestore/SyncGetVolumeRestoreVolumerestorename.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_getvolumerestore_volumerestorename_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.VolumeRestore; +import com.google.cloud.gkebackup.v1.VolumeRestoreName; + +public class SyncGetVolumeRestoreVolumerestorename { + + public static void main(String[] args) throws Exception { + syncGetVolumeRestoreVolumerestorename(); + } + + public static void syncGetVolumeRestoreVolumerestorename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + VolumeRestoreName name = + VolumeRestoreName.of( + "[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]", "[VOLUME_RESTORE]"); + VolumeRestore response = backupForGKEClient.getVolumeRestore(name); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_getvolumerestore_volumerestorename_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/AsyncListBackupPlans.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/AsyncListBackupPlans.java new file mode 100644 index 0000000..2a29634 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/AsyncListBackupPlans.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listbackupplans_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.ListBackupPlansRequest; +import com.google.cloud.gkebackup.v1.LocationName; + +public class AsyncListBackupPlans { + + public static void main(String[] args) throws Exception { + asyncListBackupPlans(); + } + + public static void asyncListBackupPlans() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListBackupPlansRequest request = + ListBackupPlansRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + backupForGKEClient.listBackupPlansPagedCallable().futureCall(request); + // Do something. + for (BackupPlan element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listbackupplans_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/AsyncListBackupPlansPaged.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/AsyncListBackupPlansPaged.java new file mode 100644 index 0000000..ca136f3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/AsyncListBackupPlansPaged.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listbackupplans_paged_async] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.ListBackupPlansRequest; +import com.google.cloud.gkebackup.v1.ListBackupPlansResponse; +import com.google.cloud.gkebackup.v1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListBackupPlansPaged { + + public static void main(String[] args) throws Exception { + asyncListBackupPlansPaged(); + } + + public static void asyncListBackupPlansPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListBackupPlansRequest request = + ListBackupPlansRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListBackupPlansResponse response = + backupForGKEClient.listBackupPlansCallable().call(request); + for (BackupPlan element : response.getBackupPlansList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listbackupplans_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/SyncListBackupPlans.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/SyncListBackupPlans.java new file mode 100644 index 0000000..f18bb61 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/SyncListBackupPlans.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listbackupplans_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.ListBackupPlansRequest; +import com.google.cloud.gkebackup.v1.LocationName; + +public class SyncListBackupPlans { + + public static void main(String[] args) throws Exception { + syncListBackupPlans(); + } + + public static void syncListBackupPlans() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListBackupPlansRequest request = + ListBackupPlansRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (BackupPlan element : backupForGKEClient.listBackupPlans(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listbackupplans_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/SyncListBackupPlansLocationname.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/SyncListBackupPlansLocationname.java new file mode 100644 index 0000000..c5b8e60 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/SyncListBackupPlansLocationname.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listbackupplans_locationname_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.LocationName; + +public class SyncListBackupPlansLocationname { + + public static void main(String[] args) throws Exception { + syncListBackupPlansLocationname(); + } + + public static void syncListBackupPlansLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (BackupPlan element : backupForGKEClient.listBackupPlans(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listbackupplans_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/SyncListBackupPlansString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/SyncListBackupPlansString.java new file mode 100644 index 0000000..2ad5a59 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackupplans/SyncListBackupPlansString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listbackupplans_string_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.LocationName; + +public class SyncListBackupPlansString { + + public static void main(String[] args) throws Exception { + syncListBackupPlansString(); + } + + public static void syncListBackupPlansString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (BackupPlan element : backupForGKEClient.listBackupPlans(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listbackupplans_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/AsyncListBackups.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/AsyncListBackups.java new file mode 100644 index 0000000..55ed4c9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/AsyncListBackups.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listbackups_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; +import com.google.cloud.gkebackup.v1.ListBackupsRequest; + +public class AsyncListBackups { + + public static void main(String[] args) throws Exception { + asyncListBackups(); + } + + public static void asyncListBackups() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListBackupsRequest request = + ListBackupsRequest.newBuilder() + .setParent(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = backupForGKEClient.listBackupsPagedCallable().futureCall(request); + // Do something. + for (Backup element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listbackups_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/AsyncListBackupsPaged.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/AsyncListBackupsPaged.java new file mode 100644 index 0000000..d32378c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/AsyncListBackupsPaged.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listbackups_paged_async] +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; +import com.google.cloud.gkebackup.v1.ListBackupsRequest; +import com.google.cloud.gkebackup.v1.ListBackupsResponse; +import com.google.common.base.Strings; + +public class AsyncListBackupsPaged { + + public static void main(String[] args) throws Exception { + asyncListBackupsPaged(); + } + + public static void asyncListBackupsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListBackupsRequest request = + ListBackupsRequest.newBuilder() + .setParent(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListBackupsResponse response = backupForGKEClient.listBackupsCallable().call(request); + for (Backup element : response.getBackupsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listbackups_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/SyncListBackups.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/SyncListBackups.java new file mode 100644 index 0000000..faa7415 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/SyncListBackups.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listbackups_sync] +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; +import com.google.cloud.gkebackup.v1.ListBackupsRequest; + +public class SyncListBackups { + + public static void main(String[] args) throws Exception { + syncListBackups(); + } + + public static void syncListBackups() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListBackupsRequest request = + ListBackupsRequest.newBuilder() + .setParent(BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Backup element : backupForGKEClient.listBackups(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listbackups_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/SyncListBackupsBackupplanname.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/SyncListBackupsBackupplanname.java new file mode 100644 index 0000000..4778121 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/SyncListBackupsBackupplanname.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listbackups_backupplanname_sync] +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; + +public class SyncListBackupsBackupplanname { + + public static void main(String[] args) throws Exception { + syncListBackupsBackupplanname(); + } + + public static void syncListBackupsBackupplanname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + BackupPlanName parent = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]"); + for (Backup element : backupForGKEClient.listBackups(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listbackups_backupplanname_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/SyncListBackupsString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/SyncListBackupsString.java new file mode 100644 index 0000000..6815764 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listbackups/SyncListBackupsString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listbackups_string_sync] +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlanName; + +public class SyncListBackupsString { + + public static void main(String[] args) throws Exception { + syncListBackupsString(); + } + + public static void syncListBackupsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String parent = BackupPlanName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]").toString(); + for (Backup element : backupForGKEClient.listBackups(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listbackups_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/AsyncListRestorePlans.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/AsyncListRestorePlans.java new file mode 100644 index 0000000..53a4f17 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/AsyncListRestorePlans.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listrestoreplans_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.ListRestorePlansRequest; +import com.google.cloud.gkebackup.v1.LocationName; +import com.google.cloud.gkebackup.v1.RestorePlan; + +public class AsyncListRestorePlans { + + public static void main(String[] args) throws Exception { + asyncListRestorePlans(); + } + + public static void asyncListRestorePlans() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListRestorePlansRequest request = + ListRestorePlansRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + backupForGKEClient.listRestorePlansPagedCallable().futureCall(request); + // Do something. + for (RestorePlan element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listrestoreplans_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/AsyncListRestorePlansPaged.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/AsyncListRestorePlansPaged.java new file mode 100644 index 0000000..8f1aeec --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/AsyncListRestorePlansPaged.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listrestoreplans_paged_async] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.ListRestorePlansRequest; +import com.google.cloud.gkebackup.v1.ListRestorePlansResponse; +import com.google.cloud.gkebackup.v1.LocationName; +import com.google.cloud.gkebackup.v1.RestorePlan; +import com.google.common.base.Strings; + +public class AsyncListRestorePlansPaged { + + public static void main(String[] args) throws Exception { + asyncListRestorePlansPaged(); + } + + public static void asyncListRestorePlansPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListRestorePlansRequest request = + ListRestorePlansRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListRestorePlansResponse response = + backupForGKEClient.listRestorePlansCallable().call(request); + for (RestorePlan element : response.getRestorePlansList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listrestoreplans_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/SyncListRestorePlans.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/SyncListRestorePlans.java new file mode 100644 index 0000000..b4fe4a6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/SyncListRestorePlans.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listrestoreplans_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.ListRestorePlansRequest; +import com.google.cloud.gkebackup.v1.LocationName; +import com.google.cloud.gkebackup.v1.RestorePlan; + +public class SyncListRestorePlans { + + public static void main(String[] args) throws Exception { + syncListRestorePlans(); + } + + public static void syncListRestorePlans() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListRestorePlansRequest request = + ListRestorePlansRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (RestorePlan element : backupForGKEClient.listRestorePlans(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listrestoreplans_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/SyncListRestorePlansLocationname.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/SyncListRestorePlansLocationname.java new file mode 100644 index 0000000..4b3f305 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/SyncListRestorePlansLocationname.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listrestoreplans_locationname_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.LocationName; +import com.google.cloud.gkebackup.v1.RestorePlan; + +public class SyncListRestorePlansLocationname { + + public static void main(String[] args) throws Exception { + syncListRestorePlansLocationname(); + } + + public static void syncListRestorePlansLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (RestorePlan element : backupForGKEClient.listRestorePlans(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listrestoreplans_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/SyncListRestorePlansString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/SyncListRestorePlansString.java new file mode 100644 index 0000000..dae3d9e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestoreplans/SyncListRestorePlansString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listrestoreplans_string_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.LocationName; +import com.google.cloud.gkebackup.v1.RestorePlan; + +public class SyncListRestorePlansString { + + public static void main(String[] args) throws Exception { + syncListRestorePlansString(); + } + + public static void syncListRestorePlansString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (RestorePlan element : backupForGKEClient.listRestorePlans(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listrestoreplans_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/AsyncListRestores.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/AsyncListRestores.java new file mode 100644 index 0000000..bb03164 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/AsyncListRestores.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listrestores_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.ListRestoresRequest; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestorePlanName; + +public class AsyncListRestores { + + public static void main(String[] args) throws Exception { + asyncListRestores(); + } + + public static void asyncListRestores() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListRestoresRequest request = + ListRestoresRequest.newBuilder() + .setParent(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + backupForGKEClient.listRestoresPagedCallable().futureCall(request); + // Do something. + for (Restore element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listrestores_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/AsyncListRestoresPaged.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/AsyncListRestoresPaged.java new file mode 100644 index 0000000..df9ece7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/AsyncListRestoresPaged.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listrestores_paged_async] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.ListRestoresRequest; +import com.google.cloud.gkebackup.v1.ListRestoresResponse; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestorePlanName; +import com.google.common.base.Strings; + +public class AsyncListRestoresPaged { + + public static void main(String[] args) throws Exception { + asyncListRestoresPaged(); + } + + public static void asyncListRestoresPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListRestoresRequest request = + ListRestoresRequest.newBuilder() + .setParent(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListRestoresResponse response = backupForGKEClient.listRestoresCallable().call(request); + for (Restore element : response.getRestoresList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listrestores_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/SyncListRestores.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/SyncListRestores.java new file mode 100644 index 0000000..b2572e4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/SyncListRestores.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listrestores_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.ListRestoresRequest; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestorePlanName; + +public class SyncListRestores { + + public static void main(String[] args) throws Exception { + syncListRestores(); + } + + public static void syncListRestores() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListRestoresRequest request = + ListRestoresRequest.newBuilder() + .setParent(RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (Restore element : backupForGKEClient.listRestores(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listrestores_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/SyncListRestoresRestoreplanname.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/SyncListRestoresRestoreplanname.java new file mode 100644 index 0000000..0a1a31f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/SyncListRestoresRestoreplanname.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listrestores_restoreplanname_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestorePlanName; + +public class SyncListRestoresRestoreplanname { + + public static void main(String[] args) throws Exception { + syncListRestoresRestoreplanname(); + } + + public static void syncListRestoresRestoreplanname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + RestorePlanName parent = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]"); + for (Restore element : backupForGKEClient.listRestores(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listrestores_restoreplanname_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/SyncListRestoresString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/SyncListRestoresString.java new file mode 100644 index 0000000..31fee2e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listrestores/SyncListRestoresString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listrestores_string_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.RestorePlanName; + +public class SyncListRestoresString { + + public static void main(String[] args) throws Exception { + syncListRestoresString(); + } + + public static void syncListRestoresString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String parent = RestorePlanName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]").toString(); + for (Restore element : backupForGKEClient.listRestores(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listrestores_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/AsyncListVolumeBackups.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/AsyncListVolumeBackups.java new file mode 100644 index 0000000..861c18a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/AsyncListVolumeBackups.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listvolumebackups_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupName; +import com.google.cloud.gkebackup.v1.ListVolumeBackupsRequest; +import com.google.cloud.gkebackup.v1.VolumeBackup; + +public class AsyncListVolumeBackups { + + public static void main(String[] args) throws Exception { + asyncListVolumeBackups(); + } + + public static void asyncListVolumeBackups() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListVolumeBackupsRequest request = + ListVolumeBackupsRequest.newBuilder() + .setParent( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + backupForGKEClient.listVolumeBackupsPagedCallable().futureCall(request); + // Do something. + for (VolumeBackup element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listvolumebackups_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/AsyncListVolumeBackupsPaged.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/AsyncListVolumeBackupsPaged.java new file mode 100644 index 0000000..a92486d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/AsyncListVolumeBackupsPaged.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listvolumebackups_paged_async] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupName; +import com.google.cloud.gkebackup.v1.ListVolumeBackupsRequest; +import com.google.cloud.gkebackup.v1.ListVolumeBackupsResponse; +import com.google.cloud.gkebackup.v1.VolumeBackup; +import com.google.common.base.Strings; + +public class AsyncListVolumeBackupsPaged { + + public static void main(String[] args) throws Exception { + asyncListVolumeBackupsPaged(); + } + + public static void asyncListVolumeBackupsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListVolumeBackupsRequest request = + ListVolumeBackupsRequest.newBuilder() + .setParent( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListVolumeBackupsResponse response = + backupForGKEClient.listVolumeBackupsCallable().call(request); + for (VolumeBackup element : response.getVolumeBackupsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listvolumebackups_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/SyncListVolumeBackups.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/SyncListVolumeBackups.java new file mode 100644 index 0000000..a1dab3f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/SyncListVolumeBackups.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listvolumebackups_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupName; +import com.google.cloud.gkebackup.v1.ListVolumeBackupsRequest; +import com.google.cloud.gkebackup.v1.VolumeBackup; + +public class SyncListVolumeBackups { + + public static void main(String[] args) throws Exception { + syncListVolumeBackups(); + } + + public static void syncListVolumeBackups() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListVolumeBackupsRequest request = + ListVolumeBackupsRequest.newBuilder() + .setParent( + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (VolumeBackup element : backupForGKEClient.listVolumeBackups(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listvolumebackups_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/SyncListVolumeBackupsBackupname.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/SyncListVolumeBackupsBackupname.java new file mode 100644 index 0000000..c138fb2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/SyncListVolumeBackupsBackupname.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listvolumebackups_backupname_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupName; +import com.google.cloud.gkebackup.v1.VolumeBackup; + +public class SyncListVolumeBackupsBackupname { + + public static void main(String[] args) throws Exception { + syncListVolumeBackupsBackupname(); + } + + public static void syncListVolumeBackupsBackupname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + BackupName parent = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]"); + for (VolumeBackup element : backupForGKEClient.listVolumeBackups(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listvolumebackups_backupname_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/SyncListVolumeBackupsString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/SyncListVolumeBackupsString.java new file mode 100644 index 0000000..1ca37cb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumebackups/SyncListVolumeBackupsString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listvolumebackups_string_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupName; +import com.google.cloud.gkebackup.v1.VolumeBackup; + +public class SyncListVolumeBackupsString { + + public static void main(String[] args) throws Exception { + syncListVolumeBackupsString(); + } + + public static void syncListVolumeBackupsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String parent = + BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP_PLAN]", "[BACKUP]").toString(); + for (VolumeBackup element : backupForGKEClient.listVolumeBackups(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listvolumebackups_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/AsyncListVolumeRestores.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/AsyncListVolumeRestores.java new file mode 100644 index 0000000..a3baf10 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/AsyncListVolumeRestores.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listvolumerestores_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.ListVolumeRestoresRequest; +import com.google.cloud.gkebackup.v1.RestoreName; +import com.google.cloud.gkebackup.v1.VolumeRestore; + +public class AsyncListVolumeRestores { + + public static void main(String[] args) throws Exception { + asyncListVolumeRestores(); + } + + public static void asyncListVolumeRestores() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListVolumeRestoresRequest request = + ListVolumeRestoresRequest.newBuilder() + .setParent( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + backupForGKEClient.listVolumeRestoresPagedCallable().futureCall(request); + // Do something. + for (VolumeRestore element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listvolumerestores_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/AsyncListVolumeRestoresPaged.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/AsyncListVolumeRestoresPaged.java new file mode 100644 index 0000000..59b7815 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/AsyncListVolumeRestoresPaged.java @@ -0,0 +1,63 @@ +/* + * 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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listvolumerestores_paged_async] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.ListVolumeRestoresRequest; +import com.google.cloud.gkebackup.v1.ListVolumeRestoresResponse; +import com.google.cloud.gkebackup.v1.RestoreName; +import com.google.cloud.gkebackup.v1.VolumeRestore; +import com.google.common.base.Strings; + +public class AsyncListVolumeRestoresPaged { + + public static void main(String[] args) throws Exception { + asyncListVolumeRestoresPaged(); + } + + public static void asyncListVolumeRestoresPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListVolumeRestoresRequest request = + ListVolumeRestoresRequest.newBuilder() + .setParent( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListVolumeRestoresResponse response = + backupForGKEClient.listVolumeRestoresCallable().call(request); + for (VolumeRestore element : response.getVolumeRestoresList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listvolumerestores_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/SyncListVolumeRestores.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/SyncListVolumeRestores.java new file mode 100644 index 0000000..802760a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/SyncListVolumeRestores.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listvolumerestores_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.ListVolumeRestoresRequest; +import com.google.cloud.gkebackup.v1.RestoreName; +import com.google.cloud.gkebackup.v1.VolumeRestore; + +public class SyncListVolumeRestores { + + public static void main(String[] args) throws Exception { + syncListVolumeRestores(); + } + + public static void syncListVolumeRestores() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + ListVolumeRestoresRequest request = + ListVolumeRestoresRequest.newBuilder() + .setParent( + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (VolumeRestore element : backupForGKEClient.listVolumeRestores(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listvolumerestores_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/SyncListVolumeRestoresRestorename.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/SyncListVolumeRestoresRestorename.java new file mode 100644 index 0000000..d853071 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/SyncListVolumeRestoresRestorename.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listvolumerestores_restorename_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.RestoreName; +import com.google.cloud.gkebackup.v1.VolumeRestore; + +public class SyncListVolumeRestoresRestorename { + + public static void main(String[] args) throws Exception { + syncListVolumeRestoresRestorename(); + } + + public static void syncListVolumeRestoresRestorename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + RestoreName parent = RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]"); + for (VolumeRestore element : backupForGKEClient.listVolumeRestores(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listvolumerestores_restorename_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/SyncListVolumeRestoresString.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/SyncListVolumeRestoresString.java new file mode 100644 index 0000000..260c6c0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/listvolumerestores/SyncListVolumeRestoresString.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_listvolumerestores_string_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.RestoreName; +import com.google.cloud.gkebackup.v1.VolumeRestore; + +public class SyncListVolumeRestoresString { + + public static void main(String[] args) throws Exception { + syncListVolumeRestoresString(); + } + + public static void syncListVolumeRestoresString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + String parent = + RestoreName.of("[PROJECT]", "[LOCATION]", "[RESTORE_PLAN]", "[RESTORE]").toString(); + for (VolumeRestore element : backupForGKEClient.listVolumeRestores(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_listvolumerestores_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackup/AsyncUpdateBackup.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackup/AsyncUpdateBackup.java new file mode 100644 index 0000000..033c118 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackup/AsyncUpdateBackup.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updatebackup_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.UpdateBackupRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateBackup { + + public static void main(String[] args) throws Exception { + asyncUpdateBackup(); + } + + public static void asyncUpdateBackup() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + UpdateBackupRequest request = + UpdateBackupRequest.newBuilder() + .setBackup(Backup.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = backupForGKEClient.updateBackupCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updatebackup_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackup/AsyncUpdateBackupLRO.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackup/AsyncUpdateBackupLRO.java new file mode 100644 index 0000000..2a10014 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackup/AsyncUpdateBackupLRO.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updatebackup_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.OperationMetadata; +import com.google.cloud.gkebackup.v1.UpdateBackupRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateBackupLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateBackupLRO(); + } + + public static void asyncUpdateBackupLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + UpdateBackupRequest request = + UpdateBackupRequest.newBuilder() + .setBackup(Backup.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + backupForGKEClient.updateBackupOperationCallable().futureCall(request); + // Do something. + Backup response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updatebackup_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackup/SyncUpdateBackup.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackup/SyncUpdateBackup.java new file mode 100644 index 0000000..c5677a0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackup/SyncUpdateBackup.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updatebackup_sync] +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.UpdateBackupRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateBackup { + + public static void main(String[] args) throws Exception { + syncUpdateBackup(); + } + + public static void syncUpdateBackup() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + UpdateBackupRequest request = + UpdateBackupRequest.newBuilder() + .setBackup(Backup.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Backup response = backupForGKEClient.updateBackupAsync(request).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updatebackup_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackup/SyncUpdateBackupBackupFieldmask.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackup/SyncUpdateBackupBackupFieldmask.java new file mode 100644 index 0000000..e6ed32a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackup/SyncUpdateBackupBackupFieldmask.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updatebackup_backupfieldmask_sync] +import com.google.cloud.gkebackup.v1.Backup; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateBackupBackupFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateBackupBackupFieldmask(); + } + + public static void syncUpdateBackupBackupFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + Backup backup = Backup.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Backup response = backupForGKEClient.updateBackupAsync(backup, updateMask).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updatebackup_backupfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackupplan/AsyncUpdateBackupPlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackupplan/AsyncUpdateBackupPlan.java new file mode 100644 index 0000000..72e15dd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackupplan/AsyncUpdateBackupPlan.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updatebackupplan_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.UpdateBackupPlanRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateBackupPlan { + + public static void main(String[] args) throws Exception { + asyncUpdateBackupPlan(); + } + + public static void asyncUpdateBackupPlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + UpdateBackupPlanRequest request = + UpdateBackupPlanRequest.newBuilder() + .setBackupPlan(BackupPlan.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + backupForGKEClient.updateBackupPlanCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updatebackupplan_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackupplan/AsyncUpdateBackupPlanLRO.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackupplan/AsyncUpdateBackupPlanLRO.java new file mode 100644 index 0000000..b698b72 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackupplan/AsyncUpdateBackupPlanLRO.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updatebackupplan_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.OperationMetadata; +import com.google.cloud.gkebackup.v1.UpdateBackupPlanRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateBackupPlanLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateBackupPlanLRO(); + } + + public static void asyncUpdateBackupPlanLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + UpdateBackupPlanRequest request = + UpdateBackupPlanRequest.newBuilder() + .setBackupPlan(BackupPlan.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + backupForGKEClient.updateBackupPlanOperationCallable().futureCall(request); + // Do something. + BackupPlan response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updatebackupplan_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackupplan/SyncUpdateBackupPlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackupplan/SyncUpdateBackupPlan.java new file mode 100644 index 0000000..1d08803 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackupplan/SyncUpdateBackupPlan.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updatebackupplan_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.cloud.gkebackup.v1.UpdateBackupPlanRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateBackupPlan { + + public static void main(String[] args) throws Exception { + syncUpdateBackupPlan(); + } + + public static void syncUpdateBackupPlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + UpdateBackupPlanRequest request = + UpdateBackupPlanRequest.newBuilder() + .setBackupPlan(BackupPlan.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + BackupPlan response = backupForGKEClient.updateBackupPlanAsync(request).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updatebackupplan_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackupplan/SyncUpdateBackupPlanBackupplanFieldmask.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackupplan/SyncUpdateBackupPlanBackupplanFieldmask.java new file mode 100644 index 0000000..121c007 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updatebackupplan/SyncUpdateBackupPlanBackupplanFieldmask.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updatebackupplan_backupplanfieldmask_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.BackupPlan; +import com.google.protobuf.FieldMask; + +public class SyncUpdateBackupPlanBackupplanFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateBackupPlanBackupplanFieldmask(); + } + + public static void syncUpdateBackupPlanBackupplanFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + BackupPlan backupPlan = BackupPlan.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + BackupPlan response = backupForGKEClient.updateBackupPlanAsync(backupPlan, updateMask).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updatebackupplan_backupplanfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestore/AsyncUpdateRestore.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestore/AsyncUpdateRestore.java new file mode 100644 index 0000000..ae2ef90 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestore/AsyncUpdateRestore.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updaterestore_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.UpdateRestoreRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateRestore { + + public static void main(String[] args) throws Exception { + asyncUpdateRestore(); + } + + public static void asyncUpdateRestore() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + UpdateRestoreRequest request = + UpdateRestoreRequest.newBuilder() + .setRestore(Restore.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = backupForGKEClient.updateRestoreCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updaterestore_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestore/AsyncUpdateRestoreLRO.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestore/AsyncUpdateRestoreLRO.java new file mode 100644 index 0000000..6123773 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestore/AsyncUpdateRestoreLRO.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updaterestore_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.OperationMetadata; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.UpdateRestoreRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateRestoreLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateRestoreLRO(); + } + + public static void asyncUpdateRestoreLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + UpdateRestoreRequest request = + UpdateRestoreRequest.newBuilder() + .setRestore(Restore.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + backupForGKEClient.updateRestoreOperationCallable().futureCall(request); + // Do something. + Restore response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updaterestore_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestore/SyncUpdateRestore.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestore/SyncUpdateRestore.java new file mode 100644 index 0000000..a110e06 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestore/SyncUpdateRestore.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updaterestore_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.cloud.gkebackup.v1.UpdateRestoreRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateRestore { + + public static void main(String[] args) throws Exception { + syncUpdateRestore(); + } + + public static void syncUpdateRestore() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + UpdateRestoreRequest request = + UpdateRestoreRequest.newBuilder() + .setRestore(Restore.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Restore response = backupForGKEClient.updateRestoreAsync(request).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updaterestore_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestore/SyncUpdateRestoreRestoreFieldmask.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestore/SyncUpdateRestoreRestoreFieldmask.java new file mode 100644 index 0000000..237628e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestore/SyncUpdateRestoreRestoreFieldmask.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updaterestore_restorefieldmask_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.Restore; +import com.google.protobuf.FieldMask; + +public class SyncUpdateRestoreRestoreFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateRestoreRestoreFieldmask(); + } + + public static void syncUpdateRestoreRestoreFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + Restore restore = Restore.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Restore response = backupForGKEClient.updateRestoreAsync(restore, updateMask).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updaterestore_restorefieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestoreplan/AsyncUpdateRestorePlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestoreplan/AsyncUpdateRestorePlan.java new file mode 100644 index 0000000..53463e1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestoreplan/AsyncUpdateRestorePlan.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updaterestoreplan_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.RestorePlan; +import com.google.cloud.gkebackup.v1.UpdateRestorePlanRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateRestorePlan { + + public static void main(String[] args) throws Exception { + asyncUpdateRestorePlan(); + } + + public static void asyncUpdateRestorePlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + UpdateRestorePlanRequest request = + UpdateRestorePlanRequest.newBuilder() + .setRestorePlan(RestorePlan.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + backupForGKEClient.updateRestorePlanCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updaterestoreplan_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestoreplan/AsyncUpdateRestorePlanLRO.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestoreplan/AsyncUpdateRestorePlanLRO.java new file mode 100644 index 0000000..85158ba --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestoreplan/AsyncUpdateRestorePlanLRO.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updaterestoreplan_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.OperationMetadata; +import com.google.cloud.gkebackup.v1.RestorePlan; +import com.google.cloud.gkebackup.v1.UpdateRestorePlanRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateRestorePlanLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateRestorePlanLRO(); + } + + public static void asyncUpdateRestorePlanLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + UpdateRestorePlanRequest request = + UpdateRestorePlanRequest.newBuilder() + .setRestorePlan(RestorePlan.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + backupForGKEClient.updateRestorePlanOperationCallable().futureCall(request); + // Do something. + RestorePlan response = future.get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updaterestoreplan_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestoreplan/SyncUpdateRestorePlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestoreplan/SyncUpdateRestorePlan.java new file mode 100644 index 0000000..0c3a664 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestoreplan/SyncUpdateRestorePlan.java @@ -0,0 +1,44 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updaterestoreplan_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.RestorePlan; +import com.google.cloud.gkebackup.v1.UpdateRestorePlanRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateRestorePlan { + + public static void main(String[] args) throws Exception { + syncUpdateRestorePlan(); + } + + public static void syncUpdateRestorePlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + UpdateRestorePlanRequest request = + UpdateRestorePlanRequest.newBuilder() + .setRestorePlan(RestorePlan.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + RestorePlan response = backupForGKEClient.updateRestorePlanAsync(request).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updaterestoreplan_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestoreplan/SyncUpdateRestorePlanRestoreplanFieldmask.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestoreplan/SyncUpdateRestorePlanRestoreplanFieldmask.java new file mode 100644 index 0000000..e167eb5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkeclient/updaterestoreplan/SyncUpdateRestorePlanRestoreplanFieldmask.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkeclient_updaterestoreplan_restoreplanfieldmask_sync] +import com.google.cloud.gkebackup.v1.BackupForGKEClient; +import com.google.cloud.gkebackup.v1.RestorePlan; +import com.google.protobuf.FieldMask; + +public class SyncUpdateRestorePlanRestoreplanFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateRestorePlanRestoreplanFieldmask(); + } + + public static void syncUpdateRestorePlanRestoreplanFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (BackupForGKEClient backupForGKEClient = BackupForGKEClient.create()) { + RestorePlan restorePlan = RestorePlan.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + RestorePlan response = + backupForGKEClient.updateRestorePlanAsync(restorePlan, updateMask).get(); + } + } +} +// [END gkebackup_v1_generated_backupforgkeclient_updaterestoreplan_restoreplanfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkesettings/getbackupplan/SyncGetBackupPlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkesettings/getbackupplan/SyncGetBackupPlan.java new file mode 100644 index 0000000..4662684 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/backupforgkesettings/getbackupplan/SyncGetBackupPlan.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.gkebackup.v1.samples; + +// [START gkebackup_v1_generated_backupforgkesettings_getbackupplan_sync] +import com.google.cloud.gkebackup.v1.BackupForGKESettings; +import java.time.Duration; + +public class SyncGetBackupPlan { + + public static void main(String[] args) throws Exception { + syncGetBackupPlan(); + } + + public static void syncGetBackupPlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + BackupForGKESettings.Builder backupForGKESettingsBuilder = BackupForGKESettings.newBuilder(); + backupForGKESettingsBuilder + .getBackupPlanSettings() + .setRetrySettings( + backupForGKESettingsBuilder + .getBackupPlanSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + BackupForGKESettings backupForGKESettings = backupForGKESettingsBuilder.build(); + } +} +// [END gkebackup_v1_generated_backupforgkesettings_getbackupplan_sync] diff --git a/samples/snippets/generated/com/google/cloud/gkebackup/v1/stub/backupforgkestubsettings/getbackupplan/SyncGetBackupPlan.java b/samples/snippets/generated/com/google/cloud/gkebackup/v1/stub/backupforgkestubsettings/getbackupplan/SyncGetBackupPlan.java new file mode 100644 index 0000000..97b3f41 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/gkebackup/v1/stub/backupforgkestubsettings/getbackupplan/SyncGetBackupPlan.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.gkebackup.v1.stub.samples; + +// [START gkebackup_v1_generated_backupforgkestubsettings_getbackupplan_sync] +import com.google.cloud.gkebackup.v1.stub.BackupForGKEStubSettings; +import java.time.Duration; + +public class SyncGetBackupPlan { + + public static void main(String[] args) throws Exception { + syncGetBackupPlan(); + } + + public static void syncGetBackupPlan() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + BackupForGKEStubSettings.Builder backupForGKESettingsBuilder = + BackupForGKEStubSettings.newBuilder(); + backupForGKESettingsBuilder + .getBackupPlanSettings() + .setRetrySettings( + backupForGKESettingsBuilder + .getBackupPlanSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + BackupForGKEStubSettings backupForGKESettings = backupForGKESettingsBuilder.build(); + } +} +// [END gkebackup_v1_generated_backupforgkestubsettings_getbackupplan_sync]