diff --git a/java-network-management/google-cloud-network-management/pom.xml b/java-network-management/google-cloud-network-management/pom.xml index e93a8f002035..82ef50107f1c 100644 --- a/java-network-management/google-cloud-network-management/pom.xml +++ b/java-network-management/google-cloud-network-management/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-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClient.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClient.java index fdce037a1a31..9f79e5aa3b55 100644 --- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClient.java +++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClient.java @@ -18,7 +18,9 @@ import com.google.api.core.ApiFuture; 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; @@ -30,7 +32,6 @@ import com.google.cloud.networkmanagement.v1.stub.ReachabilityServiceStubSettings; 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; @@ -112,13 +113,29 @@ * ReachabilityServiceClient.create(reachabilityServiceSettings); * } * + *

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.
+ * ReachabilityServiceSettings reachabilityServiceSettings =
+ *     ReachabilityServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ReachabilityServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ReachabilityServiceClient reachabilityServiceClient =
+ *     ReachabilityServiceClient.create(reachabilityServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class ReachabilityServiceClient implements BackgroundResource { private final ReachabilityServiceSettings settings; private final ReachabilityServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ReachabilityServiceClient with default settings. */ public static final ReachabilityServiceClient create() throws IOException { @@ -150,13 +167,17 @@ public static final ReachabilityServiceClient create(ReachabilityServiceStub stu protected ReachabilityServiceClient(ReachabilityServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((ReachabilityServiceStubSettings) 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 ReachabilityServiceClient(ReachabilityServiceStub 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 ReachabilityServiceSettings getSettings() { @@ -171,10 +192,19 @@ public ReachabilityServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all Connectivity Tests owned by a project. diff --git a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceSettings.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceSettings.java index 63618a249fa2..2690e58aac9c 100644 --- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceSettings.java +++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceSettings.java @@ -23,6 +23,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; @@ -168,11 +169,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ReachabilityServiceStubSettings.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 ReachabilityServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ReachabilityServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ReachabilityServiceStubSettings.defaultTransportChannelProvider(); } @@ -182,11 +190,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ReachabilityServiceStubSettings.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); @@ -224,6 +238,11 @@ private static Builder createDefault() { return new Builder(ReachabilityServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ReachabilityServiceStubSettings.newHttpJsonBuilder()); + } + public ReachabilityServiceStubSettings.Builder getStubSettingsBuilder() { return ((ReachabilityServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/HttpJsonReachabilityServiceCallableFactory.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/HttpJsonReachabilityServiceCallableFactory.java new file mode 100644 index 000000000000..b14cf9ab20bb --- /dev/null +++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/HttpJsonReachabilityServiceCallableFactory.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.networkmanagement.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 ReachabilityService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonReachabilityServiceCallableFactory + 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-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/HttpJsonReachabilityServiceStub.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/HttpJsonReachabilityServiceStub.java new file mode 100644 index 000000000000..5fc103ece90b --- /dev/null +++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/HttpJsonReachabilityServiceStub.java @@ -0,0 +1,592 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.networkmanagement.v1.stub; + +import static com.google.cloud.networkmanagement.v1.ReachabilityServiceClient.ListConnectivityTestsPagedResponse; + +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.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1.GetConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest; +import com.google.cloud.networkmanagement.v1.ListConnectivityTestsResponse; +import com.google.cloud.networkmanagement.v1.OperationMetadata; +import com.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest; +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 ReachabilityService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonReachabilityServiceStub extends ReachabilityServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .add(ConnectivityTest.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor< + ListConnectivityTestsRequest, ListConnectivityTestsResponse> + listConnectivityTestsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.networkmanagement.v1.ReachabilityService/ListConnectivityTests") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/global}/connectivityTests", + 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(ListConnectivityTestsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getConnectivityTestMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.networkmanagement.v1.ReachabilityService/GetConnectivityTest") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/global/connectivityTests/*}", + 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(ConnectivityTest.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createConnectivityTestMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.networkmanagement.v1.ReachabilityService/CreateConnectivityTest") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/global}/connectivityTests", + 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, "testId", request.getTestId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("resource", request.getResource())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateConnectivityTestRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateConnectivityTestMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.networkmanagement.v1.ReachabilityService/UpdateConnectivityTest") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{resource.name=projects/*/locations/global/connectivityTests/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "resource.name", request.getResource().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("resource", request.getResource())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateConnectivityTestRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + rerunConnectivityTestMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.networkmanagement.v1.ReachabilityService/RerunConnectivityTest") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/global/connectivityTests/*}:rerun", + 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( + (RerunConnectivityTestRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteConnectivityTestMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.networkmanagement.v1.ReachabilityService/DeleteConnectivityTest") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/global/connectivityTests/*}", + 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( + (DeleteConnectivityTestRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable + listConnectivityTestsCallable; + private final UnaryCallable + listConnectivityTestsPagedCallable; + private final UnaryCallable + getConnectivityTestCallable; + private final UnaryCallable + createConnectivityTestCallable; + private final OperationCallable< + CreateConnectivityTestRequest, ConnectivityTest, OperationMetadata> + createConnectivityTestOperationCallable; + private final UnaryCallable + updateConnectivityTestCallable; + private final OperationCallable< + UpdateConnectivityTestRequest, ConnectivityTest, OperationMetadata> + updateConnectivityTestOperationCallable; + private final UnaryCallable + rerunConnectivityTestCallable; + private final OperationCallable + rerunConnectivityTestOperationCallable; + private final UnaryCallable + deleteConnectivityTestCallable; + private final OperationCallable + deleteConnectivityTestOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonReachabilityServiceStub create( + ReachabilityServiceStubSettings settings) throws IOException { + return new HttpJsonReachabilityServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonReachabilityServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonReachabilityServiceStub( + ReachabilityServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonReachabilityServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonReachabilityServiceStub( + ReachabilityServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonReachabilityServiceStub, 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 HttpJsonReachabilityServiceStub( + ReachabilityServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonReachabilityServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonReachabilityServiceStub, 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 HttpJsonReachabilityServiceStub( + ReachabilityServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listConnectivityTestsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listConnectivityTestsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getConnectivityTestTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getConnectivityTestMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createConnectivityTestTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createConnectivityTestMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateConnectivityTestTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateConnectivityTestMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + rerunConnectivityTestTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(rerunConnectivityTestMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteConnectivityTestTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteConnectivityTestMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listConnectivityTestsCallable = + callableFactory.createUnaryCallable( + listConnectivityTestsTransportSettings, + settings.listConnectivityTestsSettings(), + clientContext); + this.listConnectivityTestsPagedCallable = + callableFactory.createPagedCallable( + listConnectivityTestsTransportSettings, + settings.listConnectivityTestsSettings(), + clientContext); + this.getConnectivityTestCallable = + callableFactory.createUnaryCallable( + getConnectivityTestTransportSettings, + settings.getConnectivityTestSettings(), + clientContext); + this.createConnectivityTestCallable = + callableFactory.createUnaryCallable( + createConnectivityTestTransportSettings, + settings.createConnectivityTestSettings(), + clientContext); + this.createConnectivityTestOperationCallable = + callableFactory.createOperationCallable( + createConnectivityTestTransportSettings, + settings.createConnectivityTestOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateConnectivityTestCallable = + callableFactory.createUnaryCallable( + updateConnectivityTestTransportSettings, + settings.updateConnectivityTestSettings(), + clientContext); + this.updateConnectivityTestOperationCallable = + callableFactory.createOperationCallable( + updateConnectivityTestTransportSettings, + settings.updateConnectivityTestOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.rerunConnectivityTestCallable = + callableFactory.createUnaryCallable( + rerunConnectivityTestTransportSettings, + settings.rerunConnectivityTestSettings(), + clientContext); + this.rerunConnectivityTestOperationCallable = + callableFactory.createOperationCallable( + rerunConnectivityTestTransportSettings, + settings.rerunConnectivityTestOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteConnectivityTestCallable = + callableFactory.createUnaryCallable( + deleteConnectivityTestTransportSettings, + settings.deleteConnectivityTestSettings(), + clientContext); + this.deleteConnectivityTestOperationCallable = + callableFactory.createOperationCallable( + deleteConnectivityTestTransportSettings, + settings.deleteConnectivityTestOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listConnectivityTestsMethodDescriptor); + methodDescriptors.add(getConnectivityTestMethodDescriptor); + methodDescriptors.add(createConnectivityTestMethodDescriptor); + methodDescriptors.add(updateConnectivityTestMethodDescriptor); + methodDescriptors.add(rerunConnectivityTestMethodDescriptor); + methodDescriptors.add(deleteConnectivityTestMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + listConnectivityTestsCallable() { + return listConnectivityTestsCallable; + } + + @Override + public UnaryCallable + listConnectivityTestsPagedCallable() { + return listConnectivityTestsPagedCallable; + } + + @Override + public UnaryCallable getConnectivityTestCallable() { + return getConnectivityTestCallable; + } + + @Override + public UnaryCallable createConnectivityTestCallable() { + return createConnectivityTestCallable; + } + + @Override + public OperationCallable + createConnectivityTestOperationCallable() { + return createConnectivityTestOperationCallable; + } + + @Override + public UnaryCallable updateConnectivityTestCallable() { + return updateConnectivityTestCallable; + } + + @Override + public OperationCallable + updateConnectivityTestOperationCallable() { + return updateConnectivityTestOperationCallable; + } + + @Override + public UnaryCallable rerunConnectivityTestCallable() { + return rerunConnectivityTestCallable; + } + + @Override + public OperationCallable + rerunConnectivityTestOperationCallable() { + return rerunConnectivityTestOperationCallable; + } + + @Override + public UnaryCallable deleteConnectivityTestCallable() { + return deleteConnectivityTestCallable; + } + + @Override + public OperationCallable + deleteConnectivityTestOperationCallable() { + return deleteConnectivityTestOperationCallable; + } + + @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-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStub.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStub.java index 6ec5898ca64a..dd8f1ed70836 100644 --- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStub.java +++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStub.java @@ -45,7 +45,11 @@ public abstract class ReachabilityServiceStub 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-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStubSettings.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStubSettings.java index 63f83c503e86..1e29ac7d7d31 100644 --- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStubSettings.java +++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1/stub/ReachabilityServiceStubSettings.java @@ -28,6 +28,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; @@ -267,6 +270,11 @@ public ReachabilityServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcReachabilityServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonReachabilityServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -299,18 +307,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(ReachabilityServiceStubSettings.class)) @@ -318,11 +333,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(ReachabilityServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ReachabilityServiceStubSettings.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); @@ -481,6 +515,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 .listConnectivityTestsSettings() diff --git a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceClient.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceClient.java index 7015618994e4..c0ba33f9c830 100644 --- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceClient.java +++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceClient.java @@ -20,6 +20,7 @@ import com.google.api.core.ApiFutures; import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; +import com.google.api.gax.httpjson.longrunning.OperationsClient; import com.google.api.gax.longrunning.OperationFuture; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -31,7 +32,6 @@ import com.google.cloud.networkmanagement.v1beta1.stub.ReachabilityServiceStubSettings; import com.google.common.util.concurrent.MoreExecutors; import com.google.longrunning.Operation; -import com.google.longrunning.OperationsClient; import com.google.protobuf.Empty; import java.io.IOException; import java.util.List; @@ -113,6 +113,21 @@ * ReachabilityServiceClient.create(reachabilityServiceSettings); * } * + *

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.
+ * ReachabilityServiceSettings reachabilityServiceSettings =
+ *     ReachabilityServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             ReachabilityServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * ReachabilityServiceClient reachabilityServiceClient =
+ *     ReachabilityServiceClient.create(reachabilityServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -120,7 +135,8 @@ public class ReachabilityServiceClient implements BackgroundResource { private final ReachabilityServiceSettings settings; private final ReachabilityServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of ReachabilityServiceClient with default settings. */ public static final ReachabilityServiceClient create() throws IOException { @@ -152,13 +168,17 @@ public static final ReachabilityServiceClient create(ReachabilityServiceStub stu protected ReachabilityServiceClient(ReachabilityServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((ReachabilityServiceStubSettings) 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 ReachabilityServiceClient(ReachabilityServiceStub 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 ReachabilityServiceSettings getSettings() { @@ -173,10 +193,19 @@ public ReachabilityServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Lists all Connectivity Tests owned by a project. diff --git a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceSettings.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceSettings.java index e5a47e81a1b0..38bf707ebd28 100644 --- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceSettings.java +++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceSettings.java @@ -23,6 +23,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; @@ -169,11 +170,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return ReachabilityServiceStubSettings.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 ReachabilityServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return ReachabilityServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return ReachabilityServiceStubSettings.defaultTransportChannelProvider(); } @@ -183,11 +191,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return ReachabilityServiceStubSettings.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); @@ -225,6 +239,11 @@ private static Builder createDefault() { return new Builder(ReachabilityServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(ReachabilityServiceStubSettings.newHttpJsonBuilder()); + } + public ReachabilityServiceStubSettings.Builder getStubSettingsBuilder() { return ((ReachabilityServiceStubSettings.Builder) getStubSettings()); } diff --git a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/HttpJsonReachabilityServiceCallableFactory.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/HttpJsonReachabilityServiceCallableFactory.java new file mode 100644 index 000000000000..1b33639031a3 --- /dev/null +++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/HttpJsonReachabilityServiceCallableFactory.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.networkmanagement.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 ReachabilityService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonReachabilityServiceCallableFactory + 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-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/HttpJsonReachabilityServiceStub.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/HttpJsonReachabilityServiceStub.java new file mode 100644 index 000000000000..b38d42a06f06 --- /dev/null +++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/HttpJsonReachabilityServiceStub.java @@ -0,0 +1,592 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.networkmanagement.v1beta1.stub; + +import static com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient.ListConnectivityTestsPagedResponse; + +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.networkmanagement.v1beta1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest; +import com.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsResponse; +import com.google.cloud.networkmanagement.v1beta1.OperationMetadata; +import com.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest; +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 ReachabilityService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonReachabilityServiceStub extends ReachabilityServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(ConnectivityTest.getDescriptor()) + .add(OperationMetadata.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor< + ListConnectivityTestsRequest, ListConnectivityTestsResponse> + listConnectivityTestsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.networkmanagement.v1beta1.ReachabilityService/ListConnectivityTests") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/global}/connectivityTests", + 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(ListConnectivityTestsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getConnectivityTestMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.networkmanagement.v1beta1.ReachabilityService/GetConnectivityTest") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/global/connectivityTests/*}", + 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(ConnectivityTest.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + createConnectivityTestMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.networkmanagement.v1beta1.ReachabilityService/CreateConnectivityTest") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/global}/connectivityTests", + 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, "testId", request.getTestId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("resource", request.getResource())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateConnectivityTestRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateConnectivityTestMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.networkmanagement.v1beta1.ReachabilityService/UpdateConnectivityTest") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{resource.name=projects/*/locations/global/connectivityTests/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "resource.name", request.getResource().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("resource", request.getResource())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateConnectivityTestRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + rerunConnectivityTestMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.networkmanagement.v1beta1.ReachabilityService/RerunConnectivityTest") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/global/connectivityTests/*}:rerun", + 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( + (RerunConnectivityTestRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + deleteConnectivityTestMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.networkmanagement.v1beta1.ReachabilityService/DeleteConnectivityTest") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/global/connectivityTests/*}", + 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( + (DeleteConnectivityTestRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private final UnaryCallable + listConnectivityTestsCallable; + private final UnaryCallable + listConnectivityTestsPagedCallable; + private final UnaryCallable + getConnectivityTestCallable; + private final UnaryCallable + createConnectivityTestCallable; + private final OperationCallable< + CreateConnectivityTestRequest, ConnectivityTest, OperationMetadata> + createConnectivityTestOperationCallable; + private final UnaryCallable + updateConnectivityTestCallable; + private final OperationCallable< + UpdateConnectivityTestRequest, ConnectivityTest, OperationMetadata> + updateConnectivityTestOperationCallable; + private final UnaryCallable + rerunConnectivityTestCallable; + private final OperationCallable + rerunConnectivityTestOperationCallable; + private final UnaryCallable + deleteConnectivityTestCallable; + private final OperationCallable + deleteConnectivityTestOperationCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonReachabilityServiceStub create( + ReachabilityServiceStubSettings settings) throws IOException { + return new HttpJsonReachabilityServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonReachabilityServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonReachabilityServiceStub( + ReachabilityServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonReachabilityServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonReachabilityServiceStub( + ReachabilityServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonReachabilityServiceStub, 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 HttpJsonReachabilityServiceStub( + ReachabilityServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonReachabilityServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonReachabilityServiceStub, 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 HttpJsonReachabilityServiceStub( + ReachabilityServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + listConnectivityTestsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listConnectivityTestsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getConnectivityTestTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getConnectivityTestMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createConnectivityTestTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createConnectivityTestMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateConnectivityTestTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateConnectivityTestMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + rerunConnectivityTestTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(rerunConnectivityTestMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteConnectivityTestTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteConnectivityTestMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listConnectivityTestsCallable = + callableFactory.createUnaryCallable( + listConnectivityTestsTransportSettings, + settings.listConnectivityTestsSettings(), + clientContext); + this.listConnectivityTestsPagedCallable = + callableFactory.createPagedCallable( + listConnectivityTestsTransportSettings, + settings.listConnectivityTestsSettings(), + clientContext); + this.getConnectivityTestCallable = + callableFactory.createUnaryCallable( + getConnectivityTestTransportSettings, + settings.getConnectivityTestSettings(), + clientContext); + this.createConnectivityTestCallable = + callableFactory.createUnaryCallable( + createConnectivityTestTransportSettings, + settings.createConnectivityTestSettings(), + clientContext); + this.createConnectivityTestOperationCallable = + callableFactory.createOperationCallable( + createConnectivityTestTransportSettings, + settings.createConnectivityTestOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateConnectivityTestCallable = + callableFactory.createUnaryCallable( + updateConnectivityTestTransportSettings, + settings.updateConnectivityTestSettings(), + clientContext); + this.updateConnectivityTestOperationCallable = + callableFactory.createOperationCallable( + updateConnectivityTestTransportSettings, + settings.updateConnectivityTestOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.rerunConnectivityTestCallable = + callableFactory.createUnaryCallable( + rerunConnectivityTestTransportSettings, + settings.rerunConnectivityTestSettings(), + clientContext); + this.rerunConnectivityTestOperationCallable = + callableFactory.createOperationCallable( + rerunConnectivityTestTransportSettings, + settings.rerunConnectivityTestOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.deleteConnectivityTestCallable = + callableFactory.createUnaryCallable( + deleteConnectivityTestTransportSettings, + settings.deleteConnectivityTestSettings(), + clientContext); + this.deleteConnectivityTestOperationCallable = + callableFactory.createOperationCallable( + deleteConnectivityTestTransportSettings, + settings.deleteConnectivityTestOperationSettings(), + clientContext, + httpJsonOperationsStub); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listConnectivityTestsMethodDescriptor); + methodDescriptors.add(getConnectivityTestMethodDescriptor); + methodDescriptors.add(createConnectivityTestMethodDescriptor); + methodDescriptors.add(updateConnectivityTestMethodDescriptor); + methodDescriptors.add(rerunConnectivityTestMethodDescriptor); + methodDescriptors.add(deleteConnectivityTestMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + listConnectivityTestsCallable() { + return listConnectivityTestsCallable; + } + + @Override + public UnaryCallable + listConnectivityTestsPagedCallable() { + return listConnectivityTestsPagedCallable; + } + + @Override + public UnaryCallable getConnectivityTestCallable() { + return getConnectivityTestCallable; + } + + @Override + public UnaryCallable createConnectivityTestCallable() { + return createConnectivityTestCallable; + } + + @Override + public OperationCallable + createConnectivityTestOperationCallable() { + return createConnectivityTestOperationCallable; + } + + @Override + public UnaryCallable updateConnectivityTestCallable() { + return updateConnectivityTestCallable; + } + + @Override + public OperationCallable + updateConnectivityTestOperationCallable() { + return updateConnectivityTestOperationCallable; + } + + @Override + public UnaryCallable rerunConnectivityTestCallable() { + return rerunConnectivityTestCallable; + } + + @Override + public OperationCallable + rerunConnectivityTestOperationCallable() { + return rerunConnectivityTestOperationCallable; + } + + @Override + public UnaryCallable deleteConnectivityTestCallable() { + return deleteConnectivityTestCallable; + } + + @Override + public OperationCallable + deleteConnectivityTestOperationCallable() { + return deleteConnectivityTestOperationCallable; + } + + @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-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStub.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStub.java index 1ce8fdbc58bf..1757b51ced66 100644 --- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStub.java +++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStub.java @@ -47,7 +47,11 @@ public abstract class ReachabilityServiceStub 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-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStubSettings.java b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStubSettings.java index da1769f9fd84..97a9c22e9028 100644 --- a/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStubSettings.java +++ b/java-network-management/google-cloud-network-management/src/main/java/com/google/cloud/networkmanagement/v1beta1/stub/ReachabilityServiceStubSettings.java @@ -28,6 +28,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; @@ -268,6 +271,11 @@ public ReachabilityServiceStub createStub() throws IOException { .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcReachabilityServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonReachabilityServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -300,18 +308,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(ReachabilityServiceStubSettings.class)) @@ -319,11 +334,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(ReachabilityServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return ReachabilityServiceStubSettings.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); @@ -482,6 +516,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 .listConnectivityTestsSettings() diff --git a/java-network-management/google-cloud-network-management/src/test/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClientHttpJsonTest.java b/java-network-management/google-cloud-network-management/src/test/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..0a8d6cf918bd --- /dev/null +++ b/java-network-management/google-cloud-network-management/src/test/java/com/google/cloud/networkmanagement/v1/ReachabilityServiceClientHttpJsonTest.java @@ -0,0 +1,457 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.networkmanagement.v1; + +import static com.google.cloud.networkmanagement.v1.ReachabilityServiceClient.ListConnectivityTestsPagedResponse; + +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.networkmanagement.v1.stub.HttpJsonReachabilityServiceStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ReachabilityServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ReachabilityServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonReachabilityServiceStub.getMethodDescriptors(), + ReachabilityServiceSettings.getDefaultEndpoint()); + ReachabilityServiceSettings settings = + ReachabilityServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ReachabilityServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ReachabilityServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listConnectivityTestsTest() throws Exception { + ConnectivityTest responsesElement = ConnectivityTest.newBuilder().build(); + ListConnectivityTestsResponse expectedResponse = + ListConnectivityTestsResponse.newBuilder() + .setNextPageToken("") + .addAllResources(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-6156/locations/global"; + + ListConnectivityTestsPagedResponse pagedListResponse = client.listConnectivityTests(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getResourcesList().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 listConnectivityTestsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6156/locations/global"; + client.listConnectivityTests(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConnectivityTestTest() throws Exception { + ConnectivityTest expectedResponse = + ConnectivityTest.newBuilder() + .setName("name3373707") + .setDescription("description-1724546052") + .setSource(Endpoint.newBuilder().build()) + .setDestination(Endpoint.newBuilder().build()) + .setProtocol("protocol-989163880") + .addAllRelatedProjects(new ArrayList()) + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setReachabilityDetails(ReachabilityDetails.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569"; + + ConnectivityTest actualResponse = client.getConnectivityTest(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 getConnectivityTestExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569"; + client.getConnectivityTest(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConnectivityTestTest() throws Exception { + ConnectivityTest expectedResponse = + ConnectivityTest.newBuilder() + .setName("name3373707") + .setDescription("description-1724546052") + .setSource(Endpoint.newBuilder().build()) + .setDestination(Endpoint.newBuilder().build()) + .setProtocol("protocol-989163880") + .addAllRelatedProjects(new ArrayList()) + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setReachabilityDetails(ReachabilityDetails.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createConnectivityTestTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-6156/locations/global"; + String testId = "testId-877170355"; + ConnectivityTest resource = ConnectivityTest.newBuilder().build(); + + ConnectivityTest actualResponse = + client.createConnectivityTestAsync(parent, testId, resource).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 createConnectivityTestExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-6156/locations/global"; + String testId = "testId-877170355"; + ConnectivityTest resource = ConnectivityTest.newBuilder().build(); + client.createConnectivityTestAsync(parent, testId, resource).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateConnectivityTestTest() throws Exception { + ConnectivityTest expectedResponse = + ConnectivityTest.newBuilder() + .setName("name3373707") + .setDescription("description-1724546052") + .setSource(Endpoint.newBuilder().build()) + .setDestination(Endpoint.newBuilder().build()) + .setProtocol("protocol-989163880") + .addAllRelatedProjects(new ArrayList()) + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setReachabilityDetails(ReachabilityDetails.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateConnectivityTestTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + FieldMask updateMask = FieldMask.newBuilder().build(); + ConnectivityTest resource = + ConnectivityTest.newBuilder() + .setName( + "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569") + .setDescription("description-1724546052") + .setSource(Endpoint.newBuilder().build()) + .setDestination(Endpoint.newBuilder().build()) + .setProtocol("protocol-989163880") + .addAllRelatedProjects(new ArrayList()) + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setReachabilityDetails(ReachabilityDetails.newBuilder().build()) + .build(); + + ConnectivityTest actualResponse = + client.updateConnectivityTestAsync(updateMask, resource).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 updateConnectivityTestExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + FieldMask updateMask = FieldMask.newBuilder().build(); + ConnectivityTest resource = + ConnectivityTest.newBuilder() + .setName( + "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569") + .setDescription("description-1724546052") + .setSource(Endpoint.newBuilder().build()) + .setDestination(Endpoint.newBuilder().build()) + .setProtocol("protocol-989163880") + .addAllRelatedProjects(new ArrayList()) + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setReachabilityDetails(ReachabilityDetails.newBuilder().build()) + .build(); + client.updateConnectivityTestAsync(updateMask, resource).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void rerunConnectivityTestTest() throws Exception { + ConnectivityTest expectedResponse = + ConnectivityTest.newBuilder() + .setName("name3373707") + .setDescription("description-1724546052") + .setSource(Endpoint.newBuilder().build()) + .setDestination(Endpoint.newBuilder().build()) + .setProtocol("protocol-989163880") + .addAllRelatedProjects(new ArrayList()) + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setReachabilityDetails(ReachabilityDetails.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("rerunConnectivityTestTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RerunConnectivityTestRequest request = + RerunConnectivityTestRequest.newBuilder() + .setName( + "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569") + .build(); + + ConnectivityTest actualResponse = client.rerunConnectivityTestAsync(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 rerunConnectivityTestExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RerunConnectivityTestRequest request = + RerunConnectivityTestRequest.newBuilder() + .setName( + "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569") + .build(); + client.rerunConnectivityTestAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteConnectivityTestTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteConnectivityTestTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569"; + + client.deleteConnectivityTestAsync(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 deleteConnectivityTestExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569"; + client.deleteConnectivityTestAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-network-management/google-cloud-network-management/src/test/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceClientHttpJsonTest.java b/java-network-management/google-cloud-network-management/src/test/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceClientHttpJsonTest.java new file mode 100644 index 000000000000..f3f62a3f8e34 --- /dev/null +++ b/java-network-management/google-cloud-network-management/src/test/java/com/google/cloud/networkmanagement/v1beta1/ReachabilityServiceClientHttpJsonTest.java @@ -0,0 +1,501 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.networkmanagement.v1beta1; + +import static com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient.ListConnectivityTestsPagedResponse; + +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.networkmanagement.v1beta1.stub.HttpJsonReachabilityServiceStub; +import com.google.common.collect.Lists; +import com.google.longrunning.Operation; +import com.google.protobuf.Any; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.concurrent.ExecutionException; +import javax.annotation.Generated; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; + +@Generated("by gapic-generator-java") +public class ReachabilityServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static ReachabilityServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonReachabilityServiceStub.getMethodDescriptors(), + ReachabilityServiceSettings.getDefaultEndpoint()); + ReachabilityServiceSettings settings = + ReachabilityServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + ReachabilityServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = ReachabilityServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listConnectivityTestsTest() throws Exception { + ConnectivityTest responsesElement = ConnectivityTest.newBuilder().build(); + ListConnectivityTestsResponse expectedResponse = + ListConnectivityTestsResponse.newBuilder() + .setNextPageToken("") + .addAllResources(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ListConnectivityTestsRequest request = + ListConnectivityTestsRequest.newBuilder() + .setParent("projects/project-6156/locations/global") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + + ListConnectivityTestsPagedResponse pagedListResponse = client.listConnectivityTests(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getResourcesList().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 listConnectivityTestsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ListConnectivityTestsRequest request = + ListConnectivityTestsRequest.newBuilder() + .setParent("projects/project-6156/locations/global") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + client.listConnectivityTests(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getConnectivityTestTest() throws Exception { + ConnectivityTest expectedResponse = + ConnectivityTest.newBuilder() + .setName("name3373707") + .setDescription("description-1724546052") + .setSource(Endpoint.newBuilder().build()) + .setDestination(Endpoint.newBuilder().build()) + .setProtocol("protocol-989163880") + .addAllRelatedProjects(new ArrayList()) + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setReachabilityDetails(ReachabilityDetails.newBuilder().build()) + .setProbingDetails(ProbingDetails.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + GetConnectivityTestRequest request = + GetConnectivityTestRequest.newBuilder() + .setName( + "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569") + .build(); + + ConnectivityTest actualResponse = client.getConnectivityTest(request); + 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 getConnectivityTestExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GetConnectivityTestRequest request = + GetConnectivityTestRequest.newBuilder() + .setName( + "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569") + .build(); + client.getConnectivityTest(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createConnectivityTestTest() throws Exception { + ConnectivityTest expectedResponse = + ConnectivityTest.newBuilder() + .setName("name3373707") + .setDescription("description-1724546052") + .setSource(Endpoint.newBuilder().build()) + .setDestination(Endpoint.newBuilder().build()) + .setProtocol("protocol-989163880") + .addAllRelatedProjects(new ArrayList()) + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setReachabilityDetails(ReachabilityDetails.newBuilder().build()) + .setProbingDetails(ProbingDetails.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createConnectivityTestTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + CreateConnectivityTestRequest request = + CreateConnectivityTestRequest.newBuilder() + .setParent("projects/project-6156/locations/global") + .setTestId("testId-877170355") + .setResource(ConnectivityTest.newBuilder().build()) + .build(); + + ConnectivityTest actualResponse = client.createConnectivityTestAsync(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 createConnectivityTestExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + CreateConnectivityTestRequest request = + CreateConnectivityTestRequest.newBuilder() + .setParent("projects/project-6156/locations/global") + .setTestId("testId-877170355") + .setResource(ConnectivityTest.newBuilder().build()) + .build(); + client.createConnectivityTestAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateConnectivityTestTest() throws Exception { + ConnectivityTest expectedResponse = + ConnectivityTest.newBuilder() + .setName("name3373707") + .setDescription("description-1724546052") + .setSource(Endpoint.newBuilder().build()) + .setDestination(Endpoint.newBuilder().build()) + .setProtocol("protocol-989163880") + .addAllRelatedProjects(new ArrayList()) + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setReachabilityDetails(ReachabilityDetails.newBuilder().build()) + .setProbingDetails(ProbingDetails.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateConnectivityTestTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + UpdateConnectivityTestRequest request = + UpdateConnectivityTestRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setResource( + ConnectivityTest.newBuilder() + .setName( + "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569") + .setDescription("description-1724546052") + .setSource(Endpoint.newBuilder().build()) + .setDestination(Endpoint.newBuilder().build()) + .setProtocol("protocol-989163880") + .addAllRelatedProjects(new ArrayList()) + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setReachabilityDetails(ReachabilityDetails.newBuilder().build()) + .setProbingDetails(ProbingDetails.newBuilder().build()) + .build()) + .build(); + + ConnectivityTest actualResponse = client.updateConnectivityTestAsync(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 updateConnectivityTestExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + UpdateConnectivityTestRequest request = + UpdateConnectivityTestRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setResource( + ConnectivityTest.newBuilder() + .setName( + "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569") + .setDescription("description-1724546052") + .setSource(Endpoint.newBuilder().build()) + .setDestination(Endpoint.newBuilder().build()) + .setProtocol("protocol-989163880") + .addAllRelatedProjects(new ArrayList()) + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setReachabilityDetails(ReachabilityDetails.newBuilder().build()) + .setProbingDetails(ProbingDetails.newBuilder().build()) + .build()) + .build(); + client.updateConnectivityTestAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void rerunConnectivityTestTest() throws Exception { + ConnectivityTest expectedResponse = + ConnectivityTest.newBuilder() + .setName("name3373707") + .setDescription("description-1724546052") + .setSource(Endpoint.newBuilder().build()) + .setDestination(Endpoint.newBuilder().build()) + .setProtocol("protocol-989163880") + .addAllRelatedProjects(new ArrayList()) + .setDisplayName("displayName1714148973") + .putAllLabels(new HashMap()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setReachabilityDetails(ReachabilityDetails.newBuilder().build()) + .setProbingDetails(ProbingDetails.newBuilder().build()) + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("rerunConnectivityTestTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + RerunConnectivityTestRequest request = + RerunConnectivityTestRequest.newBuilder() + .setName( + "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569") + .build(); + + ConnectivityTest actualResponse = client.rerunConnectivityTestAsync(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 rerunConnectivityTestExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + RerunConnectivityTestRequest request = + RerunConnectivityTestRequest.newBuilder() + .setName( + "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569") + .build(); + client.rerunConnectivityTestAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteConnectivityTestTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteConnectivityTestTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + DeleteConnectivityTestRequest request = + DeleteConnectivityTestRequest.newBuilder() + .setName( + "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569") + .build(); + + client.deleteConnectivityTestAsync(request).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 deleteConnectivityTestExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + DeleteConnectivityTestRequest request = + DeleteConnectivityTestRequest.newBuilder() + .setName( + "projects/project-4569/locations/global/connectivityTests/connectivityTest-4569") + .build(); + client.deleteConnectivityTestAsync(request).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } +} diff --git a/java-network-management/proto-google-cloud-network-management-v1/src/main/java/com/google/cloud/networkmanagement/v1/AbortInfo.java b/java-network-management/proto-google-cloud-network-management-v1/src/main/java/com/google/cloud/networkmanagement/v1/AbortInfo.java index e7b6491e7aaf..eb95b6d9af4f 100644 --- a/java-network-management/proto-google-cloud-network-management-v1/src/main/java/com/google/cloud/networkmanagement/v1/AbortInfo.java +++ b/java-network-management/proto-google-cloud-network-management-v1/src/main/java/com/google/cloud/networkmanagement/v1/AbortInfo.java @@ -40,6 +40,7 @@ private AbortInfo(com.google.protobuf.GeneratedMessageV3.Builder builder) { private AbortInfo() { cause_ = 0; resourceUri_ = ""; + projectsMissingPermission_ = com.google.protobuf.LazyStringArrayList.EMPTY; } @java.lang.Override @@ -61,6 +62,7 @@ private AbortInfo( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } + int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -85,6 +87,16 @@ private AbortInfo( resourceUri_ = s; break; } + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + projectsMissingPermission_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + projectsMissingPermission_.add(s); + break; + } default: { if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { @@ -101,6 +113,9 @@ private AbortInfo( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + projectsMissingPermission_ = projectsMissingPermission_.getUnmodifiableView(); + } this.unknownFields = unknownFields.build(); makeExtensionsImmutable(); } @@ -659,6 +674,75 @@ public com.google.protobuf.ByteString getResourceUriBytes() { } } + public static final int PROJECTS_MISSING_PERMISSION_FIELD_NUMBER = 3; + private com.google.protobuf.LazyStringList projectsMissingPermission_; + /** + * + * + *

+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @return A list containing the projectsMissingPermission. + */ + public com.google.protobuf.ProtocolStringList getProjectsMissingPermissionList() { + return projectsMissingPermission_; + } + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @return The count of projectsMissingPermission. + */ + public int getProjectsMissingPermissionCount() { + return projectsMissingPermission_.size(); + } + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param index The index of the element to return. + * @return The projectsMissingPermission at the given index. + */ + public java.lang.String getProjectsMissingPermission(int index) { + return projectsMissingPermission_.get(index); + } + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param index The index of the value to return. + * @return The bytes of the projectsMissingPermission at the given index. + */ + public com.google.protobuf.ByteString getProjectsMissingPermissionBytes(int index) { + return projectsMissingPermission_.getByteString(index); + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -680,6 +764,10 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(resourceUri_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 2, resourceUri_); } + for (int i = 0; i < projectsMissingPermission_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString( + output, 3, projectsMissingPermission_.getRaw(i)); + } unknownFields.writeTo(output); } @@ -696,6 +784,14 @@ public int getSerializedSize() { if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(resourceUri_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, resourceUri_); } + { + int dataSize = 0; + for (int i = 0; i < projectsMissingPermission_.size(); i++) { + dataSize += computeStringSizeNoTag(projectsMissingPermission_.getRaw(i)); + } + size += dataSize; + size += 1 * getProjectsMissingPermissionList().size(); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -714,6 +810,8 @@ public boolean equals(final java.lang.Object obj) { if (cause_ != other.cause_) return false; if (!getResourceUri().equals(other.getResourceUri())) return false; + if (!getProjectsMissingPermissionList().equals(other.getProjectsMissingPermissionList())) + return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -729,6 +827,10 @@ public int hashCode() { hash = (53 * hash) + cause_; hash = (37 * hash) + RESOURCE_URI_FIELD_NUMBER; hash = (53 * hash) + getResourceUri().hashCode(); + if (getProjectsMissingPermissionCount() > 0) { + hash = (37 * hash) + PROJECTS_MISSING_PERMISSION_FIELD_NUMBER; + hash = (53 * hash) + getProjectsMissingPermissionList().hashCode(); + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -878,6 +980,8 @@ public Builder clear() { resourceUri_ = ""; + projectsMissingPermission_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); return this; } @@ -905,8 +1009,14 @@ public com.google.cloud.networkmanagement.v1.AbortInfo build() { public com.google.cloud.networkmanagement.v1.AbortInfo buildPartial() { com.google.cloud.networkmanagement.v1.AbortInfo result = new com.google.cloud.networkmanagement.v1.AbortInfo(this); + int from_bitField0_ = bitField0_; result.cause_ = cause_; result.resourceUri_ = resourceUri_; + if (((bitField0_ & 0x00000001) != 0)) { + projectsMissingPermission_ = projectsMissingPermission_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.projectsMissingPermission_ = projectsMissingPermission_; onBuilt(); return result; } @@ -964,6 +1074,16 @@ public Builder mergeFrom(com.google.cloud.networkmanagement.v1.AbortInfo other) resourceUri_ = other.resourceUri_; onChanged(); } + if (!other.projectsMissingPermission_.isEmpty()) { + if (projectsMissingPermission_.isEmpty()) { + projectsMissingPermission_ = other.projectsMissingPermission_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureProjectsMissingPermissionIsMutable(); + projectsMissingPermission_.addAll(other.projectsMissingPermission_); + } + onChanged(); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -993,6 +1113,8 @@ public Builder mergeFrom( return this; } + private int bitField0_; + private int cause_ = 0; /** * @@ -1192,6 +1314,193 @@ public Builder setResourceUriBytes(com.google.protobuf.ByteString value) { return this; } + private com.google.protobuf.LazyStringList projectsMissingPermission_ = + com.google.protobuf.LazyStringArrayList.EMPTY; + + private void ensureProjectsMissingPermissionIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + projectsMissingPermission_ = + new com.google.protobuf.LazyStringArrayList(projectsMissingPermission_); + bitField0_ |= 0x00000001; + } + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @return A list containing the projectsMissingPermission. + */ + public com.google.protobuf.ProtocolStringList getProjectsMissingPermissionList() { + return projectsMissingPermission_.getUnmodifiableView(); + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @return The count of projectsMissingPermission. + */ + public int getProjectsMissingPermissionCount() { + return projectsMissingPermission_.size(); + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param index The index of the element to return. + * @return The projectsMissingPermission at the given index. + */ + public java.lang.String getProjectsMissingPermission(int index) { + return projectsMissingPermission_.get(index); + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param index The index of the value to return. + * @return The bytes of the projectsMissingPermission at the given index. + */ + public com.google.protobuf.ByteString getProjectsMissingPermissionBytes(int index) { + return projectsMissingPermission_.getByteString(index); + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param index The index to set the value at. + * @param value The projectsMissingPermission to set. + * @return This builder for chaining. + */ + public Builder setProjectsMissingPermission(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureProjectsMissingPermissionIsMutable(); + projectsMissingPermission_.set(index, value); + onChanged(); + return this; + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param value The projectsMissingPermission to add. + * @return This builder for chaining. + */ + public Builder addProjectsMissingPermission(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureProjectsMissingPermissionIsMutable(); + projectsMissingPermission_.add(value); + onChanged(); + return this; + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param values The projectsMissingPermission to add. + * @return This builder for chaining. + */ + public Builder addAllProjectsMissingPermission(java.lang.Iterable values) { + ensureProjectsMissingPermissionIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, projectsMissingPermission_); + onChanged(); + return this; + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @return This builder for chaining. + */ + public Builder clearProjectsMissingPermission() { + projectsMissingPermission_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param value The bytes of the projectsMissingPermission to add. + * @return This builder for chaining. + */ + public Builder addProjectsMissingPermissionBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureProjectsMissingPermissionIsMutable(); + projectsMissingPermission_.add(value); + onChanged(); + return this; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/java-network-management/proto-google-cloud-network-management-v1/src/main/java/com/google/cloud/networkmanagement/v1/AbortInfoOrBuilder.java b/java-network-management/proto-google-cloud-network-management-v1/src/main/java/com/google/cloud/networkmanagement/v1/AbortInfoOrBuilder.java index 86df8d5a23e3..9c3c6469e585 100644 --- a/java-network-management/proto-google-cloud-network-management-v1/src/main/java/com/google/cloud/networkmanagement/v1/AbortInfoOrBuilder.java +++ b/java-network-management/proto-google-cloud-network-management-v1/src/main/java/com/google/cloud/networkmanagement/v1/AbortInfoOrBuilder.java @@ -72,4 +72,63 @@ public interface AbortInfoOrBuilder * @return The bytes for resourceUri. */ com.google.protobuf.ByteString getResourceUriBytes(); + + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @return A list containing the projectsMissingPermission. + */ + java.util.List getProjectsMissingPermissionList(); + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @return The count of projectsMissingPermission. + */ + int getProjectsMissingPermissionCount(); + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param index The index of the element to return. + * @return The projectsMissingPermission at the given index. + */ + java.lang.String getProjectsMissingPermission(int index); + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param index The index of the value to return. + * @return The bytes of the projectsMissingPermission at the given index. + */ + com.google.protobuf.ByteString getProjectsMissingPermissionBytes(int index); } diff --git a/java-network-management/proto-google-cloud-network-management-v1/src/main/java/com/google/cloud/networkmanagement/v1/TraceProto.java b/java-network-management/proto-google-cloud-network-management-v1/src/main/java/com/google/cloud/networkmanagement/v1/TraceProto.java index b9f8496196d1..42c4067d4c29 100644 --- a/java-network-management/proto-google-cloud-network-management-v1/src/main/java/com/google/cloud/networkmanagement/v1/TraceProto.java +++ b/java-network-management/proto-google-cloud-network-management-v1/src/main/java/com/google/cloud/networkmanagement/v1/TraceProto.java @@ -250,52 +250,53 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "t\022\026\n\022TARGET_UNSPECIFIED\020\000\022\017\n\013PEERING_VPC" + "\020\001\022\017\n\013VPN_GATEWAY\020\002\022\020\n\014INTERCONNECT\020\003\022\016\n" + "\nGKE_MASTER\020\004\022\"\n\036IMPORTED_CUSTOM_ROUTE_N" - + "EXT_HOP\020\005\022\026\n\022CLOUD_SQL_INSTANCE\020\006\"\342\003\n\tAb" + + "EXT_HOP\020\005\022\026\n\022CLOUD_SQL_INSTANCE\020\006\"\207\004\n\tAb" + "ortInfo\022A\n\005cause\030\001 \001(\01622.google.cloud.ne" + "tworkmanagement.v1.AbortInfo.Cause\022\024\n\014re" - + "source_uri\030\002 \001(\t\"\373\002\n\005Cause\022\025\n\021CAUSE_UNSP" - + "ECIFIED\020\000\022\023\n\017UNKNOWN_NETWORK\020\001\022\016\n\nUNKNOW" - + "N_IP\020\002\022\023\n\017UNKNOWN_PROJECT\020\003\022\025\n\021PERMISSIO" - + "N_DENIED\020\004\022\026\n\022NO_SOURCE_LOCATION\020\005\022\024\n\020IN" - + "VALID_ARGUMENT\020\006\022\022\n\016NO_EXTERNAL_IP\020\007\022\032\n\026" - + "UNINTENDED_DESTINATION\020\010\022\022\n\016TRACE_TOO_LO" - + "NG\020\t\022\022\n\016INTERNAL_ERROR\020\n\022\035\n\031SOURCE_ENDPO" - + "INT_NOT_FOUND\020\013\022\035\n\031MISMATCHED_SOURCE_NET" - + "WORK\020\014\022\"\n\036DESTINATION_ENDPOINT_NOT_FOUND" - + "\020\r\022\"\n\036MISMATCHED_DESTINATION_NETWORK\020\016\"\232" - + "\006\n\010DropInfo\022@\n\005cause\030\001 \001(\01621.google.clou" - + "d.networkmanagement.v1.DropInfo.Cause\022\024\n" - + "\014resource_uri\030\002 \001(\t\"\265\005\n\005Cause\022\025\n\021CAUSE_U" - + "NSPECIFIED\020\000\022\034\n\030UNKNOWN_EXTERNAL_ADDRESS" - + "\020\001\022\031\n\025FOREIGN_IP_DISALLOWED\020\002\022\021\n\rFIREWAL" - + "L_RULE\020\003\022\014\n\010NO_ROUTE\020\004\022\023\n\017ROUTE_BLACKHOL" - + "E\020\005\022\027\n\023ROUTE_WRONG_NETWORK\020\006\022\037\n\033PRIVATE_" - + "TRAFFIC_TO_INTERNET\020\007\022$\n PRIVATE_GOOGLE_" - + "ACCESS_DISALLOWED\020\010\022\027\n\023NO_EXTERNAL_ADDRE" - + "SS\020\t\022\034\n\030UNKNOWN_INTERNAL_ADDRESS\020\n\022\034\n\030FO" - + "RWARDING_RULE_MISMATCH\020\013\022 \n\034FORWARDING_R" - + "ULE_NO_INSTANCES\020\014\0228\n4FIREWALL_BLOCKING_" - + "LOAD_BALANCER_BACKEND_HEALTH_CHECK\020\r\022\030\n\024" - + "INSTANCE_NOT_RUNNING\020\016\022\030\n\024TRAFFIC_TYPE_B" - + "LOCKED\020\017\022\"\n\036GKE_MASTER_UNAUTHORIZED_ACCE" - + "SS\020\020\022*\n&CLOUD_SQL_INSTANCE_UNAUTHORIZED_" - + "ACCESS\020\021\022\036\n\032DROPPED_INSIDE_GKE_SERVICE\020\022" - + "\022$\n DROPPED_INSIDE_CLOUD_SQL_SERVICE\020\023\022%" - + "\n!GOOGLE_MANAGED_SERVICE_NO_PEERING\020\024\022$\n" - + " CLOUD_SQL_INSTANCE_NO_IP_ADDRESS\020\025\"k\n\rG" - + "KEMasterInfo\022\023\n\013cluster_uri\030\002 \001(\t\022\033\n\023clu" - + "ster_network_uri\030\004 \001(\t\022\023\n\013internal_ip\030\005 " - + "\001(\t\022\023\n\013external_ip\030\006 \001(\t\"\210\001\n\024CloudSQLIns" - + "tanceInfo\022\024\n\014display_name\030\001 \001(\t\022\013\n\003uri\030\002" - + " \001(\t\022\023\n\013network_uri\030\004 \001(\t\022\023\n\013internal_ip" - + "\030\005 \001(\t\022\023\n\013external_ip\030\006 \001(\t\022\016\n\006region\030\007 " - + "\001(\tB\370\001\n%com.google.cloud.networkmanageme" - + "nt.v1B\nTraceProtoP\001ZRgoogle.golang.org/g" - + "enproto/googleapis/cloud/networkmanageme" - + "nt/v1;networkmanagement\252\002!Google.Cloud.N" - + "etworkManagement.V1\312\002!Google\\Cloud\\Netwo" - + "rkManagement\\V1\352\002$Google::Cloud::Network" - + "Management::V1b\006proto3" + + "source_uri\030\002 \001(\t\022#\n\033projects_missing_per" + + "mission\030\003 \003(\t\"\373\002\n\005Cause\022\025\n\021CAUSE_UNSPECI" + + "FIED\020\000\022\023\n\017UNKNOWN_NETWORK\020\001\022\016\n\nUNKNOWN_I" + + "P\020\002\022\023\n\017UNKNOWN_PROJECT\020\003\022\025\n\021PERMISSION_D" + + "ENIED\020\004\022\026\n\022NO_SOURCE_LOCATION\020\005\022\024\n\020INVAL" + + "ID_ARGUMENT\020\006\022\022\n\016NO_EXTERNAL_IP\020\007\022\032\n\026UNI" + + "NTENDED_DESTINATION\020\010\022\022\n\016TRACE_TOO_LONG\020" + + "\t\022\022\n\016INTERNAL_ERROR\020\n\022\035\n\031SOURCE_ENDPOINT" + + "_NOT_FOUND\020\013\022\035\n\031MISMATCHED_SOURCE_NETWOR" + + "K\020\014\022\"\n\036DESTINATION_ENDPOINT_NOT_FOUND\020\r\022" + + "\"\n\036MISMATCHED_DESTINATION_NETWORK\020\016\"\232\006\n\010" + + "DropInfo\022@\n\005cause\030\001 \001(\01621.google.cloud.n" + + "etworkmanagement.v1.DropInfo.Cause\022\024\n\014re" + + "source_uri\030\002 \001(\t\"\265\005\n\005Cause\022\025\n\021CAUSE_UNSP" + + "ECIFIED\020\000\022\034\n\030UNKNOWN_EXTERNAL_ADDRESS\020\001\022" + + "\031\n\025FOREIGN_IP_DISALLOWED\020\002\022\021\n\rFIREWALL_R" + + "ULE\020\003\022\014\n\010NO_ROUTE\020\004\022\023\n\017ROUTE_BLACKHOLE\020\005" + + "\022\027\n\023ROUTE_WRONG_NETWORK\020\006\022\037\n\033PRIVATE_TRA" + + "FFIC_TO_INTERNET\020\007\022$\n PRIVATE_GOOGLE_ACC" + + "ESS_DISALLOWED\020\010\022\027\n\023NO_EXTERNAL_ADDRESS\020" + + "\t\022\034\n\030UNKNOWN_INTERNAL_ADDRESS\020\n\022\034\n\030FORWA" + + "RDING_RULE_MISMATCH\020\013\022 \n\034FORWARDING_RULE" + + "_NO_INSTANCES\020\014\0228\n4FIREWALL_BLOCKING_LOA" + + "D_BALANCER_BACKEND_HEALTH_CHECK\020\r\022\030\n\024INS" + + "TANCE_NOT_RUNNING\020\016\022\030\n\024TRAFFIC_TYPE_BLOC" + + "KED\020\017\022\"\n\036GKE_MASTER_UNAUTHORIZED_ACCESS\020" + + "\020\022*\n&CLOUD_SQL_INSTANCE_UNAUTHORIZED_ACC" + + "ESS\020\021\022\036\n\032DROPPED_INSIDE_GKE_SERVICE\020\022\022$\n" + + " DROPPED_INSIDE_CLOUD_SQL_SERVICE\020\023\022%\n!G" + + "OOGLE_MANAGED_SERVICE_NO_PEERING\020\024\022$\n CL" + + "OUD_SQL_INSTANCE_NO_IP_ADDRESS\020\025\"k\n\rGKEM" + + "asterInfo\022\023\n\013cluster_uri\030\002 \001(\t\022\033\n\023cluste" + + "r_network_uri\030\004 \001(\t\022\023\n\013internal_ip\030\005 \001(\t" + + "\022\023\n\013external_ip\030\006 \001(\t\"\210\001\n\024CloudSQLInstan" + + "ceInfo\022\024\n\014display_name\030\001 \001(\t\022\013\n\003uri\030\002 \001(" + + "\t\022\023\n\013network_uri\030\004 \001(\t\022\023\n\013internal_ip\030\005 " + + "\001(\t\022\023\n\013external_ip\030\006 \001(\t\022\016\n\006region\030\007 \001(\t" + + "B\370\001\n%com.google.cloud.networkmanagement." + + "v1B\nTraceProtoP\001ZRgoogle.golang.org/genp" + + "roto/googleapis/cloud/networkmanagement/" + + "v1;networkmanagement\252\002!Google.Cloud.Netw" + + "orkManagement.V1\312\002!Google\\Cloud\\NetworkM" + + "anagement\\V1\352\002$Google::Cloud::NetworkMan" + + "agement::V1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -485,7 +486,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_cloud_networkmanagement_v1_AbortInfo_descriptor, new java.lang.String[] { - "Cause", "ResourceUri", + "Cause", "ResourceUri", "ProjectsMissingPermission", }); internal_static_google_cloud_networkmanagement_v1_DropInfo_descriptor = getDescriptor().getMessageTypes().get(15); diff --git a/java-network-management/proto-google-cloud-network-management-v1/src/main/proto/google/cloud/networkmanagement/v1/trace.proto b/java-network-management/proto-google-cloud-network-management-v1/src/main/proto/google/cloud/networkmanagement/v1/trace.proto index 68ab41a986a0..c34a328dccad 100644 --- a/java-network-management/proto-google-cloud-network-management-v1/src/main/proto/google/cloud/networkmanagement/v1/trace.proto +++ b/java-network-management/proto-google-cloud-network-management-v1/src/main/proto/google/cloud/networkmanagement/v1/trace.proto @@ -741,6 +741,11 @@ message AbortInfo { // URI of the resource that caused the abort. string resource_uri = 2; + + // List of project IDs that the user has specified in the request but does + // not have permission to access network configs. Analysis is aborted in this + // case with the PERMISSION_DENIED cause. + repeated string projects_missing_permission = 3; } // Details of the final state "drop" and associated resource. diff --git a/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/java/com/google/cloud/networkmanagement/v1beta1/AbortInfo.java b/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/java/com/google/cloud/networkmanagement/v1beta1/AbortInfo.java index 214fab5ddfad..b48f7d4c5bf6 100644 --- a/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/java/com/google/cloud/networkmanagement/v1beta1/AbortInfo.java +++ b/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/java/com/google/cloud/networkmanagement/v1beta1/AbortInfo.java @@ -40,6 +40,7 @@ private AbortInfo(com.google.protobuf.GeneratedMessageV3.Builder builder) { private AbortInfo() { cause_ = 0; resourceUri_ = ""; + projectsMissingPermission_ = com.google.protobuf.LazyStringArrayList.EMPTY; } @java.lang.Override @@ -61,6 +62,7 @@ private AbortInfo( if (extensionRegistry == null) { throw new java.lang.NullPointerException(); } + int mutable_bitField0_ = 0; com.google.protobuf.UnknownFieldSet.Builder unknownFields = com.google.protobuf.UnknownFieldSet.newBuilder(); try { @@ -85,6 +87,16 @@ private AbortInfo( resourceUri_ = s; break; } + case 26: + { + java.lang.String s = input.readStringRequireUtf8(); + if (!((mutable_bitField0_ & 0x00000001) != 0)) { + projectsMissingPermission_ = new com.google.protobuf.LazyStringArrayList(); + mutable_bitField0_ |= 0x00000001; + } + projectsMissingPermission_.add(s); + break; + } default: { if (!parseUnknownField(input, unknownFields, extensionRegistry, tag)) { @@ -101,6 +113,9 @@ private AbortInfo( } catch (java.io.IOException e) { throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(this); } finally { + if (((mutable_bitField0_ & 0x00000001) != 0)) { + projectsMissingPermission_ = projectsMissingPermission_.getUnmodifiableView(); + } this.unknownFields = unknownFields.build(); makeExtensionsImmutable(); } @@ -661,6 +676,75 @@ public com.google.protobuf.ByteString getResourceUriBytes() { } } + public static final int PROJECTS_MISSING_PERMISSION_FIELD_NUMBER = 3; + private com.google.protobuf.LazyStringList projectsMissingPermission_; + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @return A list containing the projectsMissingPermission. + */ + public com.google.protobuf.ProtocolStringList getProjectsMissingPermissionList() { + return projectsMissingPermission_; + } + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @return The count of projectsMissingPermission. + */ + public int getProjectsMissingPermissionCount() { + return projectsMissingPermission_.size(); + } + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param index The index of the element to return. + * @return The projectsMissingPermission at the given index. + */ + public java.lang.String getProjectsMissingPermission(int index) { + return projectsMissingPermission_.get(index); + } + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param index The index of the value to return. + * @return The bytes of the projectsMissingPermission at the given index. + */ + public com.google.protobuf.ByteString getProjectsMissingPermissionBytes(int index) { + return projectsMissingPermission_.getByteString(index); + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -683,6 +767,10 @@ public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(resourceUri_)) { com.google.protobuf.GeneratedMessageV3.writeString(output, 2, resourceUri_); } + for (int i = 0; i < projectsMissingPermission_.size(); i++) { + com.google.protobuf.GeneratedMessageV3.writeString( + output, 3, projectsMissingPermission_.getRaw(i)); + } unknownFields.writeTo(output); } @@ -700,6 +788,14 @@ public int getSerializedSize() { if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(resourceUri_)) { size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, resourceUri_); } + { + int dataSize = 0; + for (int i = 0; i < projectsMissingPermission_.size(); i++) { + dataSize += computeStringSizeNoTag(projectsMissingPermission_.getRaw(i)); + } + size += dataSize; + size += 1 * getProjectsMissingPermissionList().size(); + } size += unknownFields.getSerializedSize(); memoizedSize = size; return size; @@ -718,6 +814,8 @@ public boolean equals(final java.lang.Object obj) { if (cause_ != other.cause_) return false; if (!getResourceUri().equals(other.getResourceUri())) return false; + if (!getProjectsMissingPermissionList().equals(other.getProjectsMissingPermissionList())) + return false; if (!unknownFields.equals(other.unknownFields)) return false; return true; } @@ -733,6 +831,10 @@ public int hashCode() { hash = (53 * hash) + cause_; hash = (37 * hash) + RESOURCE_URI_FIELD_NUMBER; hash = (53 * hash) + getResourceUri().hashCode(); + if (getProjectsMissingPermissionCount() > 0) { + hash = (37 * hash) + PROJECTS_MISSING_PERMISSION_FIELD_NUMBER; + hash = (53 * hash) + getProjectsMissingPermissionList().hashCode(); + } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; @@ -882,6 +984,8 @@ public Builder clear() { resourceUri_ = ""; + projectsMissingPermission_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); return this; } @@ -909,8 +1013,14 @@ public com.google.cloud.networkmanagement.v1beta1.AbortInfo build() { public com.google.cloud.networkmanagement.v1beta1.AbortInfo buildPartial() { com.google.cloud.networkmanagement.v1beta1.AbortInfo result = new com.google.cloud.networkmanagement.v1beta1.AbortInfo(this); + int from_bitField0_ = bitField0_; result.cause_ = cause_; result.resourceUri_ = resourceUri_; + if (((bitField0_ & 0x00000001) != 0)) { + projectsMissingPermission_ = projectsMissingPermission_.getUnmodifiableView(); + bitField0_ = (bitField0_ & ~0x00000001); + } + result.projectsMissingPermission_ = projectsMissingPermission_; onBuilt(); return result; } @@ -968,6 +1078,16 @@ public Builder mergeFrom(com.google.cloud.networkmanagement.v1beta1.AbortInfo ot resourceUri_ = other.resourceUri_; onChanged(); } + if (!other.projectsMissingPermission_.isEmpty()) { + if (projectsMissingPermission_.isEmpty()) { + projectsMissingPermission_ = other.projectsMissingPermission_; + bitField0_ = (bitField0_ & ~0x00000001); + } else { + ensureProjectsMissingPermissionIsMutable(); + projectsMissingPermission_.addAll(other.projectsMissingPermission_); + } + onChanged(); + } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; @@ -998,6 +1118,8 @@ public Builder mergeFrom( return this; } + private int bitField0_; + private int cause_ = 0; /** * @@ -1197,6 +1319,193 @@ public Builder setResourceUriBytes(com.google.protobuf.ByteString value) { return this; } + private com.google.protobuf.LazyStringList projectsMissingPermission_ = + com.google.protobuf.LazyStringArrayList.EMPTY; + + private void ensureProjectsMissingPermissionIsMutable() { + if (!((bitField0_ & 0x00000001) != 0)) { + projectsMissingPermission_ = + new com.google.protobuf.LazyStringArrayList(projectsMissingPermission_); + bitField0_ |= 0x00000001; + } + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @return A list containing the projectsMissingPermission. + */ + public com.google.protobuf.ProtocolStringList getProjectsMissingPermissionList() { + return projectsMissingPermission_.getUnmodifiableView(); + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @return The count of projectsMissingPermission. + */ + public int getProjectsMissingPermissionCount() { + return projectsMissingPermission_.size(); + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param index The index of the element to return. + * @return The projectsMissingPermission at the given index. + */ + public java.lang.String getProjectsMissingPermission(int index) { + return projectsMissingPermission_.get(index); + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param index The index of the value to return. + * @return The bytes of the projectsMissingPermission at the given index. + */ + public com.google.protobuf.ByteString getProjectsMissingPermissionBytes(int index) { + return projectsMissingPermission_.getByteString(index); + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param index The index to set the value at. + * @param value The projectsMissingPermission to set. + * @return This builder for chaining. + */ + public Builder setProjectsMissingPermission(int index, java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureProjectsMissingPermissionIsMutable(); + projectsMissingPermission_.set(index, value); + onChanged(); + return this; + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param value The projectsMissingPermission to add. + * @return This builder for chaining. + */ + public Builder addProjectsMissingPermission(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + ensureProjectsMissingPermissionIsMutable(); + projectsMissingPermission_.add(value); + onChanged(); + return this; + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param values The projectsMissingPermission to add. + * @return This builder for chaining. + */ + public Builder addAllProjectsMissingPermission(java.lang.Iterable values) { + ensureProjectsMissingPermissionIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, projectsMissingPermission_); + onChanged(); + return this; + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @return This builder for chaining. + */ + public Builder clearProjectsMissingPermission() { + projectsMissingPermission_ = com.google.protobuf.LazyStringArrayList.EMPTY; + bitField0_ = (bitField0_ & ~0x00000001); + onChanged(); + return this; + } + /** + * + * + *
+     * List of project IDs that the user has specified in the request but does
+     * not have permission to access network configs. Analysis is aborted in this
+     * case with the PERMISSION_DENIED cause.
+     * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param value The bytes of the projectsMissingPermission to add. + * @return This builder for chaining. + */ + public Builder addProjectsMissingPermissionBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + ensureProjectsMissingPermissionIsMutable(); + projectsMissingPermission_.add(value); + onChanged(); + return this; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); diff --git a/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/java/com/google/cloud/networkmanagement/v1beta1/AbortInfoOrBuilder.java b/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/java/com/google/cloud/networkmanagement/v1beta1/AbortInfoOrBuilder.java index bd3a419097fd..2b5e89da837c 100644 --- a/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/java/com/google/cloud/networkmanagement/v1beta1/AbortInfoOrBuilder.java +++ b/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/java/com/google/cloud/networkmanagement/v1beta1/AbortInfoOrBuilder.java @@ -72,4 +72,63 @@ public interface AbortInfoOrBuilder * @return The bytes for resourceUri. */ com.google.protobuf.ByteString getResourceUriBytes(); + + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @return A list containing the projectsMissingPermission. + */ + java.util.List getProjectsMissingPermissionList(); + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @return The count of projectsMissingPermission. + */ + int getProjectsMissingPermissionCount(); + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param index The index of the element to return. + * @return The projectsMissingPermission at the given index. + */ + java.lang.String getProjectsMissingPermission(int index); + /** + * + * + *
+   * List of project IDs that the user has specified in the request but does
+   * not have permission to access network configs. Analysis is aborted in this
+   * case with the PERMISSION_DENIED cause.
+   * 
+ * + * repeated string projects_missing_permission = 3; + * + * @param index The index of the value to return. + * @return The bytes of the projectsMissingPermission at the given index. + */ + com.google.protobuf.ByteString getProjectsMissingPermissionBytes(int index); } diff --git a/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/java/com/google/cloud/networkmanagement/v1beta1/TraceProto.java b/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/java/com/google/cloud/networkmanagement/v1beta1/TraceProto.java index 1e6b7ce74198..f4e152bac620 100644 --- a/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/java/com/google/cloud/networkmanagement/v1beta1/TraceProto.java +++ b/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/java/com/google/cloud/networkmanagement/v1beta1/TraceProto.java @@ -255,52 +255,53 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { + "IED\020\000\022\017\n\013PEERING_VPC\020\001\022\017\n\013VPN_GATEWAY\020\002\022" + "\020\n\014INTERCONNECT\020\003\022\016\n\nGKE_MASTER\020\004\022\"\n\036IMP" + "ORTED_CUSTOM_ROUTE_NEXT_HOP\020\005\022\026\n\022CLOUD_S" - + "QL_INSTANCE\020\006\"\347\003\n\tAbortInfo\022F\n\005cause\030\001 \001" + + "QL_INSTANCE\020\006\"\214\004\n\tAbortInfo\022F\n\005cause\030\001 \001" + "(\01627.google.cloud.networkmanagement.v1be" + "ta1.AbortInfo.Cause\022\024\n\014resource_uri\030\002 \001(" - + "\t\"\373\002\n\005Cause\022\025\n\021CAUSE_UNSPECIFIED\020\000\022\023\n\017UN" - + "KNOWN_NETWORK\020\001\022\016\n\nUNKNOWN_IP\020\002\022\023\n\017UNKNO" - + "WN_PROJECT\020\003\022\025\n\021PERMISSION_DENIED\020\004\022\026\n\022N" - + "O_SOURCE_LOCATION\020\005\022\024\n\020INVALID_ARGUMENT\020" - + "\006\022\022\n\016NO_EXTERNAL_IP\020\007\022\032\n\026UNINTENDED_DEST" - + "INATION\020\010\022\022\n\016TRACE_TOO_LONG\020\t\022\022\n\016INTERNA" - + "L_ERROR\020\n\022\035\n\031SOURCE_ENDPOINT_NOT_FOUND\020\013" - + "\022\035\n\031MISMATCHED_SOURCE_NETWORK\020\014\022\"\n\036DESTI" - + "NATION_ENDPOINT_NOT_FOUND\020\r\022\"\n\036MISMATCHE" - + "D_DESTINATION_NETWORK\020\016\"\237\006\n\010DropInfo\022E\n\005" - + "cause\030\001 \001(\01626.google.cloud.networkmanage" - + "ment.v1beta1.DropInfo.Cause\022\024\n\014resource_" - + "uri\030\002 \001(\t\"\265\005\n\005Cause\022\025\n\021CAUSE_UNSPECIFIED" - + "\020\000\022\034\n\030UNKNOWN_EXTERNAL_ADDRESS\020\001\022\031\n\025FORE" - + "IGN_IP_DISALLOWED\020\002\022\021\n\rFIREWALL_RULE\020\003\022\014" - + "\n\010NO_ROUTE\020\004\022\023\n\017ROUTE_BLACKHOLE\020\005\022\027\n\023ROU" - + "TE_WRONG_NETWORK\020\006\022\037\n\033PRIVATE_TRAFFIC_TO" - + "_INTERNET\020\007\022$\n PRIVATE_GOOGLE_ACCESS_DIS" - + "ALLOWED\020\010\022\027\n\023NO_EXTERNAL_ADDRESS\020\t\022\034\n\030UN" - + "KNOWN_INTERNAL_ADDRESS\020\n\022\034\n\030FORWARDING_R" - + "ULE_MISMATCH\020\013\022 \n\034FORWARDING_RULE_NO_INS" - + "TANCES\020\014\0228\n4FIREWALL_BLOCKING_LOAD_BALAN" - + "CER_BACKEND_HEALTH_CHECK\020\r\022\030\n\024INSTANCE_N" - + "OT_RUNNING\020\016\022\030\n\024TRAFFIC_TYPE_BLOCKED\020\017\022\"" - + "\n\036GKE_MASTER_UNAUTHORIZED_ACCESS\020\020\022*\n&CL" - + "OUD_SQL_INSTANCE_UNAUTHORIZED_ACCESS\020\021\022\036" - + "\n\032DROPPED_INSIDE_GKE_SERVICE\020\022\022$\n DROPPE" - + "D_INSIDE_CLOUD_SQL_SERVICE\020\023\022%\n!GOOGLE_M" - + "ANAGED_SERVICE_NO_PEERING\020\024\022$\n CLOUD_SQL" - + "_INSTANCE_NO_IP_ADDRESS\020\025\"k\n\rGKEMasterIn" - + "fo\022\023\n\013cluster_uri\030\002 \001(\t\022\033\n\023cluster_netwo" + + "\t\022#\n\033projects_missing_permission\030\003 \003(\t\"\373" + + "\002\n\005Cause\022\025\n\021CAUSE_UNSPECIFIED\020\000\022\023\n\017UNKNO" + + "WN_NETWORK\020\001\022\016\n\nUNKNOWN_IP\020\002\022\023\n\017UNKNOWN_" + + "PROJECT\020\003\022\025\n\021PERMISSION_DENIED\020\004\022\026\n\022NO_S" + + "OURCE_LOCATION\020\005\022\024\n\020INVALID_ARGUMENT\020\006\022\022" + + "\n\016NO_EXTERNAL_IP\020\007\022\032\n\026UNINTENDED_DESTINA" + + "TION\020\010\022\022\n\016TRACE_TOO_LONG\020\t\022\022\n\016INTERNAL_E" + + "RROR\020\n\022\035\n\031SOURCE_ENDPOINT_NOT_FOUND\020\013\022\035\n" + + "\031MISMATCHED_SOURCE_NETWORK\020\014\022\"\n\036DESTINAT" + + "ION_ENDPOINT_NOT_FOUND\020\r\022\"\n\036MISMATCHED_D" + + "ESTINATION_NETWORK\020\016\"\237\006\n\010DropInfo\022E\n\005cau" + + "se\030\001 \001(\01626.google.cloud.networkmanagemen" + + "t.v1beta1.DropInfo.Cause\022\024\n\014resource_uri" + + "\030\002 \001(\t\"\265\005\n\005Cause\022\025\n\021CAUSE_UNSPECIFIED\020\000\022" + + "\034\n\030UNKNOWN_EXTERNAL_ADDRESS\020\001\022\031\n\025FOREIGN" + + "_IP_DISALLOWED\020\002\022\021\n\rFIREWALL_RULE\020\003\022\014\n\010N" + + "O_ROUTE\020\004\022\023\n\017ROUTE_BLACKHOLE\020\005\022\027\n\023ROUTE_" + + "WRONG_NETWORK\020\006\022\037\n\033PRIVATE_TRAFFIC_TO_IN" + + "TERNET\020\007\022$\n PRIVATE_GOOGLE_ACCESS_DISALL" + + "OWED\020\010\022\027\n\023NO_EXTERNAL_ADDRESS\020\t\022\034\n\030UNKNO" + + "WN_INTERNAL_ADDRESS\020\n\022\034\n\030FORWARDING_RULE" + + "_MISMATCH\020\013\022 \n\034FORWARDING_RULE_NO_INSTAN" + + "CES\020\014\0228\n4FIREWALL_BLOCKING_LOAD_BALANCER" + + "_BACKEND_HEALTH_CHECK\020\r\022\030\n\024INSTANCE_NOT_" + + "RUNNING\020\016\022\030\n\024TRAFFIC_TYPE_BLOCKED\020\017\022\"\n\036G" + + "KE_MASTER_UNAUTHORIZED_ACCESS\020\020\022*\n&CLOUD" + + "_SQL_INSTANCE_UNAUTHORIZED_ACCESS\020\021\022\036\n\032D" + + "ROPPED_INSIDE_GKE_SERVICE\020\022\022$\n DROPPED_I" + + "NSIDE_CLOUD_SQL_SERVICE\020\023\022%\n!GOOGLE_MANA" + + "GED_SERVICE_NO_PEERING\020\024\022$\n CLOUD_SQL_IN" + + "STANCE_NO_IP_ADDRESS\020\025\"k\n\rGKEMasterInfo\022" + + "\023\n\013cluster_uri\030\002 \001(\t\022\033\n\023cluster_network_" + + "uri\030\004 \001(\t\022\023\n\013internal_ip\030\005 \001(\t\022\023\n\013extern" + + "al_ip\030\006 \001(\t\"\210\001\n\024CloudSQLInstanceInfo\022\024\n\014" + + "display_name\030\001 \001(\t\022\013\n\003uri\030\002 \001(\t\022\023\n\013netwo" + "rk_uri\030\004 \001(\t\022\023\n\013internal_ip\030\005 \001(\t\022\023\n\013ext" - + "ernal_ip\030\006 \001(\t\"\210\001\n\024CloudSQLInstanceInfo\022" - + "\024\n\014display_name\030\001 \001(\t\022\013\n\003uri\030\002 \001(\t\022\023\n\013ne" - + "twork_uri\030\004 \001(\t\022\023\n\013internal_ip\030\005 \001(\t\022\023\n\013" - + "external_ip\030\006 \001(\t\022\016\n\006region\030\007 \001(\tB\221\002\n*co" - + "m.google.cloud.networkmanagement.v1beta1" - + "B\nTraceProtoP\001ZWgoogle.golang.org/genpro" - + "to/googleapis/cloud/networkmanagement/v1" - + "beta1;networkmanagement\252\002&Google.Cloud.N" - + "etworkManagement.V1Beta1\312\002&Google\\Cloud\\" - + "NetworkManagement\\V1beta1\352\002)Google::Clou" - + "d::NetworkManagement::V1beta1b\006proto3" + + "ernal_ip\030\006 \001(\t\022\016\n\006region\030\007 \001(\tB\221\002\n*com.g" + + "oogle.cloud.networkmanagement.v1beta1B\nT" + + "raceProtoP\001ZWgoogle.golang.org/genproto/" + + "googleapis/cloud/networkmanagement/v1bet" + + "a1;networkmanagement\252\002&Google.Cloud.Netw" + + "orkManagement.V1Beta1\312\002&Google\\Cloud\\Net" + + "workManagement\\V1beta1\352\002)Google::Cloud::" + + "NetworkManagement::V1beta1b\006proto3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom( @@ -493,7 +494,7 @@ public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable( internal_static_google_cloud_networkmanagement_v1beta1_AbortInfo_descriptor, new java.lang.String[] { - "Cause", "ResourceUri", + "Cause", "ResourceUri", "ProjectsMissingPermission", }); internal_static_google_cloud_networkmanagement_v1beta1_DropInfo_descriptor = getDescriptor().getMessageTypes().get(15); diff --git a/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/proto/google/cloud/networkmanagement/v1beta1/trace.proto b/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/proto/google/cloud/networkmanagement/v1beta1/trace.proto index 535a910d7c8c..ec5aa269d86b 100644 --- a/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/proto/google/cloud/networkmanagement/v1beta1/trace.proto +++ b/java-network-management/proto-google-cloud-network-management-v1beta1/src/main/proto/google/cloud/networkmanagement/v1beta1/trace.proto @@ -743,6 +743,11 @@ message AbortInfo { // URI of the resource that caused the abort. string resource_uri = 2; + + // List of project IDs that the user has specified in the request but does + // not have permission to access network configs. Analysis is aborted in this + // case with the PERMISSION_DENIED cause. + repeated string projects_missing_permission = 3; } // Details of the final state "drop" and associated resource. diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..37fe49da3102 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/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.networkmanagement.v1.samples; + +// [START +// networkmanagement_v1_generated_reachabilityserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceSettings; +import com.google.cloud.networkmanagement.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. + ReachabilityServiceSettings reachabilityServiceSettings = + ReachabilityServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ReachabilityServiceClient reachabilityServiceClient = + ReachabilityServiceClient.create(reachabilityServiceSettings); + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_create_setcredentialsprovider_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..e1c3b9be5e18 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/create/SyncCreateSetCredentialsProvider1.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.networkmanagement.v1.samples; + +// [START +// networkmanagement_v1_generated_reachabilityserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceSettings; + +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. + ReachabilityServiceSettings reachabilityServiceSettings = + ReachabilityServiceSettings.newBuilder() + .setTransportChannelProvider( + ReachabilityServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ReachabilityServiceClient reachabilityServiceClient = + ReachabilityServiceClient.create(reachabilityServiceSettings); + } +} +// [END +// networkmanagement_v1_generated_reachabilityserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/create/SyncCreateSetEndpoint.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..5c953a3fe621 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_create_setendpoint_sync] +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceSettings; +import com.google.cloud.networkmanagement.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. + ReachabilityServiceSettings reachabilityServiceSettings = + ReachabilityServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ReachabilityServiceClient reachabilityServiceClient = + ReachabilityServiceClient.create(reachabilityServiceSettings); + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_create_setendpoint_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/createconnectivitytest/AsyncCreateConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/createconnectivitytest/AsyncCreateConnectivityTest.java new file mode 100644 index 000000000000..83f1d570fd18 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/createconnectivitytest/AsyncCreateConnectivityTest.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_createconnectivitytest_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; +import com.google.longrunning.Operation; + +public class AsyncCreateConnectivityTest { + + public static void main(String[] args) throws Exception { + asyncCreateConnectivityTest(); + } + + public static void asyncCreateConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + CreateConnectivityTestRequest request = + CreateConnectivityTestRequest.newBuilder() + .setParent("parent-995424086") + .setTestId("testId-877170355") + .setResource(ConnectivityTest.newBuilder().build()) + .build(); + ApiFuture future = + reachabilityServiceClient.createConnectivityTestCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_createconnectivitytest_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/createconnectivitytest/AsyncCreateConnectivityTestLRO.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/createconnectivitytest/AsyncCreateConnectivityTestLRO.java new file mode 100644 index 000000000000..5235d5d6a7cf --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/createconnectivitytest/AsyncCreateConnectivityTestLRO.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_createconnectivitytest_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1.OperationMetadata; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; + +public class AsyncCreateConnectivityTestLRO { + + public static void main(String[] args) throws Exception { + asyncCreateConnectivityTestLRO(); + } + + public static void asyncCreateConnectivityTestLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + CreateConnectivityTestRequest request = + CreateConnectivityTestRequest.newBuilder() + .setParent("parent-995424086") + .setTestId("testId-877170355") + .setResource(ConnectivityTest.newBuilder().build()) + .build(); + OperationFuture future = + reachabilityServiceClient.createConnectivityTestOperationCallable().futureCall(request); + // Do something. + ConnectivityTest response = future.get(); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_createconnectivitytest_lro_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/createconnectivitytest/SyncCreateConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/createconnectivitytest/SyncCreateConnectivityTest.java new file mode 100644 index 000000000000..d81979f2fca4 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/createconnectivitytest/SyncCreateConnectivityTest.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_createconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.CreateConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; + +public class SyncCreateConnectivityTest { + + public static void main(String[] args) throws Exception { + syncCreateConnectivityTest(); + } + + public static void syncCreateConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + CreateConnectivityTestRequest request = + CreateConnectivityTestRequest.newBuilder() + .setParent("parent-995424086") + .setTestId("testId-877170355") + .setResource(ConnectivityTest.newBuilder().build()) + .build(); + ConnectivityTest response = + reachabilityServiceClient.createConnectivityTestAsync(request).get(); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_createconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/createconnectivitytest/SyncCreateConnectivityTestStringStringConnectivitytest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/createconnectivitytest/SyncCreateConnectivityTestStringStringConnectivitytest.java new file mode 100644 index 000000000000..126437554433 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/createconnectivitytest/SyncCreateConnectivityTestStringStringConnectivitytest.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.networkmanagement.v1.samples; + +// [START +// networkmanagement_v1_generated_reachabilityserviceclient_createconnectivitytest_stringstringconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; + +public class SyncCreateConnectivityTestStringStringConnectivitytest { + + public static void main(String[] args) throws Exception { + syncCreateConnectivityTestStringStringConnectivitytest(); + } + + public static void syncCreateConnectivityTestStringStringConnectivitytest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + String parent = "parent-995424086"; + String testId = "testId-877170355"; + ConnectivityTest resource = ConnectivityTest.newBuilder().build(); + ConnectivityTest response = + reachabilityServiceClient.createConnectivityTestAsync(parent, testId, resource).get(); + } + } +} +// [END +// networkmanagement_v1_generated_reachabilityserviceclient_createconnectivitytest_stringstringconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/deleteconnectivitytest/AsyncDeleteConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/deleteconnectivitytest/AsyncDeleteConnectivityTest.java new file mode 100644 index 000000000000..3c08a156bbf7 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/deleteconnectivitytest/AsyncDeleteConnectivityTest.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_deleteconnectivitytest_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteConnectivityTest { + + public static void main(String[] args) throws Exception { + asyncDeleteConnectivityTest(); + } + + public static void asyncDeleteConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + DeleteConnectivityTestRequest request = + DeleteConnectivityTestRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + reachabilityServiceClient.deleteConnectivityTestCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_deleteconnectivitytest_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/deleteconnectivitytest/AsyncDeleteConnectivityTestLRO.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/deleteconnectivitytest/AsyncDeleteConnectivityTestLRO.java new file mode 100644 index 000000000000..d16e4635ed19 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/deleteconnectivitytest/AsyncDeleteConnectivityTestLRO.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_deleteconnectivitytest_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1.OperationMetadata; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteConnectivityTestLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteConnectivityTestLRO(); + } + + public static void asyncDeleteConnectivityTestLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + DeleteConnectivityTestRequest request = + DeleteConnectivityTestRequest.newBuilder().setName("name3373707").build(); + OperationFuture future = + reachabilityServiceClient.deleteConnectivityTestOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_deleteconnectivitytest_lro_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/deleteconnectivitytest/SyncDeleteConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/deleteconnectivitytest/SyncDeleteConnectivityTest.java new file mode 100644 index 000000000000..7f57da22ae85 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/deleteconnectivitytest/SyncDeleteConnectivityTest.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_deleteconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1.DeleteConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; + +public class SyncDeleteConnectivityTest { + + public static void main(String[] args) throws Exception { + syncDeleteConnectivityTest(); + } + + public static void syncDeleteConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + DeleteConnectivityTestRequest request = + DeleteConnectivityTestRequest.newBuilder().setName("name3373707").build(); + reachabilityServiceClient.deleteConnectivityTestAsync(request).get(); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_deleteconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/deleteconnectivitytest/SyncDeleteConnectivityTestString.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/deleteconnectivitytest/SyncDeleteConnectivityTestString.java new file mode 100644 index 000000000000..a5f2e43b9403 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/deleteconnectivitytest/SyncDeleteConnectivityTestString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.networkmanagement.v1.samples; + +// [START +// networkmanagement_v1_generated_reachabilityserviceclient_deleteconnectivitytest_string_sync] +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; + +public class SyncDeleteConnectivityTestString { + + public static void main(String[] args) throws Exception { + syncDeleteConnectivityTestString(); + } + + public static void syncDeleteConnectivityTestString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + String name = "name3373707"; + reachabilityServiceClient.deleteConnectivityTestAsync(name).get(); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_deleteconnectivitytest_string_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/getconnectivitytest/AsyncGetConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/getconnectivitytest/AsyncGetConnectivityTest.java new file mode 100644 index 000000000000..4fd0deaa4835 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/getconnectivitytest/AsyncGetConnectivityTest.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_getconnectivitytest_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.GetConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; + +public class AsyncGetConnectivityTest { + + public static void main(String[] args) throws Exception { + asyncGetConnectivityTest(); + } + + public static void asyncGetConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + GetConnectivityTestRequest request = + GetConnectivityTestRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + reachabilityServiceClient.getConnectivityTestCallable().futureCall(request); + // Do something. + ConnectivityTest response = future.get(); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_getconnectivitytest_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/getconnectivitytest/SyncGetConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/getconnectivitytest/SyncGetConnectivityTest.java new file mode 100644 index 000000000000..f662c0e78856 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/getconnectivitytest/SyncGetConnectivityTest.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_getconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.GetConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; + +public class SyncGetConnectivityTest { + + public static void main(String[] args) throws Exception { + syncGetConnectivityTest(); + } + + public static void syncGetConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + GetConnectivityTestRequest request = + GetConnectivityTestRequest.newBuilder().setName("name3373707").build(); + ConnectivityTest response = reachabilityServiceClient.getConnectivityTest(request); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_getconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/getconnectivitytest/SyncGetConnectivityTestString.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/getconnectivitytest/SyncGetConnectivityTestString.java new file mode 100644 index 000000000000..1a1d406b4571 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/getconnectivitytest/SyncGetConnectivityTestString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_getconnectivitytest_string_sync] +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; + +public class SyncGetConnectivityTestString { + + public static void main(String[] args) throws Exception { + syncGetConnectivityTestString(); + } + + public static void syncGetConnectivityTestString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + String name = "name3373707"; + ConnectivityTest response = reachabilityServiceClient.getConnectivityTest(name); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_getconnectivitytest_string_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/listconnectivitytests/AsyncListConnectivityTests.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/listconnectivitytests/AsyncListConnectivityTests.java new file mode 100644 index 000000000000..ff13e4531891 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/listconnectivitytests/AsyncListConnectivityTests.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_listconnectivitytests_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; + +public class AsyncListConnectivityTests { + + public static void main(String[] args) throws Exception { + asyncListConnectivityTests(); + } + + public static void asyncListConnectivityTests() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + ListConnectivityTestsRequest request = + ListConnectivityTestsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + reachabilityServiceClient.listConnectivityTestsPagedCallable().futureCall(request); + // Do something. + for (ConnectivityTest element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_listconnectivitytests_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/listconnectivitytests/AsyncListConnectivityTestsPaged.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/listconnectivitytests/AsyncListConnectivityTestsPaged.java new file mode 100644 index 000000000000..c1d5063decb1 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/listconnectivitytests/AsyncListConnectivityTestsPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.networkmanagement.v1.samples; + +// [START +// networkmanagement_v1_generated_reachabilityserviceclient_listconnectivitytests_paged_async] +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest; +import com.google.cloud.networkmanagement.v1.ListConnectivityTestsResponse; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; +import com.google.common.base.Strings; + +public class AsyncListConnectivityTestsPaged { + + public static void main(String[] args) throws Exception { + asyncListConnectivityTestsPaged(); + } + + public static void asyncListConnectivityTestsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + ListConnectivityTestsRequest request = + ListConnectivityTestsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListConnectivityTestsResponse response = + reachabilityServiceClient.listConnectivityTestsCallable().call(request); + for (ConnectivityTest element : response.getResourcesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_listconnectivitytests_paged_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/listconnectivitytests/SyncListConnectivityTests.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/listconnectivitytests/SyncListConnectivityTests.java new file mode 100644 index 000000000000..cd8d068a568c --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/listconnectivitytests/SyncListConnectivityTests.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_listconnectivitytests_sync] +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.ListConnectivityTestsRequest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; + +public class SyncListConnectivityTests { + + public static void main(String[] args) throws Exception { + syncListConnectivityTests(); + } + + public static void syncListConnectivityTests() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + ListConnectivityTestsRequest request = + ListConnectivityTestsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (ConnectivityTest element : + reachabilityServiceClient.listConnectivityTests(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_listconnectivitytests_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/listconnectivitytests/SyncListConnectivityTestsString.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/listconnectivitytests/SyncListConnectivityTestsString.java new file mode 100644 index 000000000000..09c22676b3fd --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/listconnectivitytests/SyncListConnectivityTestsString.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.networkmanagement.v1.samples; + +// [START +// networkmanagement_v1_generated_reachabilityserviceclient_listconnectivitytests_string_sync] +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; + +public class SyncListConnectivityTestsString { + + public static void main(String[] args) throws Exception { + syncListConnectivityTestsString(); + } + + public static void syncListConnectivityTestsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + String parent = "parent-995424086"; + for (ConnectivityTest element : + reachabilityServiceClient.listConnectivityTests(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_listconnectivitytests_string_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/rerunconnectivitytest/AsyncRerunConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/rerunconnectivitytest/AsyncRerunConnectivityTest.java new file mode 100644 index 000000000000..4ec799f2842f --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/rerunconnectivitytest/AsyncRerunConnectivityTest.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_rerunconnectivitytest_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest; +import com.google.longrunning.Operation; + +public class AsyncRerunConnectivityTest { + + public static void main(String[] args) throws Exception { + asyncRerunConnectivityTest(); + } + + public static void asyncRerunConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + RerunConnectivityTestRequest request = + RerunConnectivityTestRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + reachabilityServiceClient.rerunConnectivityTestCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_rerunconnectivitytest_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/rerunconnectivitytest/AsyncRerunConnectivityTestLRO.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/rerunconnectivitytest/AsyncRerunConnectivityTestLRO.java new file mode 100644 index 000000000000..2d73361b3f6a --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/rerunconnectivitytest/AsyncRerunConnectivityTestLRO.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_rerunconnectivitytest_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.OperationMetadata; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest; + +public class AsyncRerunConnectivityTestLRO { + + public static void main(String[] args) throws Exception { + asyncRerunConnectivityTestLRO(); + } + + public static void asyncRerunConnectivityTestLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + RerunConnectivityTestRequest request = + RerunConnectivityTestRequest.newBuilder().setName("name3373707").build(); + OperationFuture future = + reachabilityServiceClient.rerunConnectivityTestOperationCallable().futureCall(request); + // Do something. + ConnectivityTest response = future.get(); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_rerunconnectivitytest_lro_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/rerunconnectivitytest/SyncRerunConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/rerunconnectivitytest/SyncRerunConnectivityTest.java new file mode 100644 index 000000000000..72ea857becb9 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/rerunconnectivitytest/SyncRerunConnectivityTest.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_rerunconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1.RerunConnectivityTestRequest; + +public class SyncRerunConnectivityTest { + + public static void main(String[] args) throws Exception { + syncRerunConnectivityTest(); + } + + public static void syncRerunConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + RerunConnectivityTestRequest request = + RerunConnectivityTestRequest.newBuilder().setName("name3373707").build(); + ConnectivityTest response = + reachabilityServiceClient.rerunConnectivityTestAsync(request).get(); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_rerunconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/updateconnectivitytest/AsyncUpdateConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/updateconnectivitytest/AsyncUpdateConnectivityTest.java new file mode 100644 index 000000000000..51213fb5bc02 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/updateconnectivitytest/AsyncUpdateConnectivityTest.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_updateconnectivitytest_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateConnectivityTest { + + public static void main(String[] args) throws Exception { + asyncUpdateConnectivityTest(); + } + + public static void asyncUpdateConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + UpdateConnectivityTestRequest request = + UpdateConnectivityTestRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setResource(ConnectivityTest.newBuilder().build()) + .build(); + ApiFuture future = + reachabilityServiceClient.updateConnectivityTestCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_updateconnectivitytest_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/updateconnectivitytest/AsyncUpdateConnectivityTestLRO.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/updateconnectivitytest/AsyncUpdateConnectivityTestLRO.java new file mode 100644 index 000000000000..0076a67f6929 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/updateconnectivitytest/AsyncUpdateConnectivityTestLRO.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_updateconnectivitytest_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.OperationMetadata; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateConnectivityTestLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateConnectivityTestLRO(); + } + + public static void asyncUpdateConnectivityTestLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + UpdateConnectivityTestRequest request = + UpdateConnectivityTestRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setResource(ConnectivityTest.newBuilder().build()) + .build(); + OperationFuture future = + reachabilityServiceClient.updateConnectivityTestOperationCallable().futureCall(request); + // Do something. + ConnectivityTest response = future.get(); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_updateconnectivitytest_lro_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/updateconnectivitytest/SyncUpdateConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/updateconnectivitytest/SyncUpdateConnectivityTest.java new file mode 100644 index 000000000000..cdb6835e9c85 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/updateconnectivitytest/SyncUpdateConnectivityTest.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityserviceclient_updateconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1.UpdateConnectivityTestRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateConnectivityTest { + + public static void main(String[] args) throws Exception { + syncUpdateConnectivityTest(); + } + + public static void syncUpdateConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + UpdateConnectivityTestRequest request = + UpdateConnectivityTestRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setResource(ConnectivityTest.newBuilder().build()) + .build(); + ConnectivityTest response = + reachabilityServiceClient.updateConnectivityTestAsync(request).get(); + } + } +} +// [END networkmanagement_v1_generated_reachabilityserviceclient_updateconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/updateconnectivitytest/SyncUpdateConnectivityTestFieldmaskConnectivitytest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/updateconnectivitytest/SyncUpdateConnectivityTestFieldmaskConnectivitytest.java new file mode 100644 index 000000000000..460b48d82c5c --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityserviceclient/updateconnectivitytest/SyncUpdateConnectivityTestFieldmaskConnectivitytest.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.networkmanagement.v1.samples; + +// [START +// networkmanagement_v1_generated_reachabilityserviceclient_updateconnectivitytest_fieldmaskconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1.ReachabilityServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateConnectivityTestFieldmaskConnectivitytest { + + public static void main(String[] args) throws Exception { + syncUpdateConnectivityTestFieldmaskConnectivitytest(); + } + + public static void syncUpdateConnectivityTestFieldmaskConnectivitytest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + FieldMask updateMask = FieldMask.newBuilder().build(); + ConnectivityTest resource = ConnectivityTest.newBuilder().build(); + ConnectivityTest response = + reachabilityServiceClient.updateConnectivityTestAsync(updateMask, resource).get(); + } + } +} +// [END +// networkmanagement_v1_generated_reachabilityserviceclient_updateconnectivitytest_fieldmaskconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityservicesettings/getconnectivitytest/SyncGetConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityservicesettings/getconnectivitytest/SyncGetConnectivityTest.java new file mode 100644 index 000000000000..5c8fd8667825 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/reachabilityservicesettings/getconnectivitytest/SyncGetConnectivityTest.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.networkmanagement.v1.samples; + +// [START networkmanagement_v1_generated_reachabilityservicesettings_getconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1.ReachabilityServiceSettings; +import java.time.Duration; + +public class SyncGetConnectivityTest { + + public static void main(String[] args) throws Exception { + syncGetConnectivityTest(); + } + + public static void syncGetConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ReachabilityServiceSettings.Builder reachabilityServiceSettingsBuilder = + ReachabilityServiceSettings.newBuilder(); + reachabilityServiceSettingsBuilder + .getConnectivityTestSettings() + .setRetrySettings( + reachabilityServiceSettingsBuilder + .getConnectivityTestSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ReachabilityServiceSettings reachabilityServiceSettings = + reachabilityServiceSettingsBuilder.build(); + } +} +// [END networkmanagement_v1_generated_reachabilityservicesettings_getconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/stub/reachabilityservicestubsettings/getconnectivitytest/SyncGetConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/stub/reachabilityservicestubsettings/getconnectivitytest/SyncGetConnectivityTest.java new file mode 100644 index 000000000000..4566f1f0e008 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1/stub/reachabilityservicestubsettings/getconnectivitytest/SyncGetConnectivityTest.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.networkmanagement.v1.stub.samples; + +// [START networkmanagement_v1_generated_reachabilityservicestubsettings_getconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1.stub.ReachabilityServiceStubSettings; +import java.time.Duration; + +public class SyncGetConnectivityTest { + + public static void main(String[] args) throws Exception { + syncGetConnectivityTest(); + } + + public static void syncGetConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ReachabilityServiceStubSettings.Builder reachabilityServiceSettingsBuilder = + ReachabilityServiceStubSettings.newBuilder(); + reachabilityServiceSettingsBuilder + .getConnectivityTestSettings() + .setRetrySettings( + reachabilityServiceSettingsBuilder + .getConnectivityTestSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ReachabilityServiceStubSettings reachabilityServiceSettings = + reachabilityServiceSettingsBuilder.build(); + } +} +// [END networkmanagement_v1_generated_reachabilityservicestubsettings_getconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/create/SyncCreateSetCredentialsProvider.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 000000000000..b73f72da0e24 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/create/SyncCreateSetCredentialsProvider.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.networkmanagement.v1beta1.samples; + +// [START +// networkmanagement_v1beta1_generated_reachabilityserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceSettings; +import com.google.cloud.networkmanagement.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. + ReachabilityServiceSettings reachabilityServiceSettings = + ReachabilityServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + ReachabilityServiceClient reachabilityServiceClient = + ReachabilityServiceClient.create(reachabilityServiceSettings); + } +} +// [END +// networkmanagement_v1beta1_generated_reachabilityserviceclient_create_setcredentialsprovider_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/create/SyncCreateSetCredentialsProvider1.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 000000000000..2cc39e8b7432 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/create/SyncCreateSetCredentialsProvider1.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.networkmanagement.v1beta1.samples; + +// [START +// networkmanagement_v1beta1_generated_reachabilityserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceSettings; + +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. + ReachabilityServiceSettings reachabilityServiceSettings = + ReachabilityServiceSettings.newBuilder() + .setTransportChannelProvider( + ReachabilityServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + ReachabilityServiceClient reachabilityServiceClient = + ReachabilityServiceClient.create(reachabilityServiceSettings); + } +} +// [END +// networkmanagement_v1beta1_generated_reachabilityserviceclient_create_setcredentialsprovider1_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/create/SyncCreateSetEndpoint.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 000000000000..fd389738bea7 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/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.networkmanagement.v1beta1.samples; + +// [START networkmanagement_v1beta1_generated_reachabilityserviceclient_create_setendpoint_sync] +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceSettings; +import com.google.cloud.networkmanagement.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. + ReachabilityServiceSettings reachabilityServiceSettings = + ReachabilityServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + ReachabilityServiceClient reachabilityServiceClient = + ReachabilityServiceClient.create(reachabilityServiceSettings); + } +} +// [END networkmanagement_v1beta1_generated_reachabilityserviceclient_create_setendpoint_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/createconnectivitytest/AsyncCreateConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/createconnectivitytest/AsyncCreateConnectivityTest.java new file mode 100644 index 000000000000..78d17b65fcb5 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/createconnectivitytest/AsyncCreateConnectivityTest.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.networkmanagement.v1beta1.samples; + +// [START +// networkmanagement_v1beta1_generated_reachabilityserviceclient_createconnectivitytest_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.networkmanagement.v1beta1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; +import com.google.longrunning.Operation; + +public class AsyncCreateConnectivityTest { + + public static void main(String[] args) throws Exception { + asyncCreateConnectivityTest(); + } + + public static void asyncCreateConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + CreateConnectivityTestRequest request = + CreateConnectivityTestRequest.newBuilder() + .setParent("parent-995424086") + .setTestId("testId-877170355") + .setResource(ConnectivityTest.newBuilder().build()) + .build(); + ApiFuture future = + reachabilityServiceClient.createConnectivityTestCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END networkmanagement_v1beta1_generated_reachabilityserviceclient_createconnectivitytest_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/createconnectivitytest/AsyncCreateConnectivityTestLRO.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/createconnectivitytest/AsyncCreateConnectivityTestLRO.java new file mode 100644 index 000000000000..d8469ab0306e --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/createconnectivitytest/AsyncCreateConnectivityTestLRO.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.networkmanagement.v1beta1.samples; + +// [START +// networkmanagement_v1beta1_generated_reachabilityserviceclient_createconnectivitytest_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.networkmanagement.v1beta1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1beta1.OperationMetadata; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; + +public class AsyncCreateConnectivityTestLRO { + + public static void main(String[] args) throws Exception { + asyncCreateConnectivityTestLRO(); + } + + public static void asyncCreateConnectivityTestLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + CreateConnectivityTestRequest request = + CreateConnectivityTestRequest.newBuilder() + .setParent("parent-995424086") + .setTestId("testId-877170355") + .setResource(ConnectivityTest.newBuilder().build()) + .build(); + OperationFuture future = + reachabilityServiceClient.createConnectivityTestOperationCallable().futureCall(request); + // Do something. + ConnectivityTest response = future.get(); + } + } +} +// [END +// networkmanagement_v1beta1_generated_reachabilityserviceclient_createconnectivitytest_lro_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/createconnectivitytest/SyncCreateConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/createconnectivitytest/SyncCreateConnectivityTest.java new file mode 100644 index 000000000000..5817e4ebc7cf --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/createconnectivitytest/SyncCreateConnectivityTest.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.networkmanagement.v1beta1.samples; + +// [START networkmanagement_v1beta1_generated_reachabilityserviceclient_createconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1beta1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1beta1.CreateConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; + +public class SyncCreateConnectivityTest { + + public static void main(String[] args) throws Exception { + syncCreateConnectivityTest(); + } + + public static void syncCreateConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + CreateConnectivityTestRequest request = + CreateConnectivityTestRequest.newBuilder() + .setParent("parent-995424086") + .setTestId("testId-877170355") + .setResource(ConnectivityTest.newBuilder().build()) + .build(); + ConnectivityTest response = + reachabilityServiceClient.createConnectivityTestAsync(request).get(); + } + } +} +// [END networkmanagement_v1beta1_generated_reachabilityserviceclient_createconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/deleteconnectivitytest/AsyncDeleteConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/deleteconnectivitytest/AsyncDeleteConnectivityTest.java new file mode 100644 index 000000000000..c6aefd9db78a --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/deleteconnectivitytest/AsyncDeleteConnectivityTest.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.networkmanagement.v1beta1.samples; + +// [START +// networkmanagement_v1beta1_generated_reachabilityserviceclient_deleteconnectivitytest_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteConnectivityTest { + + public static void main(String[] args) throws Exception { + asyncDeleteConnectivityTest(); + } + + public static void asyncDeleteConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + DeleteConnectivityTestRequest request = + DeleteConnectivityTestRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + reachabilityServiceClient.deleteConnectivityTestCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END networkmanagement_v1beta1_generated_reachabilityserviceclient_deleteconnectivitytest_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/deleteconnectivitytest/AsyncDeleteConnectivityTestLRO.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/deleteconnectivitytest/AsyncDeleteConnectivityTestLRO.java new file mode 100644 index 000000000000..ab60fd6b561d --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/deleteconnectivitytest/AsyncDeleteConnectivityTestLRO.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.networkmanagement.v1beta1.samples; + +// [START +// networkmanagement_v1beta1_generated_reachabilityserviceclient_deleteconnectivitytest_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1beta1.OperationMetadata; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteConnectivityTestLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteConnectivityTestLRO(); + } + + public static void asyncDeleteConnectivityTestLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + DeleteConnectivityTestRequest request = + DeleteConnectivityTestRequest.newBuilder().setName("name3373707").build(); + OperationFuture future = + reachabilityServiceClient.deleteConnectivityTestOperationCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END +// networkmanagement_v1beta1_generated_reachabilityserviceclient_deleteconnectivitytest_lro_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/deleteconnectivitytest/SyncDeleteConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/deleteconnectivitytest/SyncDeleteConnectivityTest.java new file mode 100644 index 000000000000..9888a8616c3a --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/deleteconnectivitytest/SyncDeleteConnectivityTest.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.networkmanagement.v1beta1.samples; + +// [START networkmanagement_v1beta1_generated_reachabilityserviceclient_deleteconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1beta1.DeleteConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; + +public class SyncDeleteConnectivityTest { + + public static void main(String[] args) throws Exception { + syncDeleteConnectivityTest(); + } + + public static void syncDeleteConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + DeleteConnectivityTestRequest request = + DeleteConnectivityTestRequest.newBuilder().setName("name3373707").build(); + reachabilityServiceClient.deleteConnectivityTestAsync(request).get(); + } + } +} +// [END networkmanagement_v1beta1_generated_reachabilityserviceclient_deleteconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/getconnectivitytest/AsyncGetConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/getconnectivitytest/AsyncGetConnectivityTest.java new file mode 100644 index 000000000000..50c57a462995 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/getconnectivitytest/AsyncGetConnectivityTest.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.networkmanagement.v1beta1.samples; + +// [START networkmanagement_v1beta1_generated_reachabilityserviceclient_getconnectivitytest_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.networkmanagement.v1beta1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; + +public class AsyncGetConnectivityTest { + + public static void main(String[] args) throws Exception { + asyncGetConnectivityTest(); + } + + public static void asyncGetConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + GetConnectivityTestRequest request = + GetConnectivityTestRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + reachabilityServiceClient.getConnectivityTestCallable().futureCall(request); + // Do something. + ConnectivityTest response = future.get(); + } + } +} +// [END networkmanagement_v1beta1_generated_reachabilityserviceclient_getconnectivitytest_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/getconnectivitytest/SyncGetConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/getconnectivitytest/SyncGetConnectivityTest.java new file mode 100644 index 000000000000..15c67f597e3c --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/getconnectivitytest/SyncGetConnectivityTest.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.networkmanagement.v1beta1.samples; + +// [START networkmanagement_v1beta1_generated_reachabilityserviceclient_getconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1beta1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1beta1.GetConnectivityTestRequest; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; + +public class SyncGetConnectivityTest { + + public static void main(String[] args) throws Exception { + syncGetConnectivityTest(); + } + + public static void syncGetConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + GetConnectivityTestRequest request = + GetConnectivityTestRequest.newBuilder().setName("name3373707").build(); + ConnectivityTest response = reachabilityServiceClient.getConnectivityTest(request); + } + } +} +// [END networkmanagement_v1beta1_generated_reachabilityserviceclient_getconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/listconnectivitytests/AsyncListConnectivityTests.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/listconnectivitytests/AsyncListConnectivityTests.java new file mode 100644 index 000000000000..6df752625da7 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/listconnectivitytests/AsyncListConnectivityTests.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.networkmanagement.v1beta1.samples; + +// [START networkmanagement_v1beta1_generated_reachabilityserviceclient_listconnectivitytests_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.networkmanagement.v1beta1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; + +public class AsyncListConnectivityTests { + + public static void main(String[] args) throws Exception { + asyncListConnectivityTests(); + } + + public static void asyncListConnectivityTests() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + ListConnectivityTestsRequest request = + ListConnectivityTestsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + ApiFuture future = + reachabilityServiceClient.listConnectivityTestsPagedCallable().futureCall(request); + // Do something. + for (ConnectivityTest element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END networkmanagement_v1beta1_generated_reachabilityserviceclient_listconnectivitytests_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/listconnectivitytests/AsyncListConnectivityTestsPaged.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/listconnectivitytests/AsyncListConnectivityTestsPaged.java new file mode 100644 index 000000000000..f5fe14849046 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/listconnectivitytests/AsyncListConnectivityTestsPaged.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.networkmanagement.v1beta1.samples; + +// [START +// networkmanagement_v1beta1_generated_reachabilityserviceclient_listconnectivitytests_paged_async] +import com.google.cloud.networkmanagement.v1beta1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest; +import com.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsResponse; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; +import com.google.common.base.Strings; + +public class AsyncListConnectivityTestsPaged { + + public static void main(String[] args) throws Exception { + asyncListConnectivityTestsPaged(); + } + + public static void asyncListConnectivityTestsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + ListConnectivityTestsRequest request = + ListConnectivityTestsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + while (true) { + ListConnectivityTestsResponse response = + reachabilityServiceClient.listConnectivityTestsCallable().call(request); + for (ConnectivityTest element : response.getResourcesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END +// networkmanagement_v1beta1_generated_reachabilityserviceclient_listconnectivitytests_paged_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/listconnectivitytests/SyncListConnectivityTests.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/listconnectivitytests/SyncListConnectivityTests.java new file mode 100644 index 000000000000..7ddd171cdd5a --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/listconnectivitytests/SyncListConnectivityTests.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.networkmanagement.v1beta1.samples; + +// [START networkmanagement_v1beta1_generated_reachabilityserviceclient_listconnectivitytests_sync] +import com.google.cloud.networkmanagement.v1beta1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1beta1.ListConnectivityTestsRequest; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; + +public class SyncListConnectivityTests { + + public static void main(String[] args) throws Exception { + syncListConnectivityTests(); + } + + public static void syncListConnectivityTests() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + ListConnectivityTestsRequest request = + ListConnectivityTestsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .setOrderBy("orderBy-1207110587") + .build(); + for (ConnectivityTest element : + reachabilityServiceClient.listConnectivityTests(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END networkmanagement_v1beta1_generated_reachabilityserviceclient_listconnectivitytests_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/rerunconnectivitytest/AsyncRerunConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/rerunconnectivitytest/AsyncRerunConnectivityTest.java new file mode 100644 index 000000000000..cf4282b5cc27 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/rerunconnectivitytest/AsyncRerunConnectivityTest.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.networkmanagement.v1beta1.samples; + +// [START networkmanagement_v1beta1_generated_reachabilityserviceclient_rerunconnectivitytest_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest; +import com.google.longrunning.Operation; + +public class AsyncRerunConnectivityTest { + + public static void main(String[] args) throws Exception { + asyncRerunConnectivityTest(); + } + + public static void asyncRerunConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + RerunConnectivityTestRequest request = + RerunConnectivityTestRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + reachabilityServiceClient.rerunConnectivityTestCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END networkmanagement_v1beta1_generated_reachabilityserviceclient_rerunconnectivitytest_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/rerunconnectivitytest/AsyncRerunConnectivityTestLRO.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/rerunconnectivitytest/AsyncRerunConnectivityTestLRO.java new file mode 100644 index 000000000000..1e0959c27617 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/rerunconnectivitytest/AsyncRerunConnectivityTestLRO.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.networkmanagement.v1beta1.samples; + +// [START +// networkmanagement_v1beta1_generated_reachabilityserviceclient_rerunconnectivitytest_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.networkmanagement.v1beta1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1beta1.OperationMetadata; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest; + +public class AsyncRerunConnectivityTestLRO { + + public static void main(String[] args) throws Exception { + asyncRerunConnectivityTestLRO(); + } + + public static void asyncRerunConnectivityTestLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + RerunConnectivityTestRequest request = + RerunConnectivityTestRequest.newBuilder().setName("name3373707").build(); + OperationFuture future = + reachabilityServiceClient.rerunConnectivityTestOperationCallable().futureCall(request); + // Do something. + ConnectivityTest response = future.get(); + } + } +} +// [END +// networkmanagement_v1beta1_generated_reachabilityserviceclient_rerunconnectivitytest_lro_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/rerunconnectivitytest/SyncRerunConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/rerunconnectivitytest/SyncRerunConnectivityTest.java new file mode 100644 index 000000000000..bc53ed0ab537 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/rerunconnectivitytest/SyncRerunConnectivityTest.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.networkmanagement.v1beta1.samples; + +// [START networkmanagement_v1beta1_generated_reachabilityserviceclient_rerunconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1beta1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1beta1.RerunConnectivityTestRequest; + +public class SyncRerunConnectivityTest { + + public static void main(String[] args) throws Exception { + syncRerunConnectivityTest(); + } + + public static void syncRerunConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + RerunConnectivityTestRequest request = + RerunConnectivityTestRequest.newBuilder().setName("name3373707").build(); + ConnectivityTest response = + reachabilityServiceClient.rerunConnectivityTestAsync(request).get(); + } + } +} +// [END networkmanagement_v1beta1_generated_reachabilityserviceclient_rerunconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/updateconnectivitytest/AsyncUpdateConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/updateconnectivitytest/AsyncUpdateConnectivityTest.java new file mode 100644 index 000000000000..ed6cd6887576 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/updateconnectivitytest/AsyncUpdateConnectivityTest.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.networkmanagement.v1beta1.samples; + +// [START +// networkmanagement_v1beta1_generated_reachabilityserviceclient_updateconnectivitytest_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.networkmanagement.v1beta1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateConnectivityTest { + + public static void main(String[] args) throws Exception { + asyncUpdateConnectivityTest(); + } + + public static void asyncUpdateConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + UpdateConnectivityTestRequest request = + UpdateConnectivityTestRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setResource(ConnectivityTest.newBuilder().build()) + .build(); + ApiFuture future = + reachabilityServiceClient.updateConnectivityTestCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END networkmanagement_v1beta1_generated_reachabilityserviceclient_updateconnectivitytest_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/updateconnectivitytest/AsyncUpdateConnectivityTestLRO.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/updateconnectivitytest/AsyncUpdateConnectivityTestLRO.java new file mode 100644 index 000000000000..ec15c993f89a --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/updateconnectivitytest/AsyncUpdateConnectivityTestLRO.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.networkmanagement.v1beta1.samples; + +// [START +// networkmanagement_v1beta1_generated_reachabilityserviceclient_updateconnectivitytest_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.networkmanagement.v1beta1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1beta1.OperationMetadata; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateConnectivityTestLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateConnectivityTestLRO(); + } + + public static void asyncUpdateConnectivityTestLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + UpdateConnectivityTestRequest request = + UpdateConnectivityTestRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setResource(ConnectivityTest.newBuilder().build()) + .build(); + OperationFuture future = + reachabilityServiceClient.updateConnectivityTestOperationCallable().futureCall(request); + // Do something. + ConnectivityTest response = future.get(); + } + } +} +// [END +// networkmanagement_v1beta1_generated_reachabilityserviceclient_updateconnectivitytest_lro_async] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/updateconnectivitytest/SyncUpdateConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/updateconnectivitytest/SyncUpdateConnectivityTest.java new file mode 100644 index 000000000000..ca85293f5035 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityserviceclient/updateconnectivitytest/SyncUpdateConnectivityTest.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.networkmanagement.v1beta1.samples; + +// [START networkmanagement_v1beta1_generated_reachabilityserviceclient_updateconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1beta1.ConnectivityTest; +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceClient; +import com.google.cloud.networkmanagement.v1beta1.UpdateConnectivityTestRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateConnectivityTest { + + public static void main(String[] args) throws Exception { + syncUpdateConnectivityTest(); + } + + public static void syncUpdateConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (ReachabilityServiceClient reachabilityServiceClient = ReachabilityServiceClient.create()) { + UpdateConnectivityTestRequest request = + UpdateConnectivityTestRequest.newBuilder() + .setUpdateMask(FieldMask.newBuilder().build()) + .setResource(ConnectivityTest.newBuilder().build()) + .build(); + ConnectivityTest response = + reachabilityServiceClient.updateConnectivityTestAsync(request).get(); + } + } +} +// [END networkmanagement_v1beta1_generated_reachabilityserviceclient_updateconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityservicesettings/getconnectivitytest/SyncGetConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityservicesettings/getconnectivitytest/SyncGetConnectivityTest.java new file mode 100644 index 000000000000..40c7d1ab1a83 --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/reachabilityservicesettings/getconnectivitytest/SyncGetConnectivityTest.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.networkmanagement.v1beta1.samples; + +// [START networkmanagement_v1beta1_generated_reachabilityservicesettings_getconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1beta1.ReachabilityServiceSettings; +import java.time.Duration; + +public class SyncGetConnectivityTest { + + public static void main(String[] args) throws Exception { + syncGetConnectivityTest(); + } + + public static void syncGetConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ReachabilityServiceSettings.Builder reachabilityServiceSettingsBuilder = + ReachabilityServiceSettings.newBuilder(); + reachabilityServiceSettingsBuilder + .getConnectivityTestSettings() + .setRetrySettings( + reachabilityServiceSettingsBuilder + .getConnectivityTestSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ReachabilityServiceSettings reachabilityServiceSettings = + reachabilityServiceSettingsBuilder.build(); + } +} +// [END networkmanagement_v1beta1_generated_reachabilityservicesettings_getconnectivitytest_sync] diff --git a/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/stub/reachabilityservicestubsettings/getconnectivitytest/SyncGetConnectivityTest.java b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/stub/reachabilityservicestubsettings/getconnectivitytest/SyncGetConnectivityTest.java new file mode 100644 index 000000000000..6dea765907bf --- /dev/null +++ b/java-network-management/samples/snippets/generated/com/google/cloud/networkmanagement/v1beta1/stub/reachabilityservicestubsettings/getconnectivitytest/SyncGetConnectivityTest.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.networkmanagement.v1beta1.stub.samples; + +// [START +// networkmanagement_v1beta1_generated_reachabilityservicestubsettings_getconnectivitytest_sync] +import com.google.cloud.networkmanagement.v1beta1.stub.ReachabilityServiceStubSettings; +import java.time.Duration; + +public class SyncGetConnectivityTest { + + public static void main(String[] args) throws Exception { + syncGetConnectivityTest(); + } + + public static void syncGetConnectivityTest() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + ReachabilityServiceStubSettings.Builder reachabilityServiceSettingsBuilder = + ReachabilityServiceStubSettings.newBuilder(); + reachabilityServiceSettingsBuilder + .getConnectivityTestSettings() + .setRetrySettings( + reachabilityServiceSettingsBuilder + .getConnectivityTestSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + ReachabilityServiceStubSettings reachabilityServiceSettings = + reachabilityServiceSettingsBuilder.build(); + } +} +// [END +// networkmanagement_v1beta1_generated_reachabilityservicestubsettings_getconnectivitytest_sync]