diff --git a/java-filestore/google-cloud-filestore/pom.xml b/java-filestore/google-cloud-filestore/pom.xml index 0f114a6301e5..c243ed55f77e 100644 --- a/java-filestore/google-cloud-filestore/pom.xml +++ b/java-filestore/google-cloud-filestore/pom.xml @@ -62,6 +62,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -86,12 +90,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/CloudFilestoreManagerClient.java b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/CloudFilestoreManagerClient.java index 5b0fc97c5503..7df30471aef8 100644 --- a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/CloudFilestoreManagerClient.java +++ b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/CloudFilestoreManagerClient.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; @@ -31,7 +32,6 @@ import com.google.cloud.filestore.v1.stub.CloudFilestoreManagerStubSettings; 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; @@ -131,13 +131,29 @@ * CloudFilestoreManagerClient.create(cloudFilestoreManagerSettings); * } * + *

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.
+ * CloudFilestoreManagerSettings cloudFilestoreManagerSettings =
+ *     CloudFilestoreManagerSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CloudFilestoreManagerSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CloudFilestoreManagerClient cloudFilestoreManagerClient =
+ *     CloudFilestoreManagerClient.create(cloudFilestoreManagerSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class CloudFilestoreManagerClient implements BackgroundResource { private final CloudFilestoreManagerSettings settings; private final CloudFilestoreManagerStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of CloudFilestoreManagerClient with default settings. */ public static final CloudFilestoreManagerClient create() throws IOException { @@ -169,13 +185,17 @@ public static final CloudFilestoreManagerClient create(CloudFilestoreManagerStub protected CloudFilestoreManagerClient(CloudFilestoreManagerSettings settings) throws IOException { this.settings = settings; this.stub = ((CloudFilestoreManagerStubSettings) 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 CloudFilestoreManagerClient(CloudFilestoreManagerStub 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 CloudFilestoreManagerSettings getSettings() { @@ -190,10 +210,18 @@ public CloudFilestoreManagerStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all instances in a project for either a specified location or for all locations. diff --git a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/CloudFilestoreManagerSettings.java b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/CloudFilestoreManagerSettings.java index f1ddc02a1a98..be91e7c1c24b 100644 --- a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/CloudFilestoreManagerSettings.java +++ b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/CloudFilestoreManagerSettings.java @@ -24,6 +24,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; @@ -205,11 +206,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CloudFilestoreManagerStubSettings.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 CloudFilestoreManagerStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CloudFilestoreManagerStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CloudFilestoreManagerStubSettings.defaultTransportChannelProvider(); } @@ -219,11 +227,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CloudFilestoreManagerStubSettings.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); @@ -262,6 +276,11 @@ private static Builder createDefault() { return new Builder(CloudFilestoreManagerStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CloudFilestoreManagerStubSettings.newHttpJsonBuilder()); + } + public CloudFilestoreManagerStubSettings.Builder getStubSettingsBuilder() { return ((CloudFilestoreManagerStubSettings.Builder) getStubSettings()); } diff --git a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/stub/CloudFilestoreManagerStub.java b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/stub/CloudFilestoreManagerStub.java index 6e32c58ca797..ff6d6eb04976 100644 --- a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/stub/CloudFilestoreManagerStub.java +++ b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/stub/CloudFilestoreManagerStub.java @@ -53,7 +53,11 @@ public abstract class CloudFilestoreManagerStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/stub/CloudFilestoreManagerStubSettings.java b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/stub/CloudFilestoreManagerStubSettings.java index ae273cd0f890..b6deaf5afb3f 100644 --- a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/stub/CloudFilestoreManagerStubSettings.java +++ b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/stub/CloudFilestoreManagerStubSettings.java @@ -29,6 +29,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; @@ -354,6 +357,11 @@ public CloudFilestoreManagerStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCloudFilestoreManagerStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCloudFilestoreManagerStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -386,18 +394,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(CloudFilestoreManagerStubSettings.class)) @@ -405,11 +420,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(CloudFilestoreManagerStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CloudFilestoreManagerStubSettings.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); @@ -633,6 +667,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 .listInstancesSettings() diff --git a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/stub/HttpJsonCloudFilestoreManagerCallableFactory.java b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/stub/HttpJsonCloudFilestoreManagerCallableFactory.java new file mode 100644 index 000000000000..a7fa0483931e --- /dev/null +++ b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/stub/HttpJsonCloudFilestoreManagerCallableFactory.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.filestore.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 CloudFilestoreManager service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCloudFilestoreManagerCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/stub/HttpJsonCloudFilestoreManagerStub.java b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/stub/HttpJsonCloudFilestoreManagerStub.java new file mode 100644 index 000000000000..e36211a8b282 --- /dev/null +++ b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1/stub/HttpJsonCloudFilestoreManagerStub.java @@ -0,0 +1,875 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.filestore.v1.stub; + +import static com.google.cloud.filestore.v1.CloudFilestoreManagerClient.ListBackupsPagedResponse; +import static com.google.cloud.filestore.v1.CloudFilestoreManagerClient.ListInstancesPagedResponse; + +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.common.OperationMetadata; +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CreateBackupRequest; +import com.google.cloud.filestore.v1.CreateInstanceRequest; +import com.google.cloud.filestore.v1.DeleteBackupRequest; +import com.google.cloud.filestore.v1.DeleteInstanceRequest; +import com.google.cloud.filestore.v1.GetBackupRequest; +import com.google.cloud.filestore.v1.GetInstanceRequest; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.ListBackupsRequest; +import com.google.cloud.filestore.v1.ListBackupsResponse; +import com.google.cloud.filestore.v1.ListInstancesRequest; +import com.google.cloud.filestore.v1.ListInstancesResponse; +import com.google.cloud.filestore.v1.RestoreInstanceRequest; +import com.google.cloud.filestore.v1.UpdateBackupRequest; +import com.google.cloud.filestore.v1.UpdateInstanceRequest; +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 CloudFilestoreManager service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCloudFilestoreManagerStub extends CloudFilestoreManagerStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .add(Instance.getDescriptor()) + .add(Backup.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listInstancesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.filestore.v1.CloudFilestoreManager/ListInstances") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/instances", + 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(ListInstancesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.filestore.v1.CloudFilestoreManager/GetInstance") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/instances/*}", + 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(Instance.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.filestore.v1.CloudFilestoreManager/CreateInstance") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/instances", + 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, "instanceId", request.getInstanceId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("instance", request.getInstance())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.filestore.v1.CloudFilestoreManager/UpdateInstance") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{instance.name=projects/*/locations/*/instances/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "instance.name", request.getInstance().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("instance", request.getInstance())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + restoreInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.filestore.v1.CloudFilestoreManager/RestoreInstance") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/instances/*}:restore", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RestoreInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.filestore.v1.CloudFilestoreManager/DeleteInstance") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/instances/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listBackupsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.filestore.v1.CloudFilestoreManager/ListBackups") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/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.filestore.v1.CloudFilestoreManager/GetBackup") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/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 + createBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.filestore.v1.CloudFilestoreManager/CreateBackup") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/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 + deleteBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.filestore.v1.CloudFilestoreManager/DeleteBackup") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteBackupRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.filestore.v1.CloudFilestoreManager/UpdateBackup") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{backup.name=projects/*/locations/*/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 final UnaryCallable listInstancesCallable; + private final UnaryCallable + listInstancesPagedCallable; + private final UnaryCallable getInstanceCallable; + private final UnaryCallable createInstanceCallable; + private final OperationCallable + createInstanceOperationCallable; + private final UnaryCallable updateInstanceCallable; + private final OperationCallable + updateInstanceOperationCallable; + private final UnaryCallable restoreInstanceCallable; + private final OperationCallable + restoreInstanceOperationCallable; + private final UnaryCallable deleteInstanceCallable; + private final OperationCallable + deleteInstanceOperationCallable; + private final UnaryCallable listBackupsCallable; + private final UnaryCallable + listBackupsPagedCallable; + private final UnaryCallable getBackupCallable; + private final UnaryCallable createBackupCallable; + private final OperationCallable + createBackupOperationCallable; + private final UnaryCallable deleteBackupCallable; + private final OperationCallable + deleteBackupOperationCallable; + private final UnaryCallable updateBackupCallable; + private final OperationCallable + updateBackupOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCloudFilestoreManagerStub create( + CloudFilestoreManagerStubSettings settings) throws IOException { + return new HttpJsonCloudFilestoreManagerStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCloudFilestoreManagerStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCloudFilestoreManagerStub( + CloudFilestoreManagerStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCloudFilestoreManagerStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCloudFilestoreManagerStub( + CloudFilestoreManagerStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonCloudFilestoreManagerStub, 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 HttpJsonCloudFilestoreManagerStub( + CloudFilestoreManagerStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCloudFilestoreManagerCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCloudFilestoreManagerStub, 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 HttpJsonCloudFilestoreManagerStub( + CloudFilestoreManagerStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listInstancesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listInstancesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings restoreInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(restoreInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listBackupsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listBackupsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listInstancesCallable = + callableFactory.createUnaryCallable( + listInstancesTransportSettings, settings.listInstancesSettings(), clientContext); + this.listInstancesPagedCallable = + callableFactory.createPagedCallable( + listInstancesTransportSettings, settings.listInstancesSettings(), clientContext); + this.getInstanceCallable = + callableFactory.createUnaryCallable( + getInstanceTransportSettings, settings.getInstanceSettings(), clientContext); + this.createInstanceCallable = + callableFactory.createUnaryCallable( + createInstanceTransportSettings, settings.createInstanceSettings(), clientContext); + this.createInstanceOperationCallable = + callableFactory.createOperationCallable( + createInstanceTransportSettings, + settings.createInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateInstanceCallable = + callableFactory.createUnaryCallable( + updateInstanceTransportSettings, settings.updateInstanceSettings(), clientContext); + this.updateInstanceOperationCallable = + callableFactory.createOperationCallable( + updateInstanceTransportSettings, + settings.updateInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.restoreInstanceCallable = + callableFactory.createUnaryCallable( + restoreInstanceTransportSettings, settings.restoreInstanceSettings(), clientContext); + this.restoreInstanceOperationCallable = + callableFactory.createOperationCallable( + restoreInstanceTransportSettings, + settings.restoreInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteInstanceCallable = + callableFactory.createUnaryCallable( + deleteInstanceTransportSettings, settings.deleteInstanceSettings(), clientContext); + this.deleteInstanceOperationCallable = + callableFactory.createOperationCallable( + deleteInstanceTransportSettings, + settings.deleteInstanceOperationSettings(), + 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.createBackupCallable = + callableFactory.createUnaryCallable( + createBackupTransportSettings, settings.createBackupSettings(), clientContext); + this.createBackupOperationCallable = + callableFactory.createOperationCallable( + createBackupTransportSettings, + settings.createBackupOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteBackupCallable = + callableFactory.createUnaryCallable( + deleteBackupTransportSettings, settings.deleteBackupSettings(), clientContext); + this.deleteBackupOperationCallable = + callableFactory.createOperationCallable( + deleteBackupTransportSettings, + settings.deleteBackupOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateBackupCallable = + callableFactory.createUnaryCallable( + updateBackupTransportSettings, settings.updateBackupSettings(), clientContext); + this.updateBackupOperationCallable = + callableFactory.createOperationCallable( + updateBackupTransportSettings, + settings.updateBackupOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listInstancesMethodDescriptor); + methodDescriptors.add(getInstanceMethodDescriptor); + methodDescriptors.add(createInstanceMethodDescriptor); + methodDescriptors.add(updateInstanceMethodDescriptor); + methodDescriptors.add(restoreInstanceMethodDescriptor); + methodDescriptors.add(deleteInstanceMethodDescriptor); + methodDescriptors.add(listBackupsMethodDescriptor); + methodDescriptors.add(getBackupMethodDescriptor); + methodDescriptors.add(createBackupMethodDescriptor); + methodDescriptors.add(deleteBackupMethodDescriptor); + methodDescriptors.add(updateBackupMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listInstancesCallable() { + return listInstancesCallable; + } + + @Override + public UnaryCallable + listInstancesPagedCallable() { + return listInstancesPagedCallable; + } + + @Override + public UnaryCallable getInstanceCallable() { + return getInstanceCallable; + } + + @Override + public UnaryCallable createInstanceCallable() { + return createInstanceCallable; + } + + @Override + public OperationCallable + createInstanceOperationCallable() { + return createInstanceOperationCallable; + } + + @Override + public UnaryCallable updateInstanceCallable() { + return updateInstanceCallable; + } + + @Override + public OperationCallable + updateInstanceOperationCallable() { + return updateInstanceOperationCallable; + } + + @Override + public UnaryCallable restoreInstanceCallable() { + return restoreInstanceCallable; + } + + @Override + public OperationCallable + restoreInstanceOperationCallable() { + return restoreInstanceOperationCallable; + } + + @Override + public UnaryCallable deleteInstanceCallable() { + return deleteInstanceCallable; + } + + @Override + public OperationCallable + deleteInstanceOperationCallable() { + return deleteInstanceOperationCallable; + } + + @Override + public UnaryCallable listBackupsCallable() { + return listBackupsCallable; + } + + @Override + public UnaryCallable listBackupsPagedCallable() { + return listBackupsPagedCallable; + } + + @Override + public UnaryCallable getBackupCallable() { + return getBackupCallable; + } + + @Override + public UnaryCallable createBackupCallable() { + return createBackupCallable; + } + + @Override + public OperationCallable + createBackupOperationCallable() { + return createBackupOperationCallable; + } + + @Override + public UnaryCallable deleteBackupCallable() { + return deleteBackupCallable; + } + + @Override + public OperationCallable + deleteBackupOperationCallable() { + return deleteBackupOperationCallable; + } + + @Override + public UnaryCallable updateBackupCallable() { + return updateBackupCallable; + } + + @Override + public OperationCallable + updateBackupOperationCallable() { + return updateBackupOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/CloudFilestoreManagerClient.java b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/CloudFilestoreManagerClient.java index b86cd6efbece..a5e111fa39b2 100644 --- a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/CloudFilestoreManagerClient.java +++ b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/CloudFilestoreManagerClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -32,7 +33,6 @@ import com.google.cloud.filestore.v1beta1.stub.CloudFilestoreManagerStubSettings; 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; @@ -132,6 +132,21 @@ * CloudFilestoreManagerClient.create(cloudFilestoreManagerSettings); * } * + *

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.
+ * CloudFilestoreManagerSettings cloudFilestoreManagerSettings =
+ *     CloudFilestoreManagerSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CloudFilestoreManagerSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CloudFilestoreManagerClient cloudFilestoreManagerClient =
+ *     CloudFilestoreManagerClient.create(cloudFilestoreManagerSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -139,7 +154,8 @@ public class CloudFilestoreManagerClient implements BackgroundResource { private final CloudFilestoreManagerSettings settings; private final CloudFilestoreManagerStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of CloudFilestoreManagerClient with default settings. */ public static final CloudFilestoreManagerClient create() throws IOException { @@ -171,13 +187,17 @@ public static final CloudFilestoreManagerClient create(CloudFilestoreManagerStub protected CloudFilestoreManagerClient(CloudFilestoreManagerSettings settings) throws IOException { this.settings = settings; this.stub = ((CloudFilestoreManagerStubSettings) 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 CloudFilestoreManagerClient(CloudFilestoreManagerStub 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 CloudFilestoreManagerSettings getSettings() { @@ -192,10 +212,18 @@ public CloudFilestoreManagerStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all instances in a project for either a specified location or for all locations. diff --git a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/CloudFilestoreManagerSettings.java b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/CloudFilestoreManagerSettings.java index 0476a063573d..798d804337bd 100644 --- a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/CloudFilestoreManagerSettings.java +++ b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/CloudFilestoreManagerSettings.java @@ -24,6 +24,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; @@ -206,11 +207,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CloudFilestoreManagerStubSettings.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 CloudFilestoreManagerStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CloudFilestoreManagerStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CloudFilestoreManagerStubSettings.defaultTransportChannelProvider(); } @@ -220,11 +228,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CloudFilestoreManagerStubSettings.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); @@ -263,6 +277,11 @@ private static Builder createDefault() { return new Builder(CloudFilestoreManagerStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CloudFilestoreManagerStubSettings.newHttpJsonBuilder()); + } + public CloudFilestoreManagerStubSettings.Builder getStubSettingsBuilder() { return ((CloudFilestoreManagerStubSettings.Builder) getStubSettings()); } diff --git a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/stub/CloudFilestoreManagerStub.java b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/stub/CloudFilestoreManagerStub.java index 50d80a93d7b5..22e27ef5ad94 100644 --- a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/stub/CloudFilestoreManagerStub.java +++ b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/stub/CloudFilestoreManagerStub.java @@ -55,7 +55,11 @@ public abstract class CloudFilestoreManagerStub implements BackgroundResource { public OperationsStub getOperationsStub() { - throw new UnsupportedOperationException("Not implemented: getOperationsStub()"); + return null; + } + + public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() { + return null; } public UnaryCallable diff --git a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/stub/CloudFilestoreManagerStubSettings.java b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/stub/CloudFilestoreManagerStubSettings.java index 22302ad22b00..97907a059a8b 100644 --- a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/stub/CloudFilestoreManagerStubSettings.java +++ b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/stub/CloudFilestoreManagerStubSettings.java @@ -29,6 +29,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; @@ -355,6 +358,11 @@ public CloudFilestoreManagerStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCloudFilestoreManagerStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCloudFilestoreManagerStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -387,18 +395,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(CloudFilestoreManagerStubSettings.class)) @@ -406,11 +421,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(CloudFilestoreManagerStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CloudFilestoreManagerStubSettings.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); @@ -634,6 +668,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 .listInstancesSettings() diff --git a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/stub/HttpJsonCloudFilestoreManagerCallableFactory.java b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/stub/HttpJsonCloudFilestoreManagerCallableFactory.java new file mode 100644 index 000000000000..a8e8ca24d3f8 --- /dev/null +++ b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/stub/HttpJsonCloudFilestoreManagerCallableFactory.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.filestore.v1beta1.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 CloudFilestoreManager service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCloudFilestoreManagerCallableFactory + implements HttpJsonStubCallableFactory { + + @Override + public UnaryCallable createUnaryCallable( + HttpJsonCallSettings httpJsonCallSettings, + UnaryCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createUnaryCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public + UnaryCallable createPagedCallable( + HttpJsonCallSettings httpJsonCallSettings, + PagedCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createPagedCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @Override + public UnaryCallable createBatchingCallable( + HttpJsonCallSettings httpJsonCallSettings, + BatchingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createBatchingCallable( + httpJsonCallSettings, callSettings, clientContext); + } + + @BetaApi( + "The surface for long-running operations is not stable yet and may change in the future.") + @Override + public + OperationCallable createOperationCallable( + HttpJsonCallSettings httpJsonCallSettings, + OperationCallSettings callSettings, + ClientContext clientContext, + OperationsStub operationsStub) { + UnaryCallable innerCallable = + HttpJsonCallableFactory.createBaseUnaryCallable( + httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext); + HttpJsonOperationSnapshotCallable initialCallable = + new HttpJsonOperationSnapshotCallable( + innerCallable, + httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory()); + return HttpJsonCallableFactory.createOperationCallable( + callSettings, clientContext, operationsStub.longRunningClient(), initialCallable); + } + + @Override + public + ServerStreamingCallable createServerStreamingCallable( + HttpJsonCallSettings httpJsonCallSettings, + ServerStreamingCallSettings callSettings, + ClientContext clientContext) { + return HttpJsonCallableFactory.createServerStreamingCallable( + httpJsonCallSettings, callSettings, clientContext); + } +} diff --git a/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/stub/HttpJsonCloudFilestoreManagerStub.java b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/stub/HttpJsonCloudFilestoreManagerStub.java new file mode 100644 index 000000000000..a6db15fff283 --- /dev/null +++ b/java-filestore/google-cloud-filestore/src/main/java/com/google/cloud/filestore/v1beta1/stub/HttpJsonCloudFilestoreManagerStub.java @@ -0,0 +1,883 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.filestore.v1beta1.stub; + +import static com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient.ListBackupsPagedResponse; +import static com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient.ListInstancesPagedResponse; + +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.common.OperationMetadata; +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CreateBackupRequest; +import com.google.cloud.filestore.v1beta1.CreateInstanceRequest; +import com.google.cloud.filestore.v1beta1.DeleteBackupRequest; +import com.google.cloud.filestore.v1beta1.DeleteInstanceRequest; +import com.google.cloud.filestore.v1beta1.GetBackupRequest; +import com.google.cloud.filestore.v1beta1.GetInstanceRequest; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.ListBackupsRequest; +import com.google.cloud.filestore.v1beta1.ListBackupsResponse; +import com.google.cloud.filestore.v1beta1.ListInstancesRequest; +import com.google.cloud.filestore.v1beta1.ListInstancesResponse; +import com.google.cloud.filestore.v1beta1.RestoreInstanceRequest; +import com.google.cloud.filestore.v1beta1.UpdateBackupRequest; +import com.google.cloud.filestore.v1beta1.UpdateInstanceRequest; +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 CloudFilestoreManager service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCloudFilestoreManagerStub extends CloudFilestoreManagerStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .add(Instance.getDescriptor()) + .add(Backup.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + listInstancesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.filestore.v1beta1.CloudFilestoreManager/ListInstances") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/instances", + 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(ListInstancesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.filestore.v1beta1.CloudFilestoreManager/GetInstance") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/instances/*}", + 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(Instance.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.filestore.v1beta1.CloudFilestoreManager/CreateInstance") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/instances", + 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, "instanceId", request.getInstanceId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("instance", request.getInstance())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.filestore.v1beta1.CloudFilestoreManager/UpdateInstance") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{instance.name=projects/*/locations/*/instances/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "instance.name", request.getInstance().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("instance", request.getInstance())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + restoreInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.filestore.v1beta1.CloudFilestoreManager/RestoreInstance") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/instances/*}:restore", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (RestoreInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteInstanceMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.filestore.v1beta1.CloudFilestoreManager/DeleteInstance") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/instances/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteInstanceRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + listBackupsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.filestore.v1beta1.CloudFilestoreManager/ListBackups") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/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.filestore.v1beta1.CloudFilestoreManager/GetBackup") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/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 + createBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.filestore.v1beta1.CloudFilestoreManager/CreateBackup") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/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 + deleteBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.filestore.v1beta1.CloudFilestoreManager/DeleteBackup") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/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(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteBackupRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateBackupMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.filestore.v1beta1.CloudFilestoreManager/UpdateBackup") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{backup.name=projects/*/locations/*/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 final UnaryCallable listInstancesCallable; + private final UnaryCallable + listInstancesPagedCallable; + private final UnaryCallable getInstanceCallable; + private final UnaryCallable createInstanceCallable; + private final OperationCallable + createInstanceOperationCallable; + private final UnaryCallable updateInstanceCallable; + private final OperationCallable + updateInstanceOperationCallable; + private final UnaryCallable restoreInstanceCallable; + private final OperationCallable + restoreInstanceOperationCallable; + private final UnaryCallable deleteInstanceCallable; + private final OperationCallable + deleteInstanceOperationCallable; + private final UnaryCallable listBackupsCallable; + private final UnaryCallable + listBackupsPagedCallable; + private final UnaryCallable getBackupCallable; + private final UnaryCallable createBackupCallable; + private final OperationCallable + createBackupOperationCallable; + private final UnaryCallable deleteBackupCallable; + private final OperationCallable + deleteBackupOperationCallable; + private final UnaryCallable updateBackupCallable; + private final OperationCallable + updateBackupOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCloudFilestoreManagerStub create( + CloudFilestoreManagerStubSettings settings) throws IOException { + return new HttpJsonCloudFilestoreManagerStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCloudFilestoreManagerStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCloudFilestoreManagerStub( + CloudFilestoreManagerStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCloudFilestoreManagerStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCloudFilestoreManagerStub( + CloudFilestoreManagerStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonCloudFilestoreManagerStub, 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 HttpJsonCloudFilestoreManagerStub( + CloudFilestoreManagerStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCloudFilestoreManagerCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCloudFilestoreManagerStub, 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 HttpJsonCloudFilestoreManagerStub( + CloudFilestoreManagerStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listInstancesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listInstancesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings restoreInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(restoreInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteInstanceTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteInstanceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings listBackupsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listBackupsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateBackupTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateBackupMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listInstancesCallable = + callableFactory.createUnaryCallable( + listInstancesTransportSettings, settings.listInstancesSettings(), clientContext); + this.listInstancesPagedCallable = + callableFactory.createPagedCallable( + listInstancesTransportSettings, settings.listInstancesSettings(), clientContext); + this.getInstanceCallable = + callableFactory.createUnaryCallable( + getInstanceTransportSettings, settings.getInstanceSettings(), clientContext); + this.createInstanceCallable = + callableFactory.createUnaryCallable( + createInstanceTransportSettings, settings.createInstanceSettings(), clientContext); + this.createInstanceOperationCallable = + callableFactory.createOperationCallable( + createInstanceTransportSettings, + settings.createInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateInstanceCallable = + callableFactory.createUnaryCallable( + updateInstanceTransportSettings, settings.updateInstanceSettings(), clientContext); + this.updateInstanceOperationCallable = + callableFactory.createOperationCallable( + updateInstanceTransportSettings, + settings.updateInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.restoreInstanceCallable = + callableFactory.createUnaryCallable( + restoreInstanceTransportSettings, settings.restoreInstanceSettings(), clientContext); + this.restoreInstanceOperationCallable = + callableFactory.createOperationCallable( + restoreInstanceTransportSettings, + settings.restoreInstanceOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteInstanceCallable = + callableFactory.createUnaryCallable( + deleteInstanceTransportSettings, settings.deleteInstanceSettings(), clientContext); + this.deleteInstanceOperationCallable = + callableFactory.createOperationCallable( + deleteInstanceTransportSettings, + settings.deleteInstanceOperationSettings(), + 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.createBackupCallable = + callableFactory.createUnaryCallable( + createBackupTransportSettings, settings.createBackupSettings(), clientContext); + this.createBackupOperationCallable = + callableFactory.createOperationCallable( + createBackupTransportSettings, + settings.createBackupOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteBackupCallable = + callableFactory.createUnaryCallable( + deleteBackupTransportSettings, settings.deleteBackupSettings(), clientContext); + this.deleteBackupOperationCallable = + callableFactory.createOperationCallable( + deleteBackupTransportSettings, + settings.deleteBackupOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateBackupCallable = + callableFactory.createUnaryCallable( + updateBackupTransportSettings, settings.updateBackupSettings(), clientContext); + this.updateBackupOperationCallable = + callableFactory.createOperationCallable( + updateBackupTransportSettings, + settings.updateBackupOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listInstancesMethodDescriptor); + methodDescriptors.add(getInstanceMethodDescriptor); + methodDescriptors.add(createInstanceMethodDescriptor); + methodDescriptors.add(updateInstanceMethodDescriptor); + methodDescriptors.add(restoreInstanceMethodDescriptor); + methodDescriptors.add(deleteInstanceMethodDescriptor); + methodDescriptors.add(listBackupsMethodDescriptor); + methodDescriptors.add(getBackupMethodDescriptor); + methodDescriptors.add(createBackupMethodDescriptor); + methodDescriptors.add(deleteBackupMethodDescriptor); + methodDescriptors.add(updateBackupMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable listInstancesCallable() { + return listInstancesCallable; + } + + @Override + public UnaryCallable + listInstancesPagedCallable() { + return listInstancesPagedCallable; + } + + @Override + public UnaryCallable getInstanceCallable() { + return getInstanceCallable; + } + + @Override + public UnaryCallable createInstanceCallable() { + return createInstanceCallable; + } + + @Override + public OperationCallable + createInstanceOperationCallable() { + return createInstanceOperationCallable; + } + + @Override + public UnaryCallable updateInstanceCallable() { + return updateInstanceCallable; + } + + @Override + public OperationCallable + updateInstanceOperationCallable() { + return updateInstanceOperationCallable; + } + + @Override + public UnaryCallable restoreInstanceCallable() { + return restoreInstanceCallable; + } + + @Override + public OperationCallable + restoreInstanceOperationCallable() { + return restoreInstanceOperationCallable; + } + + @Override + public UnaryCallable deleteInstanceCallable() { + return deleteInstanceCallable; + } + + @Override + public OperationCallable + deleteInstanceOperationCallable() { + return deleteInstanceOperationCallable; + } + + @Override + public UnaryCallable listBackupsCallable() { + return listBackupsCallable; + } + + @Override + public UnaryCallable listBackupsPagedCallable() { + return listBackupsPagedCallable; + } + + @Override + public UnaryCallable getBackupCallable() { + return getBackupCallable; + } + + @Override + public UnaryCallable createBackupCallable() { + return createBackupCallable; + } + + @Override + public OperationCallable + createBackupOperationCallable() { + return createBackupOperationCallable; + } + + @Override + public UnaryCallable deleteBackupCallable() { + return deleteBackupCallable; + } + + @Override + public OperationCallable + deleteBackupOperationCallable() { + return deleteBackupOperationCallable; + } + + @Override + public UnaryCallable updateBackupCallable() { + return updateBackupCallable; + } + + @Override + public OperationCallable + updateBackupOperationCallable() { + return updateBackupOperationCallable; + } + + @Override + public final void close() { + try { + backgroundResources.close(); + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new IllegalStateException("Failed to close resource", e); + } + } + + @Override + public void shutdown() { + backgroundResources.shutdown(); + } + + @Override + public boolean isShutdown() { + return backgroundResources.isShutdown(); + } + + @Override + public boolean isTerminated() { + return backgroundResources.isTerminated(); + } + + @Override + public void shutdownNow() { + backgroundResources.shutdownNow(); + } + + @Override + public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException { + return backgroundResources.awaitTermination(duration, unit); + } +} diff --git a/java-filestore/google-cloud-filestore/src/test/java/com/google/cloud/filestore/v1/CloudFilestoreManagerClientHttpJsonTest.java b/java-filestore/google-cloud-filestore/src/test/java/com/google/cloud/filestore/v1/CloudFilestoreManagerClientHttpJsonTest.java new file mode 100644 index 000000000000..fa407c9021c5 --- /dev/null +++ b/java-filestore/google-cloud-filestore/src/test/java/com/google/cloud/filestore/v1/CloudFilestoreManagerClientHttpJsonTest.java @@ -0,0 +1,1154 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.filestore.v1; + +import static com.google.cloud.filestore.v1.CloudFilestoreManagerClient.ListBackupsPagedResponse; +import static com.google.cloud.filestore.v1.CloudFilestoreManagerClient.ListInstancesPagedResponse; + +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.filestore.v1.stub.HttpJsonCloudFilestoreManagerStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.BoolValue; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class CloudFilestoreManagerClientHttpJsonTest { + private static MockHttpService mockService; + private static CloudFilestoreManagerClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCloudFilestoreManagerStub.getMethodDescriptors(), + CloudFilestoreManagerSettings.getDefaultEndpoint()); + CloudFilestoreManagerSettings settings = + CloudFilestoreManagerSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CloudFilestoreManagerSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CloudFilestoreManagerClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listInstancesTest() throws Exception { + Instance responsesElement = Instance.newBuilder().build(); + ListInstancesResponse expectedResponse = + ListInstancesResponse.newBuilder() + .setNextPageToken("") + .addAllInstances(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListInstancesPagedResponse pagedListResponse = client.listInstances(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInstancesList().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 listInstancesExceptionTest() 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.listInstances(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInstancesTest2() throws Exception { + Instance responsesElement = Instance.newBuilder().build(); + ListInstancesResponse expectedResponse = + ListInstancesResponse.newBuilder() + .setNextPageToken("") + .addAllInstances(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListInstancesPagedResponse pagedListResponse = client.listInstances(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInstancesList().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 listInstancesExceptionTest2() 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.listInstances(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + Instance actualResponse = client.getInstance(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 getInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.getInstance(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInstanceTest2() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9412/locations/location-9412/instances/instance-9412"; + + Instance actualResponse = client.getInstance(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 getInstanceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9412/locations/location-9412/instances/instance-9412"; + client.getInstance(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + + Instance actualResponse = client.createInstanceAsync(parent, instance, instanceId).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 createInstanceExceptionTest() 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]"); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + client.createInstanceAsync(parent, instance, instanceId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createInstanceTest2() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + + Instance actualResponse = client.createInstanceAsync(parent, instance, instanceId).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 createInstanceExceptionTest2() 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"; + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + client.createInstanceAsync(parent, instance, instanceId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Instance instance = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Instance actualResponse = client.updateInstanceAsync(instance, 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 updateInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Instance instance = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateInstanceAsync(instance, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void restoreInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("restoreInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RestoreInstanceRequest request = + RestoreInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setFileShare("fileShare-1327728701") + .build(); + + Instance actualResponse = client.restoreInstanceAsync(request).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 restoreInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestoreInstanceRequest request = + RestoreInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setFileShare("fileShare-1327728701") + .build(); + client.restoreInstanceAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteInstanceTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + client.deleteInstanceAsync(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 deleteInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.deleteInstanceAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteInstanceTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-9412/locations/location-9412/instances/instance-9412"; + + client.deleteInstanceAsync(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 deleteInstanceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9412/locations/location-9412/instances/instance-9412"; + client.deleteInstanceAsync(name).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); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + 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 { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + 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-5833/locations/location-5833"; + + 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-5833/locations/location-5833"; + 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]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setCapacityGb(-1923585408) + .setStorageBytes(2035244455) + .setSourceInstance(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setSourceFileShare("sourceFileShare-646832664") + .setDownloadBytes(971924980) + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[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]"); + 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]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setCapacityGb(-1923585408) + .setStorageBytes(2035244455) + .setSourceInstance(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setSourceFileShare("sourceFileShare-646832664") + .setDownloadBytes(971924980) + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1607/locations/location-1607/backups/backup-1607"; + + 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-1607/locations/location-1607/backups/backup-1607"; + client.getBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createBackupTest() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setCapacityGb(-1923585408) + .setStorageBytes(2035244455) + .setSourceInstance(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setSourceFileShare("sourceFileShare-646832664") + .setDownloadBytes(971924980) + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createBackupTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + 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 { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + 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]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setCapacityGb(-1923585408) + .setStorageBytes(2035244455) + .setSourceInstance(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setSourceFileShare("sourceFileShare-646832664") + .setDownloadBytes(971924980) + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createBackupTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + 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-5833/locations/location-5833"; + 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 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]"); + + 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]"); + 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-1607/locations/location-1607/backups/backup-1607"; + + 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-1607/locations/location-1607/backups/backup-1607"; + client.deleteBackupAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateBackupTest() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setCapacityGb(-1923585408) + .setStorageBytes(2035244455) + .setSourceInstance(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setSourceFileShare("sourceFileShare-646832664") + .setDownloadBytes(971924980) + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .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]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setCapacityGb(-1923585408) + .setStorageBytes(2035244455) + .setSourceInstance(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setSourceFileShare("sourceFileShare-646832664") + .setDownloadBytes(971924980) + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .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]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setCapacityGb(-1923585408) + .setStorageBytes(2035244455) + .setSourceInstance( + InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setSourceFileShare("sourceFileShare-646832664") + .setDownloadBytes(971924980) + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateBackupAsync(backup, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-filestore/google-cloud-filestore/src/test/java/com/google/cloud/filestore/v1beta1/CloudFilestoreManagerClientHttpJsonTest.java b/java-filestore/google-cloud-filestore/src/test/java/com/google/cloud/filestore/v1beta1/CloudFilestoreManagerClientHttpJsonTest.java new file mode 100644 index 000000000000..980eca1d9a83 --- /dev/null +++ b/java-filestore/google-cloud-filestore/src/test/java/com/google/cloud/filestore/v1beta1/CloudFilestoreManagerClientHttpJsonTest.java @@ -0,0 +1,1154 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.filestore.v1beta1; + +import static com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient.ListBackupsPagedResponse; +import static com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient.ListInstancesPagedResponse; + +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.filestore.v1beta1.stub.HttpJsonCloudFilestoreManagerStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.BoolValue; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class CloudFilestoreManagerClientHttpJsonTest { + private static MockHttpService mockService; + private static CloudFilestoreManagerClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCloudFilestoreManagerStub.getMethodDescriptors(), + CloudFilestoreManagerSettings.getDefaultEndpoint()); + CloudFilestoreManagerSettings settings = + CloudFilestoreManagerSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CloudFilestoreManagerSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CloudFilestoreManagerClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listInstancesTest() throws Exception { + Instance responsesElement = Instance.newBuilder().build(); + ListInstancesResponse expectedResponse = + ListInstancesResponse.newBuilder() + .setNextPageToken("") + .addAllInstances(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListInstancesPagedResponse pagedListResponse = client.listInstances(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInstancesList().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 listInstancesExceptionTest() 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.listInstances(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInstancesTest2() throws Exception { + Instance responsesElement = Instance.newBuilder().build(); + ListInstancesResponse expectedResponse = + ListInstancesResponse.newBuilder() + .setNextPageToken("") + .addAllInstances(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListInstancesPagedResponse pagedListResponse = client.listInstances(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInstancesList().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 listInstancesExceptionTest2() 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.listInstances(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + Instance actualResponse = client.getInstance(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 getInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.getInstance(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInstanceTest2() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-9412/locations/location-9412/instances/instance-9412"; + + Instance actualResponse = client.getInstance(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 getInstanceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9412/locations/location-9412/instances/instance-9412"; + client.getInstance(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + + Instance actualResponse = client.createInstanceAsync(parent, instance, instanceId).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 createInstanceExceptionTest() 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]"); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + client.createInstanceAsync(parent, instance, instanceId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createInstanceTest2() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + + Instance actualResponse = client.createInstanceAsync(parent, instance, instanceId).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 createInstanceExceptionTest2() 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"; + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + client.createInstanceAsync(parent, instance, instanceId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + Instance instance = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Instance actualResponse = client.updateInstanceAsync(instance, 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 updateInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Instance instance = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateInstanceAsync(instance, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void restoreInstanceTest() throws Exception { + Instance expectedResponse = + Instance.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setDescription("description-1724546052") + .setStatusMessage("statusMessage-958704715") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .addAllFileShares(new ArrayList()) + .addAllNetworks(new ArrayList()) + .setEtag("etag3123477") + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("restoreInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RestoreInstanceRequest request = + RestoreInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setFileShare("fileShare-1327728701") + .build(); + + Instance actualResponse = client.restoreInstanceAsync(request).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 restoreInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RestoreInstanceRequest request = + RestoreInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setFileShare("fileShare-1327728701") + .build(); + client.restoreInstanceAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteInstanceTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + client.deleteInstanceAsync(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 deleteInstanceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.deleteInstanceAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteInstanceTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteInstanceTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-9412/locations/location-9412/instances/instance-9412"; + + client.deleteInstanceAsync(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 deleteInstanceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-9412/locations/location-9412/instances/instance-9412"; + client.deleteInstanceAsync(name).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); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + 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 { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + 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-5833/locations/location-5833"; + + 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-5833/locations/location-5833"; + 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]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setCapacityGb(-1923585408) + .setStorageBytes(2035244455) + .setSourceInstance(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setSourceFileShare("sourceFileShare-646832664") + .setDownloadBytes(971924980) + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[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]"); + 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]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setCapacityGb(-1923585408) + .setStorageBytes(2035244455) + .setSourceInstance(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setSourceFileShare("sourceFileShare-646832664") + .setDownloadBytes(971924980) + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-1607/locations/location-1607/backups/backup-1607"; + + 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-1607/locations/location-1607/backups/backup-1607"; + client.getBackup(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createBackupTest() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setCapacityGb(-1923585408) + .setStorageBytes(2035244455) + .setSourceInstance(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setSourceFileShare("sourceFileShare-646832664") + .setDownloadBytes(971924980) + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createBackupTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + 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 { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + 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]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setCapacityGb(-1923585408) + .setStorageBytes(2035244455) + .setSourceInstance(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setSourceFileShare("sourceFileShare-646832664") + .setDownloadBytes(971924980) + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createBackupTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + 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-5833/locations/location-5833"; + 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 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]"); + + 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]"); + 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-1607/locations/location-1607/backups/backup-1607"; + + 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-1607/locations/location-1607/backups/backup-1607"; + client.deleteBackupAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateBackupTest() throws Exception { + Backup expectedResponse = + Backup.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setCapacityGb(-1923585408) + .setStorageBytes(2035244455) + .setSourceInstance(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setSourceFileShare("sourceFileShare-646832664") + .setDownloadBytes(971924980) + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .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]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setCapacityGb(-1923585408) + .setStorageBytes(2035244455) + .setSourceInstance(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setSourceFileShare("sourceFileShare-646832664") + .setDownloadBytes(971924980) + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .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]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .putAllLabels(new HashMap()) + .setCapacityGb(-1923585408) + .setStorageBytes(2035244455) + .setSourceInstance( + InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setSourceFileShare("sourceFileShare-646832664") + .setDownloadBytes(971924980) + .setSatisfiesPzs(BoolValue.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateBackupAsync(backup, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/create/SyncCreateSetCredentialsProvider.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..f7c59763e18f --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.CloudFilestoreManagerSettings; +import com.google.cloud.filestore.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. + CloudFilestoreManagerSettings cloudFilestoreManagerSettings = + CloudFilestoreManagerSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create(cloudFilestoreManagerSettings); + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_create_setcredentialsprovider_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/create/SyncCreateSetCredentialsProvider1.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..c55967c33347 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_create_setcredentialsprovider1_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.CloudFilestoreManagerSettings; + +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. + CloudFilestoreManagerSettings cloudFilestoreManagerSettings = + CloudFilestoreManagerSettings.newBuilder() + .setTransportChannelProvider( + CloudFilestoreManagerSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create(cloudFilestoreManagerSettings); + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_create_setcredentialsprovider1_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/create/SyncCreateSetEndpoint.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..f1c0f646bddf --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_create_setendpoint_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.CloudFilestoreManagerSettings; +import com.google.cloud.filestore.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. + CloudFilestoreManagerSettings cloudFilestoreManagerSettings = + CloudFilestoreManagerSettings.newBuilder().setEndpoint(myEndpoint).build(); + CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create(cloudFilestoreManagerSettings); + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_create_setendpoint_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/AsyncCreateBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/AsyncCreateBackup.java new file mode 100644 index 000000000000..64e3055769ba --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/AsyncCreateBackup.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_createbackup_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.CreateBackupRequest; +import com.google.cloud.filestore.v1.LocationName; +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + CreateBackupRequest request = + CreateBackupRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setBackup(Backup.newBuilder().build()) + .setBackupId("backupId2121930365") + .build(); + ApiFuture future = + cloudFilestoreManagerClient.createBackupCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_createbackup_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/AsyncCreateBackupLRO.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/AsyncCreateBackupLRO.java new file mode 100644 index 000000000000..3d6e54a1b02f --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/AsyncCreateBackupLRO.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_createbackup_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.common.OperationMetadata; +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.CreateBackupRequest; +import com.google.cloud.filestore.v1.LocationName; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + CreateBackupRequest request = + CreateBackupRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setBackup(Backup.newBuilder().build()) + .setBackupId("backupId2121930365") + .build(); + OperationFuture future = + cloudFilestoreManagerClient.createBackupOperationCallable().futureCall(request); + // Do something. + Backup response = future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_createbackup_lro_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/SyncCreateBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/SyncCreateBackup.java new file mode 100644 index 000000000000..aec63e4ba426 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/SyncCreateBackup.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_createbackup_sync] +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.CreateBackupRequest; +import com.google.cloud.filestore.v1.LocationName; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + CreateBackupRequest request = + CreateBackupRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setBackup(Backup.newBuilder().build()) + .setBackupId("backupId2121930365") + .build(); + Backup response = cloudFilestoreManagerClient.createBackupAsync(request).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_createbackup_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/SyncCreateBackupLocationnameBackupString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/SyncCreateBackupLocationnameBackupString.java new file mode 100644 index 000000000000..5a23a1f350c7 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/SyncCreateBackupLocationnameBackupString.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.filestore.v1.samples; + +// [START +// filestore_v1_generated_cloudfilestoremanagerclient_createbackup_locationnamebackupstring_sync] +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.LocationName; + +public class SyncCreateBackupLocationnameBackupString { + + public static void main(String[] args) throws Exception { + syncCreateBackupLocationnameBackupString(); + } + + public static void syncCreateBackupLocationnameBackupString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Backup backup = Backup.newBuilder().build(); + String backupId = "backupId2121930365"; + Backup response = + cloudFilestoreManagerClient.createBackupAsync(parent, backup, backupId).get(); + } + } +} +// [END +// filestore_v1_generated_cloudfilestoremanagerclient_createbackup_locationnamebackupstring_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/SyncCreateBackupStringBackupString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/SyncCreateBackupStringBackupString.java new file mode 100644 index 000000000000..edc2d57381a0 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createbackup/SyncCreateBackupStringBackupString.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_createbackup_stringbackupstring_sync] +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.LocationName; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Backup backup = Backup.newBuilder().build(); + String backupId = "backupId2121930365"; + Backup response = + cloudFilestoreManagerClient.createBackupAsync(parent, backup, backupId).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_createbackup_stringbackupstring_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/AsyncCreateInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/AsyncCreateInstance.java new file mode 100644 index 000000000000..7a1001f26c0e --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/AsyncCreateInstance.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_createinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.CreateInstanceRequest; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.LocationName; +import com.google.longrunning.Operation; + +public class AsyncCreateInstance { + + public static void main(String[] args) throws Exception { + asyncCreateInstance(); + } + + public static void asyncCreateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + CreateInstanceRequest request = + CreateInstanceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInstanceId("instanceId902024336") + .setInstance(Instance.newBuilder().build()) + .build(); + ApiFuture future = + cloudFilestoreManagerClient.createInstanceCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_createinstance_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/AsyncCreateInstanceLRO.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/AsyncCreateInstanceLRO.java new file mode 100644 index 000000000000..d94f5c806fac --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/AsyncCreateInstanceLRO.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_createinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.common.OperationMetadata; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.CreateInstanceRequest; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.LocationName; + +public class AsyncCreateInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncCreateInstanceLRO(); + } + + public static void asyncCreateInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + CreateInstanceRequest request = + CreateInstanceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInstanceId("instanceId902024336") + .setInstance(Instance.newBuilder().build()) + .build(); + OperationFuture future = + cloudFilestoreManagerClient.createInstanceOperationCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_createinstance_lro_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/SyncCreateInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/SyncCreateInstance.java new file mode 100644 index 000000000000..36f8b59f6adf --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/SyncCreateInstance.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_createinstance_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.CreateInstanceRequest; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.LocationName; + +public class SyncCreateInstance { + + public static void main(String[] args) throws Exception { + syncCreateInstance(); + } + + public static void syncCreateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + CreateInstanceRequest request = + CreateInstanceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInstanceId("instanceId902024336") + .setInstance(Instance.newBuilder().build()) + .build(); + Instance response = cloudFilestoreManagerClient.createInstanceAsync(request).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_createinstance_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/SyncCreateInstanceLocationnameInstanceString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/SyncCreateInstanceLocationnameInstanceString.java new file mode 100644 index 000000000000..c263a9d0b952 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/SyncCreateInstanceLocationnameInstanceString.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.filestore.v1.samples; + +// [START +// filestore_v1_generated_cloudfilestoremanagerclient_createinstance_locationnameinstancestring_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.LocationName; + +public class SyncCreateInstanceLocationnameInstanceString { + + public static void main(String[] args) throws Exception { + syncCreateInstanceLocationnameInstanceString(); + } + + public static void syncCreateInstanceLocationnameInstanceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + Instance response = + cloudFilestoreManagerClient.createInstanceAsync(parent, instance, instanceId).get(); + } + } +} +// [END +// filestore_v1_generated_cloudfilestoremanagerclient_createinstance_locationnameinstancestring_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/SyncCreateInstanceStringInstanceString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/SyncCreateInstanceStringInstanceString.java new file mode 100644 index 000000000000..54faca837cc6 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/createinstance/SyncCreateInstanceStringInstanceString.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.filestore.v1.samples; + +// [START +// filestore_v1_generated_cloudfilestoremanagerclient_createinstance_stringinstancestring_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.LocationName; + +public class SyncCreateInstanceStringInstanceString { + + public static void main(String[] args) throws Exception { + syncCreateInstanceStringInstanceString(); + } + + public static void syncCreateInstanceStringInstanceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + Instance response = + cloudFilestoreManagerClient.createInstanceAsync(parent, instance, instanceId).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_createinstance_stringinstancestring_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deletebackup/AsyncDeleteBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deletebackup/AsyncDeleteBackup.java new file mode 100644 index 000000000000..b9f25d5e6ca2 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deletebackup/AsyncDeleteBackup.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_deletebackup_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1.BackupName; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + DeleteBackupRequest request = + DeleteBackupRequest.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .build(); + ApiFuture future = + cloudFilestoreManagerClient.deleteBackupCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_deletebackup_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deletebackup/AsyncDeleteBackupLRO.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deletebackup/AsyncDeleteBackupLRO.java new file mode 100644 index 000000000000..e6be2f41e8b0 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deletebackup/AsyncDeleteBackupLRO.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_deletebackup_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.common.OperationMetadata; +import com.google.cloud.filestore.v1.BackupName; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.DeleteBackupRequest; +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + DeleteBackupRequest request = + DeleteBackupRequest.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .build(); + OperationFuture future = + cloudFilestoreManagerClient.deleteBackupOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_deletebackup_lro_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackup.java new file mode 100644 index 000000000000..fa29c6173b54 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackup.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_deletebackup_sync] +import com.google.cloud.filestore.v1.BackupName; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.DeleteBackupRequest; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + DeleteBackupRequest request = + DeleteBackupRequest.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .build(); + cloudFilestoreManagerClient.deleteBackupAsync(request).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_deletebackup_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackupBackupname.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackupBackupname.java new file mode 100644 index 000000000000..72a24844dadd --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_deletebackup_backupname_sync] +import com.google.cloud.filestore.v1.BackupName; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + cloudFilestoreManagerClient.deleteBackupAsync(name).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_deletebackup_backupname_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackupString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackupString.java new file mode 100644 index 000000000000..642dfa6312d4 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackupString.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_deletebackup_string_sync] +import com.google.cloud.filestore.v1.BackupName; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString(); + cloudFilestoreManagerClient.deleteBackupAsync(name).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_deletebackup_string_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/AsyncDeleteInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/AsyncDeleteInstance.java new file mode 100644 index 000000000000..ad2a0d10a814 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/AsyncDeleteInstance.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_deleteinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.DeleteInstanceRequest; +import com.google.cloud.filestore.v1.InstanceName; +import com.google.longrunning.Operation; + +public class AsyncDeleteInstance { + + public static void main(String[] args) throws Exception { + asyncDeleteInstance(); + } + + public static void asyncDeleteInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + DeleteInstanceRequest request = + DeleteInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = + cloudFilestoreManagerClient.deleteInstanceCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_deleteinstance_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/AsyncDeleteInstanceLRO.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/AsyncDeleteInstanceLRO.java new file mode 100644 index 000000000000..88f81e368baf --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/AsyncDeleteInstanceLRO.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_deleteinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.common.OperationMetadata; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.DeleteInstanceRequest; +import com.google.cloud.filestore.v1.InstanceName; +import com.google.protobuf.Empty; + +public class AsyncDeleteInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteInstanceLRO(); + } + + public static void asyncDeleteInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + DeleteInstanceRequest request = + DeleteInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + OperationFuture future = + cloudFilestoreManagerClient.deleteInstanceOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_deleteinstance_lro_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstance.java new file mode 100644 index 000000000000..1bb441de618b --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstance.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_deleteinstance_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.DeleteInstanceRequest; +import com.google.cloud.filestore.v1.InstanceName; + +public class SyncDeleteInstance { + + public static void main(String[] args) throws Exception { + syncDeleteInstance(); + } + + public static void syncDeleteInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + DeleteInstanceRequest request = + DeleteInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + cloudFilestoreManagerClient.deleteInstanceAsync(request).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_deleteinstance_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstanceInstancename.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstanceInstancename.java new file mode 100644 index 000000000000..79bd94c5b8ed --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstanceInstancename.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_deleteinstance_instancename_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.InstanceName; + +public class SyncDeleteInstanceInstancename { + + public static void main(String[] args) throws Exception { + syncDeleteInstanceInstancename(); + } + + public static void syncDeleteInstanceInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + cloudFilestoreManagerClient.deleteInstanceAsync(name).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_deleteinstance_instancename_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstanceString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstanceString.java new file mode 100644 index 000000000000..c82efc9f4e9a --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstanceString.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_deleteinstance_string_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.InstanceName; + +public class SyncDeleteInstanceString { + + public static void main(String[] args) throws Exception { + syncDeleteInstanceString(); + } + + public static void syncDeleteInstanceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + cloudFilestoreManagerClient.deleteInstanceAsync(name).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_deleteinstance_string_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getbackup/AsyncGetBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getbackup/AsyncGetBackup.java new file mode 100644 index 000000000000..b4df3bc56d16 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getbackup/AsyncGetBackup.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_getbackup_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.BackupName; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + GetBackupRequest request = + GetBackupRequest.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .build(); + ApiFuture future = + cloudFilestoreManagerClient.getBackupCallable().futureCall(request); + // Do something. + Backup response = future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_getbackup_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getbackup/SyncGetBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getbackup/SyncGetBackup.java new file mode 100644 index 000000000000..61f3b96d4e6c --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_getbackup_sync] +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.BackupName; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + GetBackupRequest request = + GetBackupRequest.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .build(); + Backup response = cloudFilestoreManagerClient.getBackup(request); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_getbackup_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getbackup/SyncGetBackupBackupname.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getbackup/SyncGetBackupBackupname.java new file mode 100644 index 000000000000..5dc063ec4093 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getbackup/SyncGetBackupBackupname.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_getbackup_backupname_sync] +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.BackupName; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + Backup response = cloudFilestoreManagerClient.getBackup(name); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_getbackup_backupname_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getbackup/SyncGetBackupString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getbackup/SyncGetBackupString.java new file mode 100644 index 000000000000..fcef05c8be43 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_getbackup_string_sync] +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.BackupName; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString(); + Backup response = cloudFilestoreManagerClient.getBackup(name); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_getbackup_string_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getinstance/AsyncGetInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getinstance/AsyncGetInstance.java new file mode 100644 index 000000000000..a236b2de15d7 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getinstance/AsyncGetInstance.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_getinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.GetInstanceRequest; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.InstanceName; + +public class AsyncGetInstance { + + public static void main(String[] args) throws Exception { + asyncGetInstance(); + } + + public static void asyncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + GetInstanceRequest request = + GetInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = + cloudFilestoreManagerClient.getInstanceCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_getinstance_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getinstance/SyncGetInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getinstance/SyncGetInstance.java new file mode 100644 index 000000000000..2496ef246696 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getinstance/SyncGetInstance.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_getinstance_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.GetInstanceRequest; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.InstanceName; + +public class SyncGetInstance { + + public static void main(String[] args) throws Exception { + syncGetInstance(); + } + + public static void syncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + GetInstanceRequest request = + GetInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + Instance response = cloudFilestoreManagerClient.getInstance(request); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_getinstance_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getinstance/SyncGetInstanceInstancename.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getinstance/SyncGetInstanceInstancename.java new file mode 100644 index 000000000000..89cd872e8508 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getinstance/SyncGetInstanceInstancename.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_getinstance_instancename_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.InstanceName; + +public class SyncGetInstanceInstancename { + + public static void main(String[] args) throws Exception { + syncGetInstanceInstancename(); + } + + public static void syncGetInstanceInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + Instance response = cloudFilestoreManagerClient.getInstance(name); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_getinstance_instancename_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getinstance/SyncGetInstanceString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getinstance/SyncGetInstanceString.java new file mode 100644 index 000000000000..410ea25abdd3 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/getinstance/SyncGetInstanceString.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_getinstance_string_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.InstanceName; + +public class SyncGetInstanceString { + + public static void main(String[] args) throws Exception { + syncGetInstanceString(); + } + + public static void syncGetInstanceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + Instance response = cloudFilestoreManagerClient.getInstance(name); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_getinstance_string_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/AsyncListBackups.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/AsyncListBackups.java new file mode 100644 index 000000000000..c9cce4dde56e --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/AsyncListBackups.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_listbackups_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.ListBackupsRequest; +import com.google.cloud.filestore.v1.LocationName; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + ListBackupsRequest request = + ListBackupsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + cloudFilestoreManagerClient.listBackupsPagedCallable().futureCall(request); + // Do something. + for (Backup element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_listbackups_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/AsyncListBackupsPaged.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/AsyncListBackupsPaged.java new file mode 100644 index 000000000000..9f07bf3c0aaf --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/AsyncListBackupsPaged.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_listbackups_paged_async] +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.ListBackupsRequest; +import com.google.cloud.filestore.v1.ListBackupsResponse; +import com.google.cloud.filestore.v1.LocationName; +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + ListBackupsRequest request = + ListBackupsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListBackupsResponse response = + cloudFilestoreManagerClient.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 filestore_v1_generated_cloudfilestoremanagerclient_listbackups_paged_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/SyncListBackups.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/SyncListBackups.java new file mode 100644 index 000000000000..b0ae8f307b56 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/SyncListBackups.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_listbackups_sync] +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.ListBackupsRequest; +import com.google.cloud.filestore.v1.LocationName; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + ListBackupsRequest request = + ListBackupsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setFilter("filter-1274492040") + .build(); + for (Backup element : cloudFilestoreManagerClient.listBackups(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_listbackups_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/SyncListBackupsLocationname.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/SyncListBackupsLocationname.java new file mode 100644 index 000000000000..ee03bf0d6985 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/SyncListBackupsLocationname.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_listbackups_locationname_sync] +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.LocationName; + +public class SyncListBackupsLocationname { + + public static void main(String[] args) throws Exception { + syncListBackupsLocationname(); + } + + public static void syncListBackupsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Backup element : cloudFilestoreManagerClient.listBackups(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_listbackups_locationname_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/SyncListBackupsString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/SyncListBackupsString.java new file mode 100644 index 000000000000..36fb5015e8ac --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listbackups/SyncListBackupsString.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_listbackups_string_sync] +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.LocationName; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Backup element : cloudFilestoreManagerClient.listBackups(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_listbackups_string_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/AsyncListInstances.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/AsyncListInstances.java new file mode 100644 index 000000000000..213c1f7e64b5 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/AsyncListInstances.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_listinstances_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.ListInstancesRequest; +import com.google.cloud.filestore.v1.LocationName; + +public class AsyncListInstances { + + public static void main(String[] args) throws Exception { + asyncListInstances(); + } + + public static void asyncListInstances() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + cloudFilestoreManagerClient.listInstancesPagedCallable().futureCall(request); + // Do something. + for (Instance element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_listinstances_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/AsyncListInstancesPaged.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/AsyncListInstancesPaged.java new file mode 100644 index 000000000000..215d2f2c86cf --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/AsyncListInstancesPaged.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_listinstances_paged_async] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.ListInstancesRequest; +import com.google.cloud.filestore.v1.ListInstancesResponse; +import com.google.cloud.filestore.v1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListInstancesPaged { + + public static void main(String[] args) throws Exception { + asyncListInstancesPaged(); + } + + public static void asyncListInstancesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListInstancesResponse response = + cloudFilestoreManagerClient.listInstancesCallable().call(request); + for (Instance element : response.getInstancesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_listinstances_paged_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/SyncListInstances.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/SyncListInstances.java new file mode 100644 index 000000000000..e93dc20221c3 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/SyncListInstances.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_listinstances_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.ListInstancesRequest; +import com.google.cloud.filestore.v1.LocationName; + +public class SyncListInstances { + + public static void main(String[] args) throws Exception { + syncListInstances(); + } + + public static void syncListInstances() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setFilter("filter-1274492040") + .build(); + for (Instance element : cloudFilestoreManagerClient.listInstances(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_listinstances_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/SyncListInstancesLocationname.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/SyncListInstancesLocationname.java new file mode 100644 index 000000000000..53d9f9b19c8d --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/SyncListInstancesLocationname.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_listinstances_locationname_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.LocationName; + +public class SyncListInstancesLocationname { + + public static void main(String[] args) throws Exception { + syncListInstancesLocationname(); + } + + public static void syncListInstancesLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Instance element : cloudFilestoreManagerClient.listInstances(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_listinstances_locationname_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/SyncListInstancesString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/SyncListInstancesString.java new file mode 100644 index 000000000000..e6e99ef78eb7 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/listinstances/SyncListInstancesString.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_listinstances_string_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.LocationName; + +public class SyncListInstancesString { + + public static void main(String[] args) throws Exception { + syncListInstancesString(); + } + + public static void syncListInstancesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Instance element : cloudFilestoreManagerClient.listInstances(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_listinstances_string_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/restoreinstance/AsyncRestoreInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/restoreinstance/AsyncRestoreInstance.java new file mode 100644 index 000000000000..627e73e257bc --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/restoreinstance/AsyncRestoreInstance.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_restoreinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.InstanceName; +import com.google.cloud.filestore.v1.RestoreInstanceRequest; +import com.google.longrunning.Operation; + +public class AsyncRestoreInstance { + + public static void main(String[] args) throws Exception { + asyncRestoreInstance(); + } + + public static void asyncRestoreInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + RestoreInstanceRequest request = + RestoreInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setFileShare("fileShare-1327728701") + .build(); + ApiFuture future = + cloudFilestoreManagerClient.restoreInstanceCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_restoreinstance_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/restoreinstance/AsyncRestoreInstanceLRO.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/restoreinstance/AsyncRestoreInstanceLRO.java new file mode 100644 index 000000000000..d29e8e1e9325 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/restoreinstance/AsyncRestoreInstanceLRO.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_restoreinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.common.OperationMetadata; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.InstanceName; +import com.google.cloud.filestore.v1.RestoreInstanceRequest; + +public class AsyncRestoreInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncRestoreInstanceLRO(); + } + + public static void asyncRestoreInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + RestoreInstanceRequest request = + RestoreInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setFileShare("fileShare-1327728701") + .build(); + OperationFuture future = + cloudFilestoreManagerClient.restoreInstanceOperationCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_restoreinstance_lro_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/restoreinstance/SyncRestoreInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/restoreinstance/SyncRestoreInstance.java new file mode 100644 index 000000000000..63896d2aff37 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/restoreinstance/SyncRestoreInstance.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_restoreinstance_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.InstanceName; +import com.google.cloud.filestore.v1.RestoreInstanceRequest; + +public class SyncRestoreInstance { + + public static void main(String[] args) throws Exception { + syncRestoreInstance(); + } + + public static void syncRestoreInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + RestoreInstanceRequest request = + RestoreInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setFileShare("fileShare-1327728701") + .build(); + Instance response = cloudFilestoreManagerClient.restoreInstanceAsync(request).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_restoreinstance_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updatebackup/AsyncUpdateBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updatebackup/AsyncUpdateBackup.java new file mode 100644 index 000000000000..7c1d803980ae --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updatebackup/AsyncUpdateBackup.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_updatebackup_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + UpdateBackupRequest request = + UpdateBackupRequest.newBuilder() + .setBackup(Backup.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + cloudFilestoreManagerClient.updateBackupCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_updatebackup_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updatebackup/AsyncUpdateBackupLRO.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updatebackup/AsyncUpdateBackupLRO.java new file mode 100644 index 000000000000..8cc923ba6445 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updatebackup/AsyncUpdateBackupLRO.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_updatebackup_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.common.OperationMetadata; +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + UpdateBackupRequest request = + UpdateBackupRequest.newBuilder() + .setBackup(Backup.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + cloudFilestoreManagerClient.updateBackupOperationCallable().futureCall(request); + // Do something. + Backup response = future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_updatebackup_lro_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updatebackup/SyncUpdateBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updatebackup/SyncUpdateBackup.java new file mode 100644 index 000000000000..efacf6f4070c --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updatebackup/SyncUpdateBackup.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_updatebackup_sync] +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + UpdateBackupRequest request = + UpdateBackupRequest.newBuilder() + .setBackup(Backup.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Backup response = cloudFilestoreManagerClient.updateBackupAsync(request).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_updatebackup_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updatebackup/SyncUpdateBackupBackupFieldmask.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updatebackup/SyncUpdateBackupBackupFieldmask.java new file mode 100644 index 000000000000..e872c1effa10 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updatebackup/SyncUpdateBackupBackupFieldmask.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_updatebackup_backupfieldmask_sync] +import com.google.cloud.filestore.v1.Backup; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + Backup backup = Backup.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Backup response = cloudFilestoreManagerClient.updateBackupAsync(backup, updateMask).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_updatebackup_backupfieldmask_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updateinstance/AsyncUpdateInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updateinstance/AsyncUpdateInstance.java new file mode 100644 index 000000000000..e49d70925f4b --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updateinstance/AsyncUpdateInstance.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_updateinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.UpdateInstanceRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateInstance { + + public static void main(String[] args) throws Exception { + asyncUpdateInstance(); + } + + public static void asyncUpdateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + UpdateInstanceRequest request = + UpdateInstanceRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setInstance(Instance.newBuilder().build()) + .build(); + ApiFuture future = + cloudFilestoreManagerClient.updateInstanceCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_updateinstance_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updateinstance/AsyncUpdateInstanceLRO.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updateinstance/AsyncUpdateInstanceLRO.java new file mode 100644 index 000000000000..0cbeb2de2bd3 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updateinstance/AsyncUpdateInstanceLRO.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_updateinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.common.OperationMetadata; +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.UpdateInstanceRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateInstanceLRO(); + } + + public static void asyncUpdateInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + UpdateInstanceRequest request = + UpdateInstanceRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setInstance(Instance.newBuilder().build()) + .build(); + OperationFuture future = + cloudFilestoreManagerClient.updateInstanceOperationCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_updateinstance_lro_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updateinstance/SyncUpdateInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updateinstance/SyncUpdateInstance.java new file mode 100644 index 000000000000..7ce812372947 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updateinstance/SyncUpdateInstance.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_updateinstance_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.cloud.filestore.v1.UpdateInstanceRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateInstance { + + public static void main(String[] args) throws Exception { + syncUpdateInstance(); + } + + public static void syncUpdateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + UpdateInstanceRequest request = + UpdateInstanceRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setInstance(Instance.newBuilder().build()) + .build(); + Instance response = cloudFilestoreManagerClient.updateInstanceAsync(request).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_updateinstance_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updateinstance/SyncUpdateInstanceInstanceFieldmask.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updateinstance/SyncUpdateInstanceInstanceFieldmask.java new file mode 100644 index 000000000000..42dbce80ffc4 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagerclient/updateinstance/SyncUpdateInstanceInstanceFieldmask.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerclient_updateinstance_instancefieldmask_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1.Instance; +import com.google.protobuf.FieldMask; + +public class SyncUpdateInstanceInstanceFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateInstanceInstanceFieldmask(); + } + + public static void syncUpdateInstanceInstanceFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + Instance instance = Instance.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Instance response = + cloudFilestoreManagerClient.updateInstanceAsync(instance, updateMask).get(); + } + } +} +// [END filestore_v1_generated_cloudfilestoremanagerclient_updateinstance_instancefieldmask_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagersettings/getinstance/SyncGetInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagersettings/getinstance/SyncGetInstance.java new file mode 100644 index 000000000000..ff44b8b7bc81 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/cloudfilestoremanagersettings/getinstance/SyncGetInstance.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.filestore.v1.samples; + +// [START filestore_v1_generated_cloudfilestoremanagersettings_getinstance_sync] +import com.google.cloud.filestore.v1.CloudFilestoreManagerSettings; +import java.time.Duration; + +public class SyncGetInstance { + + public static void main(String[] args) throws Exception { + syncGetInstance(); + } + + public static void syncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CloudFilestoreManagerSettings.Builder cloudFilestoreManagerSettingsBuilder = + CloudFilestoreManagerSettings.newBuilder(); + cloudFilestoreManagerSettingsBuilder + .getInstanceSettings() + .setRetrySettings( + cloudFilestoreManagerSettingsBuilder + .getInstanceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CloudFilestoreManagerSettings cloudFilestoreManagerSettings = + cloudFilestoreManagerSettingsBuilder.build(); + } +} +// [END filestore_v1_generated_cloudfilestoremanagersettings_getinstance_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/stub/cloudfilestoremanagerstubsettings/getinstance/SyncGetInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/stub/cloudfilestoremanagerstubsettings/getinstance/SyncGetInstance.java new file mode 100644 index 000000000000..d8a10e166341 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1/stub/cloudfilestoremanagerstubsettings/getinstance/SyncGetInstance.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.filestore.v1.stub.samples; + +// [START filestore_v1_generated_cloudfilestoremanagerstubsettings_getinstance_sync] +import com.google.cloud.filestore.v1.stub.CloudFilestoreManagerStubSettings; +import java.time.Duration; + +public class SyncGetInstance { + + public static void main(String[] args) throws Exception { + syncGetInstance(); + } + + public static void syncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CloudFilestoreManagerStubSettings.Builder cloudFilestoreManagerSettingsBuilder = + CloudFilestoreManagerStubSettings.newBuilder(); + cloudFilestoreManagerSettingsBuilder + .getInstanceSettings() + .setRetrySettings( + cloudFilestoreManagerSettingsBuilder + .getInstanceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CloudFilestoreManagerStubSettings cloudFilestoreManagerSettings = + cloudFilestoreManagerSettingsBuilder.build(); + } +} +// [END filestore_v1_generated_cloudfilestoremanagerstubsettings_getinstance_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/create/SyncCreateSetCredentialsProvider.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..976189f69196 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/create/SyncCreateSetCredentialsProvider.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.filestore.v1beta1.samples; + +// [START +// filestore_v1beta1_generated_cloudfilestoremanagerclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerSettings; +import com.google.cloud.filestore.v1beta1.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. + CloudFilestoreManagerSettings cloudFilestoreManagerSettings = + CloudFilestoreManagerSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create(cloudFilestoreManagerSettings); + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_create_setcredentialsprovider_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/create/SyncCreateSetCredentialsProvider1.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..b78f5d3973f7 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/create/SyncCreateSetCredentialsProvider1.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.filestore.v1beta1.samples; + +// [START +// filestore_v1beta1_generated_cloudfilestoremanagerclient_create_setcredentialsprovider1_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerSettings; + +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. + CloudFilestoreManagerSettings cloudFilestoreManagerSettings = + CloudFilestoreManagerSettings.newBuilder() + .setTransportChannelProvider( + CloudFilestoreManagerSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create(cloudFilestoreManagerSettings); + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_create_setcredentialsprovider1_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/create/SyncCreateSetEndpoint.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..3a997277fe23 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,39 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_create_setendpoint_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerSettings; +import com.google.cloud.filestore.v1beta1.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. + CloudFilestoreManagerSettings cloudFilestoreManagerSettings = + CloudFilestoreManagerSettings.newBuilder().setEndpoint(myEndpoint).build(); + CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create(cloudFilestoreManagerSettings); + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_create_setendpoint_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/AsyncCreateBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/AsyncCreateBackup.java new file mode 100644 index 000000000000..38717f70a1d7 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/AsyncCreateBackup.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_createbackup_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.CreateBackupRequest; +import com.google.cloud.filestore.v1beta1.LocationName; +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + CreateBackupRequest request = + CreateBackupRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setBackup(Backup.newBuilder().build()) + .setBackupId("backupId2121930365") + .build(); + ApiFuture future = + cloudFilestoreManagerClient.createBackupCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_createbackup_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/AsyncCreateBackupLRO.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/AsyncCreateBackupLRO.java new file mode 100644 index 000000000000..e2c04c78abf4 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/AsyncCreateBackupLRO.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_createbackup_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.common.OperationMetadata; +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.CreateBackupRequest; +import com.google.cloud.filestore.v1beta1.LocationName; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + CreateBackupRequest request = + CreateBackupRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setBackup(Backup.newBuilder().build()) + .setBackupId("backupId2121930365") + .build(); + OperationFuture future = + cloudFilestoreManagerClient.createBackupOperationCallable().futureCall(request); + // Do something. + Backup response = future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_createbackup_lro_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/SyncCreateBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/SyncCreateBackup.java new file mode 100644 index 000000000000..5e4ac9a79235 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/SyncCreateBackup.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_createbackup_sync] +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.CreateBackupRequest; +import com.google.cloud.filestore.v1beta1.LocationName; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + CreateBackupRequest request = + CreateBackupRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setBackup(Backup.newBuilder().build()) + .setBackupId("backupId2121930365") + .build(); + Backup response = cloudFilestoreManagerClient.createBackupAsync(request).get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_createbackup_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/SyncCreateBackupLocationnameBackupString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/SyncCreateBackupLocationnameBackupString.java new file mode 100644 index 000000000000..c380bbaee31a --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/SyncCreateBackupLocationnameBackupString.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.filestore.v1beta1.samples; + +// [START +// filestore_v1beta1_generated_cloudfilestoremanagerclient_createbackup_locationnamebackupstring_sync] +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.LocationName; + +public class SyncCreateBackupLocationnameBackupString { + + public static void main(String[] args) throws Exception { + syncCreateBackupLocationnameBackupString(); + } + + public static void syncCreateBackupLocationnameBackupString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Backup backup = Backup.newBuilder().build(); + String backupId = "backupId2121930365"; + Backup response = + cloudFilestoreManagerClient.createBackupAsync(parent, backup, backupId).get(); + } + } +} +// [END +// filestore_v1beta1_generated_cloudfilestoremanagerclient_createbackup_locationnamebackupstring_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/SyncCreateBackupStringBackupString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/SyncCreateBackupStringBackupString.java new file mode 100644 index 000000000000..7c62eeb6f5d9 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createbackup/SyncCreateBackupStringBackupString.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.filestore.v1beta1.samples; + +// [START +// filestore_v1beta1_generated_cloudfilestoremanagerclient_createbackup_stringbackupstring_sync] +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.LocationName; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Backup backup = Backup.newBuilder().build(); + String backupId = "backupId2121930365"; + Backup response = + cloudFilestoreManagerClient.createBackupAsync(parent, backup, backupId).get(); + } + } +} +// [END +// filestore_v1beta1_generated_cloudfilestoremanagerclient_createbackup_stringbackupstring_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/AsyncCreateInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/AsyncCreateInstance.java new file mode 100644 index 000000000000..4aece0eeb995 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/AsyncCreateInstance.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_createinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.CreateInstanceRequest; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.LocationName; +import com.google.longrunning.Operation; + +public class AsyncCreateInstance { + + public static void main(String[] args) throws Exception { + asyncCreateInstance(); + } + + public static void asyncCreateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + CreateInstanceRequest request = + CreateInstanceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInstanceId("instanceId902024336") + .setInstance(Instance.newBuilder().build()) + .build(); + ApiFuture future = + cloudFilestoreManagerClient.createInstanceCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_createinstance_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/AsyncCreateInstanceLRO.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/AsyncCreateInstanceLRO.java new file mode 100644 index 000000000000..1071b4cc7f2c --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/AsyncCreateInstanceLRO.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_createinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.common.OperationMetadata; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.CreateInstanceRequest; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.LocationName; + +public class AsyncCreateInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncCreateInstanceLRO(); + } + + public static void asyncCreateInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + CreateInstanceRequest request = + CreateInstanceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInstanceId("instanceId902024336") + .setInstance(Instance.newBuilder().build()) + .build(); + OperationFuture future = + cloudFilestoreManagerClient.createInstanceOperationCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_createinstance_lro_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/SyncCreateInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/SyncCreateInstance.java new file mode 100644 index 000000000000..cf8712405d22 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/SyncCreateInstance.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_createinstance_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.CreateInstanceRequest; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.LocationName; + +public class SyncCreateInstance { + + public static void main(String[] args) throws Exception { + syncCreateInstance(); + } + + public static void syncCreateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + CreateInstanceRequest request = + CreateInstanceRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setInstanceId("instanceId902024336") + .setInstance(Instance.newBuilder().build()) + .build(); + Instance response = cloudFilestoreManagerClient.createInstanceAsync(request).get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_createinstance_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/SyncCreateInstanceLocationnameInstanceString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/SyncCreateInstanceLocationnameInstanceString.java new file mode 100644 index 000000000000..17b00c347cbc --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/SyncCreateInstanceLocationnameInstanceString.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.filestore.v1beta1.samples; + +// [START +// filestore_v1beta1_generated_cloudfilestoremanagerclient_createinstance_locationnameinstancestring_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.LocationName; + +public class SyncCreateInstanceLocationnameInstanceString { + + public static void main(String[] args) throws Exception { + syncCreateInstanceLocationnameInstanceString(); + } + + public static void syncCreateInstanceLocationnameInstanceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + Instance response = + cloudFilestoreManagerClient.createInstanceAsync(parent, instance, instanceId).get(); + } + } +} +// [END +// filestore_v1beta1_generated_cloudfilestoremanagerclient_createinstance_locationnameinstancestring_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/SyncCreateInstanceStringInstanceString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/SyncCreateInstanceStringInstanceString.java new file mode 100644 index 000000000000..e807984c1f7e --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/createinstance/SyncCreateInstanceStringInstanceString.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.filestore.v1beta1.samples; + +// [START +// filestore_v1beta1_generated_cloudfilestoremanagerclient_createinstance_stringinstancestring_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.LocationName; + +public class SyncCreateInstanceStringInstanceString { + + public static void main(String[] args) throws Exception { + syncCreateInstanceStringInstanceString(); + } + + public static void syncCreateInstanceStringInstanceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Instance instance = Instance.newBuilder().build(); + String instanceId = "instanceId902024336"; + Instance response = + cloudFilestoreManagerClient.createInstanceAsync(parent, instance, instanceId).get(); + } + } +} +// [END +// filestore_v1beta1_generated_cloudfilestoremanagerclient_createinstance_stringinstancestring_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deletebackup/AsyncDeleteBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deletebackup/AsyncDeleteBackup.java new file mode 100644 index 000000000000..ac9f5b9c6d0e --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deletebackup/AsyncDeleteBackup.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_deletebackup_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1beta1.BackupName; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + DeleteBackupRequest request = + DeleteBackupRequest.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .build(); + ApiFuture future = + cloudFilestoreManagerClient.deleteBackupCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_deletebackup_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deletebackup/AsyncDeleteBackupLRO.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deletebackup/AsyncDeleteBackupLRO.java new file mode 100644 index 000000000000..ceca8a8df3cc --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deletebackup/AsyncDeleteBackupLRO.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_deletebackup_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.common.OperationMetadata; +import com.google.cloud.filestore.v1beta1.BackupName; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.DeleteBackupRequest; +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + DeleteBackupRequest request = + DeleteBackupRequest.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .build(); + OperationFuture future = + cloudFilestoreManagerClient.deleteBackupOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_deletebackup_lro_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackup.java new file mode 100644 index 000000000000..d143d9b30942 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackup.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_deletebackup_sync] +import com.google.cloud.filestore.v1beta1.BackupName; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.DeleteBackupRequest; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + DeleteBackupRequest request = + DeleteBackupRequest.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .build(); + cloudFilestoreManagerClient.deleteBackupAsync(request).get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_deletebackup_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackupBackupname.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackupBackupname.java new file mode 100644 index 000000000000..3bdc5a4d204e --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_deletebackup_backupname_sync] +import com.google.cloud.filestore.v1beta1.BackupName; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + cloudFilestoreManagerClient.deleteBackupAsync(name).get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_deletebackup_backupname_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackupString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackupString.java new file mode 100644 index 000000000000..3f0fbb56641a --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deletebackup/SyncDeleteBackupString.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_deletebackup_string_sync] +import com.google.cloud.filestore.v1beta1.BackupName; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString(); + cloudFilestoreManagerClient.deleteBackupAsync(name).get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_deletebackup_string_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/AsyncDeleteInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/AsyncDeleteInstance.java new file mode 100644 index 000000000000..7c74e56c47db --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/AsyncDeleteInstance.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_deleteinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.DeleteInstanceRequest; +import com.google.cloud.filestore.v1beta1.InstanceName; +import com.google.longrunning.Operation; + +public class AsyncDeleteInstance { + + public static void main(String[] args) throws Exception { + asyncDeleteInstance(); + } + + public static void asyncDeleteInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + DeleteInstanceRequest request = + DeleteInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = + cloudFilestoreManagerClient.deleteInstanceCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_deleteinstance_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/AsyncDeleteInstanceLRO.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/AsyncDeleteInstanceLRO.java new file mode 100644 index 000000000000..e20b4c6cef50 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/AsyncDeleteInstanceLRO.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_deleteinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.common.OperationMetadata; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.DeleteInstanceRequest; +import com.google.cloud.filestore.v1beta1.InstanceName; +import com.google.protobuf.Empty; + +public class AsyncDeleteInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteInstanceLRO(); + } + + public static void asyncDeleteInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + DeleteInstanceRequest request = + DeleteInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + OperationFuture future = + cloudFilestoreManagerClient.deleteInstanceOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_deleteinstance_lro_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstance.java new file mode 100644 index 000000000000..b335777ba08c --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstance.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_deleteinstance_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.DeleteInstanceRequest; +import com.google.cloud.filestore.v1beta1.InstanceName; + +public class SyncDeleteInstance { + + public static void main(String[] args) throws Exception { + syncDeleteInstance(); + } + + public static void syncDeleteInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + DeleteInstanceRequest request = + DeleteInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + cloudFilestoreManagerClient.deleteInstanceAsync(request).get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_deleteinstance_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstanceInstancename.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstanceInstancename.java new file mode 100644 index 000000000000..72f45e522647 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstanceInstancename.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_deleteinstance_instancename_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.InstanceName; + +public class SyncDeleteInstanceInstancename { + + public static void main(String[] args) throws Exception { + syncDeleteInstanceInstancename(); + } + + public static void syncDeleteInstanceInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + cloudFilestoreManagerClient.deleteInstanceAsync(name).get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_deleteinstance_instancename_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstanceString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstanceString.java new file mode 100644 index 000000000000..9185678ae4d3 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/deleteinstance/SyncDeleteInstanceString.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_deleteinstance_string_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.InstanceName; + +public class SyncDeleteInstanceString { + + public static void main(String[] args) throws Exception { + syncDeleteInstanceString(); + } + + public static void syncDeleteInstanceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + cloudFilestoreManagerClient.deleteInstanceAsync(name).get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_deleteinstance_string_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getbackup/AsyncGetBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getbackup/AsyncGetBackup.java new file mode 100644 index 000000000000..b29ff1d7f649 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getbackup/AsyncGetBackup.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_getbackup_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.BackupName; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + GetBackupRequest request = + GetBackupRequest.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .build(); + ApiFuture future = + cloudFilestoreManagerClient.getBackupCallable().futureCall(request); + // Do something. + Backup response = future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_getbackup_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getbackup/SyncGetBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getbackup/SyncGetBackup.java new file mode 100644 index 000000000000..c0e30720fb17 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_getbackup_sync] +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.BackupName; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + GetBackupRequest request = + GetBackupRequest.newBuilder() + .setName(BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString()) + .build(); + Backup response = cloudFilestoreManagerClient.getBackup(request); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_getbackup_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getbackup/SyncGetBackupBackupname.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getbackup/SyncGetBackupBackupname.java new file mode 100644 index 000000000000..ace688982c69 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getbackup/SyncGetBackupBackupname.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_getbackup_backupname_sync] +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.BackupName; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + BackupName name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]"); + Backup response = cloudFilestoreManagerClient.getBackup(name); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_getbackup_backupname_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getbackup/SyncGetBackupString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getbackup/SyncGetBackupString.java new file mode 100644 index 000000000000..54f2148be843 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_getbackup_string_sync] +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.BackupName; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String name = BackupName.of("[PROJECT]", "[LOCATION]", "[BACKUP]").toString(); + Backup response = cloudFilestoreManagerClient.getBackup(name); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_getbackup_string_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getinstance/AsyncGetInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getinstance/AsyncGetInstance.java new file mode 100644 index 000000000000..a4e93e5fa7e0 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getinstance/AsyncGetInstance.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_getinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.GetInstanceRequest; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.InstanceName; + +public class AsyncGetInstance { + + public static void main(String[] args) throws Exception { + asyncGetInstance(); + } + + public static void asyncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + GetInstanceRequest request = + GetInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = + cloudFilestoreManagerClient.getInstanceCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_getinstance_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getinstance/SyncGetInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getinstance/SyncGetInstance.java new file mode 100644 index 000000000000..a433ed0fe02b --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getinstance/SyncGetInstance.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_getinstance_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.GetInstanceRequest; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.InstanceName; + +public class SyncGetInstance { + + public static void main(String[] args) throws Exception { + syncGetInstance(); + } + + public static void syncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + GetInstanceRequest request = + GetInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + Instance response = cloudFilestoreManagerClient.getInstance(request); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_getinstance_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getinstance/SyncGetInstanceInstancename.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getinstance/SyncGetInstanceInstancename.java new file mode 100644 index 000000000000..66bc2caed2fe --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getinstance/SyncGetInstanceInstancename.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_getinstance_instancename_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.InstanceName; + +public class SyncGetInstanceInstancename { + + public static void main(String[] args) throws Exception { + syncGetInstanceInstancename(); + } + + public static void syncGetInstanceInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + InstanceName name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + Instance response = cloudFilestoreManagerClient.getInstance(name); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_getinstance_instancename_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getinstance/SyncGetInstanceString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getinstance/SyncGetInstanceString.java new file mode 100644 index 000000000000..5e5c7e597b7a --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/getinstance/SyncGetInstanceString.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_getinstance_string_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.InstanceName; + +public class SyncGetInstanceString { + + public static void main(String[] args) throws Exception { + syncGetInstanceString(); + } + + public static void syncGetInstanceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String name = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + Instance response = cloudFilestoreManagerClient.getInstance(name); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_getinstance_string_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/AsyncListBackups.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/AsyncListBackups.java new file mode 100644 index 000000000000..18316ed04087 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/AsyncListBackups.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_listbackups_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.ListBackupsRequest; +import com.google.cloud.filestore.v1beta1.LocationName; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + ListBackupsRequest request = + ListBackupsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + cloudFilestoreManagerClient.listBackupsPagedCallable().futureCall(request); + // Do something. + for (Backup element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_listbackups_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/AsyncListBackupsPaged.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/AsyncListBackupsPaged.java new file mode 100644 index 000000000000..89be677d26e9 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/AsyncListBackupsPaged.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_listbackups_paged_async] +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.ListBackupsRequest; +import com.google.cloud.filestore.v1beta1.ListBackupsResponse; +import com.google.cloud.filestore.v1beta1.LocationName; +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + ListBackupsRequest request = + ListBackupsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListBackupsResponse response = + cloudFilestoreManagerClient.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 filestore_v1beta1_generated_cloudfilestoremanagerclient_listbackups_paged_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/SyncListBackups.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/SyncListBackups.java new file mode 100644 index 000000000000..5e8e3a97ae9d --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/SyncListBackups.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_listbackups_sync] +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.ListBackupsRequest; +import com.google.cloud.filestore.v1beta1.LocationName; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + ListBackupsRequest request = + ListBackupsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setFilter("filter-1274492040") + .build(); + for (Backup element : cloudFilestoreManagerClient.listBackups(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_listbackups_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/SyncListBackupsLocationname.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/SyncListBackupsLocationname.java new file mode 100644 index 000000000000..2a5f6d53b764 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/SyncListBackupsLocationname.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_listbackups_locationname_sync] +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.LocationName; + +public class SyncListBackupsLocationname { + + public static void main(String[] args) throws Exception { + syncListBackupsLocationname(); + } + + public static void syncListBackupsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Backup element : cloudFilestoreManagerClient.listBackups(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_listbackups_locationname_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/SyncListBackupsString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/SyncListBackupsString.java new file mode 100644 index 000000000000..7b02b45b3978 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listbackups/SyncListBackupsString.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_listbackups_string_sync] +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.LocationName; + +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Backup element : cloudFilestoreManagerClient.listBackups(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_listbackups_string_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/AsyncListInstances.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/AsyncListInstances.java new file mode 100644 index 000000000000..a785979a6596 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/AsyncListInstances.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_listinstances_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.ListInstancesRequest; +import com.google.cloud.filestore.v1beta1.LocationName; + +public class AsyncListInstances { + + public static void main(String[] args) throws Exception { + asyncListInstances(); + } + + public static void asyncListInstances() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + cloudFilestoreManagerClient.listInstancesPagedCallable().futureCall(request); + // Do something. + for (Instance element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_listinstances_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/AsyncListInstancesPaged.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/AsyncListInstancesPaged.java new file mode 100644 index 000000000000..ea6275b185b5 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/AsyncListInstancesPaged.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_listinstances_paged_async] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.ListInstancesRequest; +import com.google.cloud.filestore.v1beta1.ListInstancesResponse; +import com.google.cloud.filestore.v1beta1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListInstancesPaged { + + public static void main(String[] args) throws Exception { + asyncListInstancesPaged(); + } + + public static void asyncListInstancesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListInstancesResponse response = + cloudFilestoreManagerClient.listInstancesCallable().call(request); + for (Instance element : response.getInstancesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_listinstances_paged_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/SyncListInstances.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/SyncListInstances.java new file mode 100644 index 000000000000..d889bba0687f --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/SyncListInstances.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_listinstances_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.ListInstancesRequest; +import com.google.cloud.filestore.v1beta1.LocationName; + +public class SyncListInstances { + + public static void main(String[] args) throws Exception { + syncListInstances(); + } + + public static void syncListInstances() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + ListInstancesRequest request = + ListInstancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setOrderBy("orderBy-1207110587") + .setFilter("filter-1274492040") + .build(); + for (Instance element : cloudFilestoreManagerClient.listInstances(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_listinstances_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/SyncListInstancesLocationname.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/SyncListInstancesLocationname.java new file mode 100644 index 000000000000..b29cbeb9b4d0 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/SyncListInstancesLocationname.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_listinstances_locationname_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.LocationName; + +public class SyncListInstancesLocationname { + + public static void main(String[] args) throws Exception { + syncListInstancesLocationname(); + } + + public static void syncListInstancesLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Instance element : cloudFilestoreManagerClient.listInstances(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_listinstances_locationname_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/SyncListInstancesString.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/SyncListInstancesString.java new file mode 100644 index 000000000000..b4723dcaf318 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/listinstances/SyncListInstancesString.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_listinstances_string_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.LocationName; + +public class SyncListInstancesString { + + public static void main(String[] args) throws Exception { + syncListInstancesString(); + } + + public static void syncListInstancesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Instance element : cloudFilestoreManagerClient.listInstances(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_listinstances_string_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/restoreinstance/AsyncRestoreInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/restoreinstance/AsyncRestoreInstance.java new file mode 100644 index 000000000000..fbc467cbae0c --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/restoreinstance/AsyncRestoreInstance.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_restoreinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.InstanceName; +import com.google.cloud.filestore.v1beta1.RestoreInstanceRequest; +import com.google.longrunning.Operation; + +public class AsyncRestoreInstance { + + public static void main(String[] args) throws Exception { + asyncRestoreInstance(); + } + + public static void asyncRestoreInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + RestoreInstanceRequest request = + RestoreInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setFileShare("fileShare-1327728701") + .build(); + ApiFuture future = + cloudFilestoreManagerClient.restoreInstanceCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_restoreinstance_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/restoreinstance/AsyncRestoreInstanceLRO.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/restoreinstance/AsyncRestoreInstanceLRO.java new file mode 100644 index 000000000000..bb43a5796cf7 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/restoreinstance/AsyncRestoreInstanceLRO.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_restoreinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.common.OperationMetadata; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.InstanceName; +import com.google.cloud.filestore.v1beta1.RestoreInstanceRequest; + +public class AsyncRestoreInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncRestoreInstanceLRO(); + } + + public static void asyncRestoreInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + RestoreInstanceRequest request = + RestoreInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setFileShare("fileShare-1327728701") + .build(); + OperationFuture future = + cloudFilestoreManagerClient.restoreInstanceOperationCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_restoreinstance_lro_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/restoreinstance/SyncRestoreInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/restoreinstance/SyncRestoreInstance.java new file mode 100644 index 000000000000..d3e3588e53f8 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/restoreinstance/SyncRestoreInstance.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_restoreinstance_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.InstanceName; +import com.google.cloud.filestore.v1beta1.RestoreInstanceRequest; + +public class SyncRestoreInstance { + + public static void main(String[] args) throws Exception { + syncRestoreInstance(); + } + + public static void syncRestoreInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + RestoreInstanceRequest request = + RestoreInstanceRequest.newBuilder() + .setName(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setFileShare("fileShare-1327728701") + .build(); + Instance response = cloudFilestoreManagerClient.restoreInstanceAsync(request).get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_restoreinstance_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updatebackup/AsyncUpdateBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updatebackup/AsyncUpdateBackup.java new file mode 100644 index 000000000000..d0930f68b179 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updatebackup/AsyncUpdateBackup.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_updatebackup_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + UpdateBackupRequest request = + UpdateBackupRequest.newBuilder() + .setBackup(Backup.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + cloudFilestoreManagerClient.updateBackupCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_updatebackup_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updatebackup/AsyncUpdateBackupLRO.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updatebackup/AsyncUpdateBackupLRO.java new file mode 100644 index 000000000000..3b93f38473ee --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updatebackup/AsyncUpdateBackupLRO.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_updatebackup_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.common.OperationMetadata; +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + UpdateBackupRequest request = + UpdateBackupRequest.newBuilder() + .setBackup(Backup.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + cloudFilestoreManagerClient.updateBackupOperationCallable().futureCall(request); + // Do something. + Backup response = future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_updatebackup_lro_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updatebackup/SyncUpdateBackup.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updatebackup/SyncUpdateBackup.java new file mode 100644 index 000000000000..222234e3ba52 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updatebackup/SyncUpdateBackup.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_updatebackup_sync] +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + UpdateBackupRequest request = + UpdateBackupRequest.newBuilder() + .setBackup(Backup.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Backup response = cloudFilestoreManagerClient.updateBackupAsync(request).get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_updatebackup_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updatebackup/SyncUpdateBackupBackupFieldmask.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updatebackup/SyncUpdateBackupBackupFieldmask.java new file mode 100644 index 000000000000..8efe77f0fd83 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updatebackup/SyncUpdateBackupBackupFieldmask.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_updatebackup_backupfieldmask_sync] +import com.google.cloud.filestore.v1beta1.Backup; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +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 (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + Backup backup = Backup.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Backup response = cloudFilestoreManagerClient.updateBackupAsync(backup, updateMask).get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_updatebackup_backupfieldmask_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updateinstance/AsyncUpdateInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updateinstance/AsyncUpdateInstance.java new file mode 100644 index 000000000000..18fe46689fe0 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updateinstance/AsyncUpdateInstance.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_updateinstance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.UpdateInstanceRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateInstance { + + public static void main(String[] args) throws Exception { + asyncUpdateInstance(); + } + + public static void asyncUpdateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + UpdateInstanceRequest request = + UpdateInstanceRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setInstance(Instance.newBuilder().build()) + .build(); + ApiFuture future = + cloudFilestoreManagerClient.updateInstanceCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_updateinstance_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updateinstance/AsyncUpdateInstanceLRO.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updateinstance/AsyncUpdateInstanceLRO.java new file mode 100644 index 000000000000..38cb997e8253 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updateinstance/AsyncUpdateInstanceLRO.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_updateinstance_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.common.OperationMetadata; +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.UpdateInstanceRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateInstanceLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateInstanceLRO(); + } + + public static void asyncUpdateInstanceLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + UpdateInstanceRequest request = + UpdateInstanceRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setInstance(Instance.newBuilder().build()) + .build(); + OperationFuture future = + cloudFilestoreManagerClient.updateInstanceOperationCallable().futureCall(request); + // Do something. + Instance response = future.get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_updateinstance_lro_async] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updateinstance/SyncUpdateInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updateinstance/SyncUpdateInstance.java new file mode 100644 index 000000000000..0c826902e31c --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updateinstance/SyncUpdateInstance.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerclient_updateinstance_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.cloud.filestore.v1beta1.UpdateInstanceRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateInstance { + + public static void main(String[] args) throws Exception { + syncUpdateInstance(); + } + + public static void syncUpdateInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + UpdateInstanceRequest request = + UpdateInstanceRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setInstance(Instance.newBuilder().build()) + .build(); + Instance response = cloudFilestoreManagerClient.updateInstanceAsync(request).get(); + } + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerclient_updateinstance_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updateinstance/SyncUpdateInstanceInstanceFieldmask.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updateinstance/SyncUpdateInstanceInstanceFieldmask.java new file mode 100644 index 000000000000..fcc39f71243a --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagerclient/updateinstance/SyncUpdateInstanceInstanceFieldmask.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.filestore.v1beta1.samples; + +// [START +// filestore_v1beta1_generated_cloudfilestoremanagerclient_updateinstance_instancefieldmask_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerClient; +import com.google.cloud.filestore.v1beta1.Instance; +import com.google.protobuf.FieldMask; + +public class SyncUpdateInstanceInstanceFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateInstanceInstanceFieldmask(); + } + + public static void syncUpdateInstanceInstanceFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudFilestoreManagerClient cloudFilestoreManagerClient = + CloudFilestoreManagerClient.create()) { + Instance instance = Instance.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Instance response = + cloudFilestoreManagerClient.updateInstanceAsync(instance, updateMask).get(); + } + } +} +// [END +// filestore_v1beta1_generated_cloudfilestoremanagerclient_updateinstance_instancefieldmask_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagersettings/getinstance/SyncGetInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagersettings/getinstance/SyncGetInstance.java new file mode 100644 index 000000000000..e856cb1747b3 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/cloudfilestoremanagersettings/getinstance/SyncGetInstance.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.filestore.v1beta1.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagersettings_getinstance_sync] +import com.google.cloud.filestore.v1beta1.CloudFilestoreManagerSettings; +import java.time.Duration; + +public class SyncGetInstance { + + public static void main(String[] args) throws Exception { + syncGetInstance(); + } + + public static void syncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CloudFilestoreManagerSettings.Builder cloudFilestoreManagerSettingsBuilder = + CloudFilestoreManagerSettings.newBuilder(); + cloudFilestoreManagerSettingsBuilder + .getInstanceSettings() + .setRetrySettings( + cloudFilestoreManagerSettingsBuilder + .getInstanceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CloudFilestoreManagerSettings cloudFilestoreManagerSettings = + cloudFilestoreManagerSettingsBuilder.build(); + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagersettings_getinstance_sync] diff --git a/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/stub/cloudfilestoremanagerstubsettings/getinstance/SyncGetInstance.java b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/stub/cloudfilestoremanagerstubsettings/getinstance/SyncGetInstance.java new file mode 100644 index 000000000000..2f07b2210b23 --- /dev/null +++ b/java-filestore/samples/snippets/generated/com/google/cloud/filestore/v1beta1/stub/cloudfilestoremanagerstubsettings/getinstance/SyncGetInstance.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.filestore.v1beta1.stub.samples; + +// [START filestore_v1beta1_generated_cloudfilestoremanagerstubsettings_getinstance_sync] +import com.google.cloud.filestore.v1beta1.stub.CloudFilestoreManagerStubSettings; +import java.time.Duration; + +public class SyncGetInstance { + + public static void main(String[] args) throws Exception { + syncGetInstance(); + } + + public static void syncGetInstance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CloudFilestoreManagerStubSettings.Builder cloudFilestoreManagerSettingsBuilder = + CloudFilestoreManagerStubSettings.newBuilder(); + cloudFilestoreManagerSettingsBuilder + .getInstanceSettings() + .setRetrySettings( + cloudFilestoreManagerSettingsBuilder + .getInstanceSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CloudFilestoreManagerStubSettings cloudFilestoreManagerSettings = + cloudFilestoreManagerSettingsBuilder.build(); + } +} +// [END filestore_v1beta1_generated_cloudfilestoremanagerstubsettings_getinstance_sync]