diff --git a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/AssuredWorkloadsServiceClient.java b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/AssuredWorkloadsServiceClient.java
index 22a6c36f..1996ed87 100644
--- a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/AssuredWorkloadsServiceClient.java
+++ b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/AssuredWorkloadsServiceClient.java
@@ -19,6 +19,7 @@
import com.google.api.core.ApiFuture;
import com.google.api.core.ApiFutures;
import com.google.api.gax.core.BackgroundResource;
+import com.google.api.gax.httpjson.longrunning.OperationsClient;
import com.google.api.gax.longrunning.OperationFuture;
import com.google.api.gax.paging.AbstractFixedSizeCollection;
import com.google.api.gax.paging.AbstractPage;
@@ -30,7 +31,6 @@
import com.google.cloud.assuredworkloads.v1.stub.AssuredWorkloadsServiceStubSettings;
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;
@@ -107,13 +107,29 @@
* AssuredWorkloadsServiceClient.create(assuredWorkloadsServiceSettings);
* }
*
+ * 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.
+ * AssuredWorkloadsServiceSettings assuredWorkloadsServiceSettings =
+ * AssuredWorkloadsServiceSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * AssuredWorkloadsServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
+ * AssuredWorkloadsServiceClient.create(assuredWorkloadsServiceSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@Generated("by gapic-generator-java")
public class AssuredWorkloadsServiceClient implements BackgroundResource {
private final AssuredWorkloadsServiceSettings settings;
private final AssuredWorkloadsServiceStub stub;
- private final OperationsClient operationsClient;
+ private final OperationsClient httpJsonOperationsClient;
+ private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of AssuredWorkloadsServiceClient with default settings. */
public static final AssuredWorkloadsServiceClient create() throws IOException {
@@ -146,13 +162,17 @@ protected AssuredWorkloadsServiceClient(AssuredWorkloadsServiceSettings settings
throws IOException {
this.settings = settings;
this.stub = ((AssuredWorkloadsServiceStubSettings) 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 AssuredWorkloadsServiceClient(AssuredWorkloadsServiceStub 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 AssuredWorkloadsServiceSettings getSettings() {
@@ -167,10 +187,18 @@ public AssuredWorkloadsServiceStub getStub() {
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
- public final OperationsClient getOperationsClient() {
+ public final com.google.longrunning.OperationsClient getOperationsClient() {
return operationsClient;
}
+ /**
+ * Returns the OperationsClient that can be used to query the status of a long-running operation
+ * returned by another API method call.
+ */
+ public final OperationsClient getHttpJsonOperationsClient() {
+ return httpJsonOperationsClient;
+ }
+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates Assured Workload.
diff --git a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/AssuredWorkloadsServiceSettings.java b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/AssuredWorkloadsServiceSettings.java
index 1a487ee2..24d6eaf9 100644
--- a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/AssuredWorkloadsServiceSettings.java
+++ b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/AssuredWorkloadsServiceSettings.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;
@@ -135,11 +136,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return AssuredWorkloadsServiceStubSettings.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 AssuredWorkloadsServiceStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return AssuredWorkloadsServiceStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return AssuredWorkloadsServiceStubSettings.defaultTransportChannelProvider();
}
@@ -149,11 +157,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return AssuredWorkloadsServiceStubSettings.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);
@@ -192,6 +206,11 @@ private static Builder createDefault() {
return new Builder(AssuredWorkloadsServiceStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(AssuredWorkloadsServiceStubSettings.newHttpJsonBuilder());
+ }
+
public AssuredWorkloadsServiceStubSettings.Builder getStubSettingsBuilder() {
return ((AssuredWorkloadsServiceStubSettings.Builder) getStubSettings());
}
diff --git a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/stub/AssuredWorkloadsServiceStub.java b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/stub/AssuredWorkloadsServiceStub.java
index b6082e62..5515cbfc 100644
--- a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/stub/AssuredWorkloadsServiceStub.java
+++ b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/stub/AssuredWorkloadsServiceStub.java
@@ -44,7 +44,11 @@
public abstract class AssuredWorkloadsServiceStub implements BackgroundResource {
public OperationsStub getOperationsStub() {
- throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
+ return null;
+ }
+
+ public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() {
+ return null;
}
public OperationCallable
diff --git a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/stub/AssuredWorkloadsServiceStubSettings.java b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/stub/AssuredWorkloadsServiceStubSettings.java
index b218e2de..5e6b14cf 100644
--- a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/stub/AssuredWorkloadsServiceStubSettings.java
+++ b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/stub/AssuredWorkloadsServiceStubSettings.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;
@@ -208,6 +211,11 @@ public AssuredWorkloadsServiceStub createStub() throws IOException {
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcAssuredWorkloadsServiceStub.create(this);
}
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonAssuredWorkloadsServiceStub.create(this);
+ }
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -240,18 +248,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(AssuredWorkloadsServiceStubSettings.class))
@@ -259,11 +274,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(AssuredWorkloadsServiceStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return AssuredWorkloadsServiceStubSettings.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);
@@ -383,6 +417,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
.createWorkloadSettings()
diff --git a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/stub/HttpJsonAssuredWorkloadsServiceCallableFactory.java b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/stub/HttpJsonAssuredWorkloadsServiceCallableFactory.java
new file mode 100644
index 00000000..f55c5355
--- /dev/null
+++ b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/stub/HttpJsonAssuredWorkloadsServiceCallableFactory.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.assuredworkloads.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 AssuredWorkloadsService service API.
+ *
+ * This class is for advanced usage.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonAssuredWorkloadsServiceCallableFactory
+ implements HttpJsonStubCallableFactory {
+
+ @Override
+ public UnaryCallable createUnaryCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createUnaryCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ PagedCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createPagedCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ BatchingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createBatchingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ OperationCallSettings callSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ UnaryCallable innerCallable =
+ HttpJsonCallableFactory.createBaseUnaryCallable(
+ httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext);
+ HttpJsonOperationSnapshotCallable initialCallable =
+ new HttpJsonOperationSnapshotCallable(
+ innerCallable,
+ httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory());
+ return HttpJsonCallableFactory.createOperationCallable(
+ callSettings, clientContext, operationsStub.longRunningClient(), initialCallable);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ ServerStreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createServerStreamingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+}
diff --git a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/stub/HttpJsonAssuredWorkloadsServiceStub.java b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/stub/HttpJsonAssuredWorkloadsServiceStub.java
new file mode 100644
index 00000000..1aed44f6
--- /dev/null
+++ b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1/stub/HttpJsonAssuredWorkloadsServiceStub.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.assuredworkloads.v1.stub;
+
+import static com.google.cloud.assuredworkloads.v1.AssuredWorkloadsServiceClient.ListWorkloadsPagedResponse;
+
+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.assuredworkloads.v1.CreateWorkloadOperationMetadata;
+import com.google.cloud.assuredworkloads.v1.CreateWorkloadRequest;
+import com.google.cloud.assuredworkloads.v1.DeleteWorkloadRequest;
+import com.google.cloud.assuredworkloads.v1.GetWorkloadRequest;
+import com.google.cloud.assuredworkloads.v1.ListWorkloadsRequest;
+import com.google.cloud.assuredworkloads.v1.ListWorkloadsResponse;
+import com.google.cloud.assuredworkloads.v1.UpdateWorkloadRequest;
+import com.google.cloud.assuredworkloads.v1.Workload;
+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 AssuredWorkloadsService service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@Generated("by gapic-generator-java")
+@BetaApi
+public class HttpJsonAssuredWorkloadsServiceStub extends AssuredWorkloadsServiceStub {
+ private static final TypeRegistry typeRegistry =
+ TypeRegistry.newBuilder()
+ .add(Workload.getDescriptor())
+ .add(CreateWorkloadOperationMetadata.getDescriptor())
+ .build();
+
+ private static final ApiMethodDescriptor
+ createWorkloadMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.assuredworkloads.v1.AssuredWorkloadsService/CreateWorkload")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{parent=organizations/*/locations/*}/workloads",
+ 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, "externalId", request.getExternalId());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("workload", request.getWorkload()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (CreateWorkloadRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ updateWorkloadMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.assuredworkloads.v1.AssuredWorkloadsService/UpdateWorkload")
+ .setHttpMethod("PATCH")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{workload.name=organizations/*/locations/*/workloads/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(
+ fields, "workload.name", request.getWorkload().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("workload", request.getWorkload()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Workload.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ deleteWorkloadMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.assuredworkloads.v1.AssuredWorkloadsService/DeleteWorkload")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=organizations/*/locations/*/workloads/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "etag", request.getEtag());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Empty.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ getWorkloadMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.assuredworkloads.v1.AssuredWorkloadsService/GetWorkload")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{name=organizations/*/locations/*/workloads/*}",
+ 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(Workload.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ listWorkloadsMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.assuredworkloads.v1.AssuredWorkloadsService/ListWorkloads")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1/{parent=organizations/*/locations/*}/workloads",
+ 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, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListWorkloadsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private final UnaryCallable createWorkloadCallable;
+ private final OperationCallable
+ createWorkloadOperationCallable;
+ private final UnaryCallable updateWorkloadCallable;
+ private final UnaryCallable deleteWorkloadCallable;
+ private final UnaryCallable getWorkloadCallable;
+ private final UnaryCallable listWorkloadsCallable;
+ private final UnaryCallable
+ listWorkloadsPagedCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonOperationsStub httpJsonOperationsStub;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonAssuredWorkloadsServiceStub create(
+ AssuredWorkloadsServiceStubSettings settings) throws IOException {
+ return new HttpJsonAssuredWorkloadsServiceStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonAssuredWorkloadsServiceStub create(ClientContext clientContext)
+ throws IOException {
+ return new HttpJsonAssuredWorkloadsServiceStub(
+ AssuredWorkloadsServiceStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonAssuredWorkloadsServiceStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonAssuredWorkloadsServiceStub(
+ AssuredWorkloadsServiceStubSettings.newHttpJsonBuilder().build(),
+ clientContext,
+ callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonAssuredWorkloadsServiceStub, 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 HttpJsonAssuredWorkloadsServiceStub(
+ AssuredWorkloadsServiceStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new HttpJsonAssuredWorkloadsServiceCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonAssuredWorkloadsServiceStub, 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 HttpJsonAssuredWorkloadsServiceStub(
+ AssuredWorkloadsServiceStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.httpJsonOperationsStub =
+ HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
+
+ HttpJsonCallSettings createWorkloadTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(createWorkloadMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings updateWorkloadTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(updateWorkloadMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings deleteWorkloadTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deleteWorkloadMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings getWorkloadTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getWorkloadMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ listWorkloadsTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(listWorkloadsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+
+ this.createWorkloadCallable =
+ callableFactory.createUnaryCallable(
+ createWorkloadTransportSettings, settings.createWorkloadSettings(), clientContext);
+ this.createWorkloadOperationCallable =
+ callableFactory.createOperationCallable(
+ createWorkloadTransportSettings,
+ settings.createWorkloadOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.updateWorkloadCallable =
+ callableFactory.createUnaryCallable(
+ updateWorkloadTransportSettings, settings.updateWorkloadSettings(), clientContext);
+ this.deleteWorkloadCallable =
+ callableFactory.createUnaryCallable(
+ deleteWorkloadTransportSettings, settings.deleteWorkloadSettings(), clientContext);
+ this.getWorkloadCallable =
+ callableFactory.createUnaryCallable(
+ getWorkloadTransportSettings, settings.getWorkloadSettings(), clientContext);
+ this.listWorkloadsCallable =
+ callableFactory.createUnaryCallable(
+ listWorkloadsTransportSettings, settings.listWorkloadsSettings(), clientContext);
+ this.listWorkloadsPagedCallable =
+ callableFactory.createPagedCallable(
+ listWorkloadsTransportSettings, settings.listWorkloadsSettings(), clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(createWorkloadMethodDescriptor);
+ methodDescriptors.add(updateWorkloadMethodDescriptor);
+ methodDescriptors.add(deleteWorkloadMethodDescriptor);
+ methodDescriptors.add(getWorkloadMethodDescriptor);
+ methodDescriptors.add(listWorkloadsMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ public HttpJsonOperationsStub getHttpJsonOperationsStub() {
+ return httpJsonOperationsStub;
+ }
+
+ @Override
+ public UnaryCallable createWorkloadCallable() {
+ return createWorkloadCallable;
+ }
+
+ @Override
+ public OperationCallable
+ createWorkloadOperationCallable() {
+ return createWorkloadOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable updateWorkloadCallable() {
+ return updateWorkloadCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteWorkloadCallable() {
+ return deleteWorkloadCallable;
+ }
+
+ @Override
+ public UnaryCallable getWorkloadCallable() {
+ return getWorkloadCallable;
+ }
+
+ @Override
+ public UnaryCallable listWorkloadsCallable() {
+ return listWorkloadsCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listWorkloadsPagedCallable() {
+ return listWorkloadsPagedCallable;
+ }
+
+ @Override
+ public final void close() {
+ try {
+ backgroundResources.close();
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to close resource", e);
+ }
+ }
+
+ @Override
+ public void shutdown() {
+ backgroundResources.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return backgroundResources.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return backgroundResources.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ backgroundResources.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return backgroundResources.awaitTermination(duration, unit);
+ }
+}
diff --git a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/AssuredWorkloadsServiceClient.java b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/AssuredWorkloadsServiceClient.java
index bd7b423d..c227a2a6 100644
--- a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/AssuredWorkloadsServiceClient.java
+++ b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/AssuredWorkloadsServiceClient.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.assuredworkloads.v1beta1.stub.AssuredWorkloadsServiceStubSettings;
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;
@@ -108,6 +108,21 @@
* AssuredWorkloadsServiceClient.create(assuredWorkloadsServiceSettings);
* }
*
+ * 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.
+ * AssuredWorkloadsServiceSettings assuredWorkloadsServiceSettings =
+ * AssuredWorkloadsServiceSettings.newBuilder()
+ * .setTransportChannelProvider(
+ * AssuredWorkloadsServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ * .build();
+ * AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
+ * AssuredWorkloadsServiceClient.create(assuredWorkloadsServiceSettings);
+ * }
+ *
* Please refer to the GitHub repository's samples for more quickstart code snippets.
*/
@BetaApi
@@ -115,7 +130,8 @@
public class AssuredWorkloadsServiceClient implements BackgroundResource {
private final AssuredWorkloadsServiceSettings settings;
private final AssuredWorkloadsServiceStub stub;
- private final OperationsClient operationsClient;
+ private final OperationsClient httpJsonOperationsClient;
+ private final com.google.longrunning.OperationsClient operationsClient;
/** Constructs an instance of AssuredWorkloadsServiceClient with default settings. */
public static final AssuredWorkloadsServiceClient create() throws IOException {
@@ -148,13 +164,17 @@ protected AssuredWorkloadsServiceClient(AssuredWorkloadsServiceSettings settings
throws IOException {
this.settings = settings;
this.stub = ((AssuredWorkloadsServiceStubSettings) 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 AssuredWorkloadsServiceClient(AssuredWorkloadsServiceStub 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 AssuredWorkloadsServiceSettings getSettings() {
@@ -169,10 +189,18 @@ public AssuredWorkloadsServiceStub getStub() {
* Returns the OperationsClient that can be used to query the status of a long-running operation
* returned by another API method call.
*/
- public final OperationsClient getOperationsClient() {
+ public final com.google.longrunning.OperationsClient getOperationsClient() {
return operationsClient;
}
+ /**
+ * Returns the OperationsClient that can be used to query the status of a long-running operation
+ * returned by another API method call.
+ */
+ public final OperationsClient getHttpJsonOperationsClient() {
+ return httpJsonOperationsClient;
+ }
+
// AUTO-GENERATED DOCUMENTATION AND METHOD.
/**
* Creates Assured Workload.
diff --git a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/AssuredWorkloadsServiceSettings.java b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/AssuredWorkloadsServiceSettings.java
index b3b65ae4..c0d48076 100644
--- a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/AssuredWorkloadsServiceSettings.java
+++ b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/AssuredWorkloadsServiceSettings.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;
@@ -136,11 +137,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde
return AssuredWorkloadsServiceStubSettings.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 AssuredWorkloadsServiceStubSettings.defaultGrpcTransportProviderBuilder();
}
+ /** Returns a builder for the default REST ChannelProvider for this service. */
+ @BetaApi
+ public static InstantiatingHttpJsonChannelProvider.Builder
+ defaultHttpJsonTransportProviderBuilder() {
+ return AssuredWorkloadsServiceStubSettings.defaultHttpJsonTransportProviderBuilder();
+ }
+
public static TransportChannelProvider defaultTransportChannelProvider() {
return AssuredWorkloadsServiceStubSettings.defaultTransportChannelProvider();
}
@@ -150,11 +158,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil
return AssuredWorkloadsServiceStubSettings.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);
@@ -193,6 +207,11 @@ private static Builder createDefault() {
return new Builder(AssuredWorkloadsServiceStubSettings.newBuilder());
}
+ @BetaApi
+ private static Builder createHttpJsonDefault() {
+ return new Builder(AssuredWorkloadsServiceStubSettings.newHttpJsonBuilder());
+ }
+
public AssuredWorkloadsServiceStubSettings.Builder getStubSettingsBuilder() {
return ((AssuredWorkloadsServiceStubSettings.Builder) getStubSettings());
}
diff --git a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/stub/AssuredWorkloadsServiceStub.java b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/stub/AssuredWorkloadsServiceStub.java
index 9d220ccb..1360d608 100644
--- a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/stub/AssuredWorkloadsServiceStub.java
+++ b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/stub/AssuredWorkloadsServiceStub.java
@@ -46,7 +46,11 @@
public abstract class AssuredWorkloadsServiceStub implements BackgroundResource {
public OperationsStub getOperationsStub() {
- throw new UnsupportedOperationException("Not implemented: getOperationsStub()");
+ return null;
+ }
+
+ public com.google.api.gax.httpjson.longrunning.stub.OperationsStub getHttpJsonOperationsStub() {
+ return null;
}
public OperationCallable
diff --git a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/stub/AssuredWorkloadsServiceStubSettings.java b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/stub/AssuredWorkloadsServiceStubSettings.java
index 50806cfc..4b991a42 100644
--- a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/stub/AssuredWorkloadsServiceStubSettings.java
+++ b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/stub/AssuredWorkloadsServiceStubSettings.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;
@@ -209,6 +212,11 @@ public AssuredWorkloadsServiceStub createStub() throws IOException {
.equals(GrpcTransportChannel.getGrpcTransportName())) {
return GrpcAssuredWorkloadsServiceStub.create(this);
}
+ if (getTransportChannelProvider()
+ .getTransportName()
+ .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) {
+ return HttpJsonAssuredWorkloadsServiceStub.create(this);
+ }
throw new UnsupportedOperationException(
String.format(
"Transport not supported: %s", getTransportChannelProvider().getTransportName()));
@@ -241,18 +249,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(AssuredWorkloadsServiceStubSettings.class))
@@ -260,11 +275,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(AssuredWorkloadsServiceStubSettings.class))
+ .setTransportToken(
+ GaxHttpJsonProperties.getHttpJsonTokenName(),
+ GaxHttpJsonProperties.getHttpJsonVersion());
+ }
+
+ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() {
+ return AssuredWorkloadsServiceStubSettings.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);
@@ -398,6 +432,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
.createWorkloadSettings()
diff --git a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/stub/HttpJsonAssuredWorkloadsServiceCallableFactory.java b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/stub/HttpJsonAssuredWorkloadsServiceCallableFactory.java
new file mode 100644
index 00000000..70ab5a3b
--- /dev/null
+++ b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/stub/HttpJsonAssuredWorkloadsServiceCallableFactory.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.assuredworkloads.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 AssuredWorkloadsService service API.
+ *
+ * This class is for advanced usage.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class HttpJsonAssuredWorkloadsServiceCallableFactory
+ implements HttpJsonStubCallableFactory {
+
+ @Override
+ public UnaryCallable createUnaryCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ UnaryCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createUnaryCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public
+ UnaryCallable createPagedCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ PagedCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createPagedCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @Override
+ public UnaryCallable createBatchingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ BatchingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createBatchingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+
+ @BetaApi(
+ "The surface for long-running operations is not stable yet and may change in the future.")
+ @Override
+ public
+ OperationCallable createOperationCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ OperationCallSettings callSettings,
+ ClientContext clientContext,
+ OperationsStub operationsStub) {
+ UnaryCallable innerCallable =
+ HttpJsonCallableFactory.createBaseUnaryCallable(
+ httpJsonCallSettings, callSettings.getInitialCallSettings(), clientContext);
+ HttpJsonOperationSnapshotCallable initialCallable =
+ new HttpJsonOperationSnapshotCallable(
+ innerCallable,
+ httpJsonCallSettings.getMethodDescriptor().getOperationSnapshotFactory());
+ return HttpJsonCallableFactory.createOperationCallable(
+ callSettings, clientContext, operationsStub.longRunningClient(), initialCallable);
+ }
+
+ @Override
+ public
+ ServerStreamingCallable createServerStreamingCallable(
+ HttpJsonCallSettings httpJsonCallSettings,
+ ServerStreamingCallSettings callSettings,
+ ClientContext clientContext) {
+ return HttpJsonCallableFactory.createServerStreamingCallable(
+ httpJsonCallSettings, callSettings, clientContext);
+ }
+}
diff --git a/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/stub/HttpJsonAssuredWorkloadsServiceStub.java b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/stub/HttpJsonAssuredWorkloadsServiceStub.java
new file mode 100644
index 00000000..94705b90
--- /dev/null
+++ b/google-cloud-assured-workloads/src/main/java/com/google/cloud/assuredworkloads/v1beta1/stub/HttpJsonAssuredWorkloadsServiceStub.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.assuredworkloads.v1beta1.stub;
+
+import static com.google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsServiceClient.ListWorkloadsPagedResponse;
+
+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.assuredworkloads.v1beta1.CreateWorkloadOperationMetadata;
+import com.google.cloud.assuredworkloads.v1beta1.CreateWorkloadRequest;
+import com.google.cloud.assuredworkloads.v1beta1.DeleteWorkloadRequest;
+import com.google.cloud.assuredworkloads.v1beta1.GetWorkloadRequest;
+import com.google.cloud.assuredworkloads.v1beta1.ListWorkloadsRequest;
+import com.google.cloud.assuredworkloads.v1beta1.ListWorkloadsResponse;
+import com.google.cloud.assuredworkloads.v1beta1.UpdateWorkloadRequest;
+import com.google.cloud.assuredworkloads.v1beta1.Workload;
+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 AssuredWorkloadsService service API.
+ *
+ * This class is for advanced usage and reflects the underlying API directly.
+ */
+@BetaApi
+@Generated("by gapic-generator-java")
+public class HttpJsonAssuredWorkloadsServiceStub extends AssuredWorkloadsServiceStub {
+ private static final TypeRegistry typeRegistry =
+ TypeRegistry.newBuilder()
+ .add(CreateWorkloadOperationMetadata.getDescriptor())
+ .add(Workload.getDescriptor())
+ .build();
+
+ private static final ApiMethodDescriptor
+ createWorkloadMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/CreateWorkload")
+ .setHttpMethod("POST")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{parent=organizations/*/locations/*}/workloads",
+ 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, "externalId", request.getExternalId());
+ return fields;
+ })
+ .setRequestBodyExtractor(
+ request ->
+ ProtoRestSerializer.create()
+ .toBody("workload", request.getWorkload()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Operation.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .setOperationSnapshotFactory(
+ (CreateWorkloadRequest request, Operation response) ->
+ HttpJsonOperationSnapshot.create(response))
+ .build();
+
+ private static final ApiMethodDescriptor
+ updateWorkloadMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/UpdateWorkload")
+ .setHttpMethod("PATCH")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{workload.name=organizations/*/locations/*/workloads/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(
+ fields, "workload.name", request.getWorkload().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("workload", request.getWorkload()))
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Workload.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ deleteWorkloadMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/DeleteWorkload")
+ .setHttpMethod("DELETE")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{name=organizations/*/locations/*/workloads/*}",
+ request -> {
+ Map fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putPathParam(fields, "name", request.getName());
+ return fields;
+ })
+ .setQueryParamsExtractor(
+ request -> {
+ Map> fields = new HashMap<>();
+ ProtoRestSerializer serializer =
+ ProtoRestSerializer.create();
+ serializer.putQueryParam(fields, "etag", request.getEtag());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(Empty.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ getWorkloadMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/GetWorkload")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{name=organizations/*/locations/*/workloads/*}",
+ 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(Workload.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private static final ApiMethodDescriptor
+ listWorkloadsMethodDescriptor =
+ ApiMethodDescriptor.newBuilder()
+ .setFullMethodName(
+ "google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsService/ListWorkloads")
+ .setHttpMethod("GET")
+ .setType(ApiMethodDescriptor.MethodType.UNARY)
+ .setRequestFormatter(
+ ProtoMessageRequestFormatter.newBuilder()
+ .setPath(
+ "/v1beta1/{parent=organizations/*/locations/*}/workloads",
+ 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, "pageSize", request.getPageSize());
+ serializer.putQueryParam(fields, "pageToken", request.getPageToken());
+ return fields;
+ })
+ .setRequestBodyExtractor(request -> null)
+ .build())
+ .setResponseParser(
+ ProtoMessageResponseParser.newBuilder()
+ .setDefaultInstance(ListWorkloadsResponse.getDefaultInstance())
+ .setDefaultTypeRegistry(typeRegistry)
+ .build())
+ .build();
+
+ private final UnaryCallable createWorkloadCallable;
+ private final OperationCallable
+ createWorkloadOperationCallable;
+ private final UnaryCallable updateWorkloadCallable;
+ private final UnaryCallable deleteWorkloadCallable;
+ private final UnaryCallable getWorkloadCallable;
+ private final UnaryCallable listWorkloadsCallable;
+ private final UnaryCallable
+ listWorkloadsPagedCallable;
+
+ private final BackgroundResource backgroundResources;
+ private final HttpJsonOperationsStub httpJsonOperationsStub;
+ private final HttpJsonStubCallableFactory callableFactory;
+
+ public static final HttpJsonAssuredWorkloadsServiceStub create(
+ AssuredWorkloadsServiceStubSettings settings) throws IOException {
+ return new HttpJsonAssuredWorkloadsServiceStub(settings, ClientContext.create(settings));
+ }
+
+ public static final HttpJsonAssuredWorkloadsServiceStub create(ClientContext clientContext)
+ throws IOException {
+ return new HttpJsonAssuredWorkloadsServiceStub(
+ AssuredWorkloadsServiceStubSettings.newHttpJsonBuilder().build(), clientContext);
+ }
+
+ public static final HttpJsonAssuredWorkloadsServiceStub create(
+ ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException {
+ return new HttpJsonAssuredWorkloadsServiceStub(
+ AssuredWorkloadsServiceStubSettings.newHttpJsonBuilder().build(),
+ clientContext,
+ callableFactory);
+ }
+
+ /**
+ * Constructs an instance of HttpJsonAssuredWorkloadsServiceStub, 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 HttpJsonAssuredWorkloadsServiceStub(
+ AssuredWorkloadsServiceStubSettings settings, ClientContext clientContext)
+ throws IOException {
+ this(settings, clientContext, new HttpJsonAssuredWorkloadsServiceCallableFactory());
+ }
+
+ /**
+ * Constructs an instance of HttpJsonAssuredWorkloadsServiceStub, 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 HttpJsonAssuredWorkloadsServiceStub(
+ AssuredWorkloadsServiceStubSettings settings,
+ ClientContext clientContext,
+ HttpJsonStubCallableFactory callableFactory)
+ throws IOException {
+ this.callableFactory = callableFactory;
+ this.httpJsonOperationsStub =
+ HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry);
+
+ HttpJsonCallSettings createWorkloadTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(createWorkloadMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings updateWorkloadTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(updateWorkloadMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings deleteWorkloadTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(deleteWorkloadMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings getWorkloadTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(getWorkloadMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+ HttpJsonCallSettings
+ listWorkloadsTransportSettings =
+ HttpJsonCallSettings.newBuilder()
+ .setMethodDescriptor(listWorkloadsMethodDescriptor)
+ .setTypeRegistry(typeRegistry)
+ .build();
+
+ this.createWorkloadCallable =
+ callableFactory.createUnaryCallable(
+ createWorkloadTransportSettings, settings.createWorkloadSettings(), clientContext);
+ this.createWorkloadOperationCallable =
+ callableFactory.createOperationCallable(
+ createWorkloadTransportSettings,
+ settings.createWorkloadOperationSettings(),
+ clientContext,
+ httpJsonOperationsStub);
+ this.updateWorkloadCallable =
+ callableFactory.createUnaryCallable(
+ updateWorkloadTransportSettings, settings.updateWorkloadSettings(), clientContext);
+ this.deleteWorkloadCallable =
+ callableFactory.createUnaryCallable(
+ deleteWorkloadTransportSettings, settings.deleteWorkloadSettings(), clientContext);
+ this.getWorkloadCallable =
+ callableFactory.createUnaryCallable(
+ getWorkloadTransportSettings, settings.getWorkloadSettings(), clientContext);
+ this.listWorkloadsCallable =
+ callableFactory.createUnaryCallable(
+ listWorkloadsTransportSettings, settings.listWorkloadsSettings(), clientContext);
+ this.listWorkloadsPagedCallable =
+ callableFactory.createPagedCallable(
+ listWorkloadsTransportSettings, settings.listWorkloadsSettings(), clientContext);
+
+ this.backgroundResources =
+ new BackgroundResourceAggregation(clientContext.getBackgroundResources());
+ }
+
+ @InternalApi
+ public static List getMethodDescriptors() {
+ List methodDescriptors = new ArrayList<>();
+ methodDescriptors.add(createWorkloadMethodDescriptor);
+ methodDescriptors.add(updateWorkloadMethodDescriptor);
+ methodDescriptors.add(deleteWorkloadMethodDescriptor);
+ methodDescriptors.add(getWorkloadMethodDescriptor);
+ methodDescriptors.add(listWorkloadsMethodDescriptor);
+ return methodDescriptors;
+ }
+
+ public HttpJsonOperationsStub getHttpJsonOperationsStub() {
+ return httpJsonOperationsStub;
+ }
+
+ @Override
+ public UnaryCallable createWorkloadCallable() {
+ return createWorkloadCallable;
+ }
+
+ @Override
+ public OperationCallable
+ createWorkloadOperationCallable() {
+ return createWorkloadOperationCallable;
+ }
+
+ @Override
+ public UnaryCallable updateWorkloadCallable() {
+ return updateWorkloadCallable;
+ }
+
+ @Override
+ public UnaryCallable deleteWorkloadCallable() {
+ return deleteWorkloadCallable;
+ }
+
+ @Override
+ public UnaryCallable getWorkloadCallable() {
+ return getWorkloadCallable;
+ }
+
+ @Override
+ public UnaryCallable listWorkloadsCallable() {
+ return listWorkloadsCallable;
+ }
+
+ @Override
+ public UnaryCallable
+ listWorkloadsPagedCallable() {
+ return listWorkloadsPagedCallable;
+ }
+
+ @Override
+ public final void close() {
+ try {
+ backgroundResources.close();
+ } catch (RuntimeException e) {
+ throw e;
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to close resource", e);
+ }
+ }
+
+ @Override
+ public void shutdown() {
+ backgroundResources.shutdown();
+ }
+
+ @Override
+ public boolean isShutdown() {
+ return backgroundResources.isShutdown();
+ }
+
+ @Override
+ public boolean isTerminated() {
+ return backgroundResources.isTerminated();
+ }
+
+ @Override
+ public void shutdownNow() {
+ backgroundResources.shutdownNow();
+ }
+
+ @Override
+ public boolean awaitTermination(long duration, TimeUnit unit) throws InterruptedException {
+ return backgroundResources.awaitTermination(duration, unit);
+ }
+}
diff --git a/google-cloud-assured-workloads/src/test/java/com/google/cloud/assuredworkloads/v1/AssuredWorkloadsServiceClientHttpJsonTest.java b/google-cloud-assured-workloads/src/test/java/com/google/cloud/assuredworkloads/v1/AssuredWorkloadsServiceClientHttpJsonTest.java
new file mode 100644
index 00000000..bc56604b
--- /dev/null
+++ b/google-cloud-assured-workloads/src/test/java/com/google/cloud/assuredworkloads/v1/AssuredWorkloadsServiceClientHttpJsonTest.java
@@ -0,0 +1,586 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.assuredworkloads.v1;
+
+import static com.google.cloud.assuredworkloads.v1.AssuredWorkloadsServiceClient.ListWorkloadsPagedResponse;
+
+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.assuredworkloads.v1.stub.HttpJsonAssuredWorkloadsServiceStub;
+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 AssuredWorkloadsServiceClientHttpJsonTest {
+ private static MockHttpService mockService;
+ private static AssuredWorkloadsServiceClient client;
+
+ @BeforeClass
+ public static void startStaticServer() throws IOException {
+ mockService =
+ new MockHttpService(
+ HttpJsonAssuredWorkloadsServiceStub.getMethodDescriptors(),
+ AssuredWorkloadsServiceSettings.getDefaultEndpoint());
+ AssuredWorkloadsServiceSettings settings =
+ AssuredWorkloadsServiceSettings.newHttpJsonBuilder()
+ .setTransportChannelProvider(
+ AssuredWorkloadsServiceSettings.defaultHttpJsonTransportProviderBuilder()
+ .setHttpTransport(mockService)
+ .build())
+ .setCredentialsProvider(NoCredentialsProvider.create())
+ .build();
+ client = AssuredWorkloadsServiceClient.create(settings);
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ client.close();
+ }
+
+ @Before
+ public void setUp() {}
+
+ @After
+ public void tearDown() throws Exception {
+ mockService.reset();
+ }
+
+ @Test
+ public void createWorkloadTest() throws Exception {
+ Workload expectedResponse =
+ Workload.newBuilder()
+ .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
+ .setDisplayName("displayName1714148973")
+ .addAllResources(new ArrayList())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setBillingAccount("billingAccount708726578")
+ .setEtag("etag3123477")
+ .putAllLabels(new HashMap())
+ .setProvisionedResourcesParent("provisionedResourcesParent1733249115")
+ .setKmsSettings(Workload.KMSSettings.newBuilder().build())
+ .addAllResourceSettings(new ArrayList())
+ .setEnableSovereignControls(true)
+ .setSaaEnrollmentResponse(Workload.SaaEnrollmentResponse.newBuilder().build())
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("createWorkloadTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
+ Workload workload = Workload.newBuilder().build();
+
+ Workload actualResponse = client.createWorkloadAsync(parent, workload).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 createWorkloadExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
+ Workload workload = Workload.newBuilder().build();
+ client.createWorkloadAsync(parent, workload).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+
+ @Test
+ public void createWorkloadTest2() throws Exception {
+ Workload expectedResponse =
+ Workload.newBuilder()
+ .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
+ .setDisplayName("displayName1714148973")
+ .addAllResources(new ArrayList())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setBillingAccount("billingAccount708726578")
+ .setEtag("etag3123477")
+ .putAllLabels(new HashMap())
+ .setProvisionedResourcesParent("provisionedResourcesParent1733249115")
+ .setKmsSettings(Workload.KMSSettings.newBuilder().build())
+ .addAllResourceSettings(new ArrayList())
+ .setEnableSovereignControls(true)
+ .setSaaEnrollmentResponse(Workload.SaaEnrollmentResponse.newBuilder().build())
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("createWorkloadTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ String parent = "organizations/organization-9365/locations/location-9365";
+ Workload workload = Workload.newBuilder().build();
+
+ Workload actualResponse = client.createWorkloadAsync(parent, workload).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 createWorkloadExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String parent = "organizations/organization-9365/locations/location-9365";
+ Workload workload = Workload.newBuilder().build();
+ client.createWorkloadAsync(parent, workload).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+
+ @Test
+ public void updateWorkloadTest() throws Exception {
+ Workload expectedResponse =
+ Workload.newBuilder()
+ .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
+ .setDisplayName("displayName1714148973")
+ .addAllResources(new ArrayList())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setBillingAccount("billingAccount708726578")
+ .setEtag("etag3123477")
+ .putAllLabels(new HashMap())
+ .setProvisionedResourcesParent("provisionedResourcesParent1733249115")
+ .setKmsSettings(Workload.KMSSettings.newBuilder().build())
+ .addAllResourceSettings(new ArrayList())
+ .setEnableSovereignControls(true)
+ .setSaaEnrollmentResponse(Workload.SaaEnrollmentResponse.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ Workload workload =
+ Workload.newBuilder()
+ .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
+ .setDisplayName("displayName1714148973")
+ .addAllResources(new ArrayList())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setBillingAccount("billingAccount708726578")
+ .setEtag("etag3123477")
+ .putAllLabels(new HashMap())
+ .setProvisionedResourcesParent("provisionedResourcesParent1733249115")
+ .setKmsSettings(Workload.KMSSettings.newBuilder().build())
+ .addAllResourceSettings(new ArrayList())
+ .setEnableSovereignControls(true)
+ .setSaaEnrollmentResponse(Workload.SaaEnrollmentResponse.newBuilder().build())
+ .build();
+ FieldMask updateMask = FieldMask.newBuilder().build();
+
+ Workload actualResponse = client.updateWorkload(workload, updateMask);
+ 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 updateWorkloadExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ Workload workload =
+ Workload.newBuilder()
+ .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
+ .setDisplayName("displayName1714148973")
+ .addAllResources(new ArrayList())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setBillingAccount("billingAccount708726578")
+ .setEtag("etag3123477")
+ .putAllLabels(new HashMap())
+ .setProvisionedResourcesParent("provisionedResourcesParent1733249115")
+ .setKmsSettings(Workload.KMSSettings.newBuilder().build())
+ .addAllResourceSettings(new ArrayList())
+ .setEnableSovereignControls(true)
+ .setSaaEnrollmentResponse(Workload.SaaEnrollmentResponse.newBuilder().build())
+ .build();
+ FieldMask updateMask = FieldMask.newBuilder().build();
+ client.updateWorkload(workload, updateMask);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void deleteWorkloadTest() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ WorkloadName name = WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]");
+
+ client.deleteWorkload(name);
+
+ 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 deleteWorkloadExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ WorkloadName name = WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]");
+ client.deleteWorkload(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void deleteWorkloadTest2() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ String name = "organizations/organization-4962/locations/location-4962/workloads/workload-4962";
+
+ client.deleteWorkload(name);
+
+ 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 deleteWorkloadExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name =
+ "organizations/organization-4962/locations/location-4962/workloads/workload-4962";
+ client.deleteWorkload(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getWorkloadTest() throws Exception {
+ Workload expectedResponse =
+ Workload.newBuilder()
+ .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
+ .setDisplayName("displayName1714148973")
+ .addAllResources(new ArrayList())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setBillingAccount("billingAccount708726578")
+ .setEtag("etag3123477")
+ .putAllLabels(new HashMap())
+ .setProvisionedResourcesParent("provisionedResourcesParent1733249115")
+ .setKmsSettings(Workload.KMSSettings.newBuilder().build())
+ .addAllResourceSettings(new ArrayList())
+ .setEnableSovereignControls(true)
+ .setSaaEnrollmentResponse(Workload.SaaEnrollmentResponse.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ WorkloadName name = WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]");
+
+ Workload actualResponse = client.getWorkload(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 getWorkloadExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ WorkloadName name = WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]");
+ client.getWorkload(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getWorkloadTest2() throws Exception {
+ Workload expectedResponse =
+ Workload.newBuilder()
+ .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
+ .setDisplayName("displayName1714148973")
+ .addAllResources(new ArrayList())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setBillingAccount("billingAccount708726578")
+ .setEtag("etag3123477")
+ .putAllLabels(new HashMap())
+ .setProvisionedResourcesParent("provisionedResourcesParent1733249115")
+ .setKmsSettings(Workload.KMSSettings.newBuilder().build())
+ .addAllResourceSettings(new ArrayList())
+ .setEnableSovereignControls(true)
+ .setSaaEnrollmentResponse(Workload.SaaEnrollmentResponse.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String name = "organizations/organization-4962/locations/location-4962/workloads/workload-4962";
+
+ Workload actualResponse = client.getWorkload(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 getWorkloadExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name =
+ "organizations/organization-4962/locations/location-4962/workloads/workload-4962";
+ client.getWorkload(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listWorkloadsTest() throws Exception {
+ Workload responsesElement = Workload.newBuilder().build();
+ ListWorkloadsResponse expectedResponse =
+ ListWorkloadsResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllWorkloads(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
+
+ ListWorkloadsPagedResponse pagedListResponse = client.listWorkloads(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getWorkloadsList().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 listWorkloadsExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
+ client.listWorkloads(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listWorkloadsTest2() throws Exception {
+ Workload responsesElement = Workload.newBuilder().build();
+ ListWorkloadsResponse expectedResponse =
+ ListWorkloadsResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllWorkloads(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String parent = "organizations/organization-9365/locations/location-9365";
+
+ ListWorkloadsPagedResponse pagedListResponse = client.listWorkloads(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getWorkloadsList().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 listWorkloadsExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String parent = "organizations/organization-9365/locations/location-9365";
+ client.listWorkloads(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+}
diff --git a/google-cloud-assured-workloads/src/test/java/com/google/cloud/assuredworkloads/v1beta1/AssuredWorkloadsServiceClientHttpJsonTest.java b/google-cloud-assured-workloads/src/test/java/com/google/cloud/assuredworkloads/v1beta1/AssuredWorkloadsServiceClientHttpJsonTest.java
new file mode 100644
index 00000000..dc8c992c
--- /dev/null
+++ b/google-cloud-assured-workloads/src/test/java/com/google/cloud/assuredworkloads/v1beta1/AssuredWorkloadsServiceClientHttpJsonTest.java
@@ -0,0 +1,586 @@
+/*
+ * Copyright 2022 Google LLC
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * https://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package com.google.cloud.assuredworkloads.v1beta1;
+
+import static com.google.cloud.assuredworkloads.v1beta1.AssuredWorkloadsServiceClient.ListWorkloadsPagedResponse;
+
+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.assuredworkloads.v1beta1.stub.HttpJsonAssuredWorkloadsServiceStub;
+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 AssuredWorkloadsServiceClientHttpJsonTest {
+ private static MockHttpService mockService;
+ private static AssuredWorkloadsServiceClient client;
+
+ @BeforeClass
+ public static void startStaticServer() throws IOException {
+ mockService =
+ new MockHttpService(
+ HttpJsonAssuredWorkloadsServiceStub.getMethodDescriptors(),
+ AssuredWorkloadsServiceSettings.getDefaultEndpoint());
+ AssuredWorkloadsServiceSettings settings =
+ AssuredWorkloadsServiceSettings.newHttpJsonBuilder()
+ .setTransportChannelProvider(
+ AssuredWorkloadsServiceSettings.defaultHttpJsonTransportProviderBuilder()
+ .setHttpTransport(mockService)
+ .build())
+ .setCredentialsProvider(NoCredentialsProvider.create())
+ .build();
+ client = AssuredWorkloadsServiceClient.create(settings);
+ }
+
+ @AfterClass
+ public static void stopServer() {
+ client.close();
+ }
+
+ @Before
+ public void setUp() {}
+
+ @After
+ public void tearDown() throws Exception {
+ mockService.reset();
+ }
+
+ @Test
+ public void createWorkloadTest() throws Exception {
+ Workload expectedResponse =
+ Workload.newBuilder()
+ .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
+ .setDisplayName("displayName1714148973")
+ .addAllResources(new ArrayList())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setBillingAccount("billingAccount708726578")
+ .setEtag("etag3123477")
+ .putAllLabels(new HashMap())
+ .setProvisionedResourcesParent("provisionedResourcesParent1733249115")
+ .setKmsSettings(Workload.KMSSettings.newBuilder().build())
+ .addAllResourceSettings(new ArrayList())
+ .setEnableSovereignControls(true)
+ .setSaaEnrollmentResponse(Workload.SaaEnrollmentResponse.newBuilder().build())
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("createWorkloadTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
+ Workload workload = Workload.newBuilder().build();
+
+ Workload actualResponse = client.createWorkloadAsync(parent, workload).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 createWorkloadExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
+ Workload workload = Workload.newBuilder().build();
+ client.createWorkloadAsync(parent, workload).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+
+ @Test
+ public void createWorkloadTest2() throws Exception {
+ Workload expectedResponse =
+ Workload.newBuilder()
+ .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
+ .setDisplayName("displayName1714148973")
+ .addAllResources(new ArrayList())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setBillingAccount("billingAccount708726578")
+ .setEtag("etag3123477")
+ .putAllLabels(new HashMap())
+ .setProvisionedResourcesParent("provisionedResourcesParent1733249115")
+ .setKmsSettings(Workload.KMSSettings.newBuilder().build())
+ .addAllResourceSettings(new ArrayList())
+ .setEnableSovereignControls(true)
+ .setSaaEnrollmentResponse(Workload.SaaEnrollmentResponse.newBuilder().build())
+ .build();
+ Operation resultOperation =
+ Operation.newBuilder()
+ .setName("createWorkloadTest")
+ .setDone(true)
+ .setResponse(Any.pack(expectedResponse))
+ .build();
+ mockService.addResponse(resultOperation);
+
+ String parent = "organizations/organization-9365/locations/location-9365";
+ Workload workload = Workload.newBuilder().build();
+
+ Workload actualResponse = client.createWorkloadAsync(parent, workload).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 createWorkloadExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String parent = "organizations/organization-9365/locations/location-9365";
+ Workload workload = Workload.newBuilder().build();
+ client.createWorkloadAsync(parent, workload).get();
+ Assert.fail("No exception raised");
+ } catch (ExecutionException e) {
+ }
+ }
+
+ @Test
+ public void updateWorkloadTest() throws Exception {
+ Workload expectedResponse =
+ Workload.newBuilder()
+ .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
+ .setDisplayName("displayName1714148973")
+ .addAllResources(new ArrayList())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setBillingAccount("billingAccount708726578")
+ .setEtag("etag3123477")
+ .putAllLabels(new HashMap())
+ .setProvisionedResourcesParent("provisionedResourcesParent1733249115")
+ .setKmsSettings(Workload.KMSSettings.newBuilder().build())
+ .addAllResourceSettings(new ArrayList())
+ .setEnableSovereignControls(true)
+ .setSaaEnrollmentResponse(Workload.SaaEnrollmentResponse.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ Workload workload =
+ Workload.newBuilder()
+ .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
+ .setDisplayName("displayName1714148973")
+ .addAllResources(new ArrayList())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setBillingAccount("billingAccount708726578")
+ .setEtag("etag3123477")
+ .putAllLabels(new HashMap())
+ .setProvisionedResourcesParent("provisionedResourcesParent1733249115")
+ .setKmsSettings(Workload.KMSSettings.newBuilder().build())
+ .addAllResourceSettings(new ArrayList())
+ .setEnableSovereignControls(true)
+ .setSaaEnrollmentResponse(Workload.SaaEnrollmentResponse.newBuilder().build())
+ .build();
+ FieldMask updateMask = FieldMask.newBuilder().build();
+
+ Workload actualResponse = client.updateWorkload(workload, updateMask);
+ 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 updateWorkloadExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ Workload workload =
+ Workload.newBuilder()
+ .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
+ .setDisplayName("displayName1714148973")
+ .addAllResources(new ArrayList())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setBillingAccount("billingAccount708726578")
+ .setEtag("etag3123477")
+ .putAllLabels(new HashMap())
+ .setProvisionedResourcesParent("provisionedResourcesParent1733249115")
+ .setKmsSettings(Workload.KMSSettings.newBuilder().build())
+ .addAllResourceSettings(new ArrayList())
+ .setEnableSovereignControls(true)
+ .setSaaEnrollmentResponse(Workload.SaaEnrollmentResponse.newBuilder().build())
+ .build();
+ FieldMask updateMask = FieldMask.newBuilder().build();
+ client.updateWorkload(workload, updateMask);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void deleteWorkloadTest() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ WorkloadName name = WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]");
+
+ client.deleteWorkload(name);
+
+ 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 deleteWorkloadExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ WorkloadName name = WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]");
+ client.deleteWorkload(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void deleteWorkloadTest2() throws Exception {
+ Empty expectedResponse = Empty.newBuilder().build();
+ mockService.addResponse(expectedResponse);
+
+ String name = "organizations/organization-4962/locations/location-4962/workloads/workload-4962";
+
+ client.deleteWorkload(name);
+
+ 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 deleteWorkloadExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name =
+ "organizations/organization-4962/locations/location-4962/workloads/workload-4962";
+ client.deleteWorkload(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getWorkloadTest() throws Exception {
+ Workload expectedResponse =
+ Workload.newBuilder()
+ .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
+ .setDisplayName("displayName1714148973")
+ .addAllResources(new ArrayList())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setBillingAccount("billingAccount708726578")
+ .setEtag("etag3123477")
+ .putAllLabels(new HashMap())
+ .setProvisionedResourcesParent("provisionedResourcesParent1733249115")
+ .setKmsSettings(Workload.KMSSettings.newBuilder().build())
+ .addAllResourceSettings(new ArrayList())
+ .setEnableSovereignControls(true)
+ .setSaaEnrollmentResponse(Workload.SaaEnrollmentResponse.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ WorkloadName name = WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]");
+
+ Workload actualResponse = client.getWorkload(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 getWorkloadExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ WorkloadName name = WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]");
+ client.getWorkload(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void getWorkloadTest2() throws Exception {
+ Workload expectedResponse =
+ Workload.newBuilder()
+ .setName(WorkloadName.of("[ORGANIZATION]", "[LOCATION]", "[WORKLOAD]").toString())
+ .setDisplayName("displayName1714148973")
+ .addAllResources(new ArrayList())
+ .setCreateTime(Timestamp.newBuilder().build())
+ .setBillingAccount("billingAccount708726578")
+ .setEtag("etag3123477")
+ .putAllLabels(new HashMap())
+ .setProvisionedResourcesParent("provisionedResourcesParent1733249115")
+ .setKmsSettings(Workload.KMSSettings.newBuilder().build())
+ .addAllResourceSettings(new ArrayList())
+ .setEnableSovereignControls(true)
+ .setSaaEnrollmentResponse(Workload.SaaEnrollmentResponse.newBuilder().build())
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String name = "organizations/organization-4962/locations/location-4962/workloads/workload-4962";
+
+ Workload actualResponse = client.getWorkload(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 getWorkloadExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String name =
+ "organizations/organization-4962/locations/location-4962/workloads/workload-4962";
+ client.getWorkload(name);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listWorkloadsTest() throws Exception {
+ Workload responsesElement = Workload.newBuilder().build();
+ ListWorkloadsResponse expectedResponse =
+ ListWorkloadsResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllWorkloads(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
+
+ ListWorkloadsPagedResponse pagedListResponse = client.listWorkloads(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getWorkloadsList().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 listWorkloadsExceptionTest() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ LocationName parent = LocationName.of("[ORGANIZATION]", "[LOCATION]");
+ client.listWorkloads(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+
+ @Test
+ public void listWorkloadsTest2() throws Exception {
+ Workload responsesElement = Workload.newBuilder().build();
+ ListWorkloadsResponse expectedResponse =
+ ListWorkloadsResponse.newBuilder()
+ .setNextPageToken("")
+ .addAllWorkloads(Arrays.asList(responsesElement))
+ .build();
+ mockService.addResponse(expectedResponse);
+
+ String parent = "organizations/organization-9365/locations/location-9365";
+
+ ListWorkloadsPagedResponse pagedListResponse = client.listWorkloads(parent);
+
+ List resources = Lists.newArrayList(pagedListResponse.iterateAll());
+
+ Assert.assertEquals(1, resources.size());
+ Assert.assertEquals(expectedResponse.getWorkloadsList().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 listWorkloadsExceptionTest2() throws Exception {
+ ApiException exception =
+ ApiExceptionFactory.createException(
+ new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false);
+ mockService.addException(exception);
+
+ try {
+ String parent = "organizations/organization-9365/locations/location-9365";
+ client.listWorkloads(parent);
+ Assert.fail("No exception raised");
+ } catch (InvalidArgumentException e) {
+ // Expected exception.
+ }
+ }
+}
diff --git a/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/create/SyncCreateSetCredentialsProvider.java
new file mode 100644
index 00000000..9c6c3750
--- /dev/null
+++ b/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/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.assuredworkloads.v1.samples;
+
+// [START
+// assuredworkloads_v1_generated_assuredworkloadsserviceclient_create_setcredentialsprovider_sync]
+import com.google.api.gax.core.FixedCredentialsProvider;
+import com.google.cloud.assuredworkloads.v1.AssuredWorkloadsServiceClient;
+import com.google.cloud.assuredworkloads.v1.AssuredWorkloadsServiceSettings;
+import com.google.cloud.assuredworkloads.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.
+ AssuredWorkloadsServiceSettings assuredWorkloadsServiceSettings =
+ AssuredWorkloadsServiceSettings.newBuilder()
+ .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials))
+ .build();
+ AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
+ AssuredWorkloadsServiceClient.create(assuredWorkloadsServiceSettings);
+ }
+}
+// [END
+// assuredworkloads_v1_generated_assuredworkloadsserviceclient_create_setcredentialsprovider_sync]
diff --git a/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/create/SyncCreateSetCredentialsProvider1.java
new file mode 100644
index 00000000..d9cfc714
--- /dev/null
+++ b/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/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.assuredworkloads.v1.samples;
+
+// [START
+// assuredworkloads_v1_generated_assuredworkloadsserviceclient_create_setcredentialsprovider1_sync]
+import com.google.cloud.assuredworkloads.v1.AssuredWorkloadsServiceClient;
+import com.google.cloud.assuredworkloads.v1.AssuredWorkloadsServiceSettings;
+
+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.
+ AssuredWorkloadsServiceSettings assuredWorkloadsServiceSettings =
+ AssuredWorkloadsServiceSettings.newBuilder()
+ .setTransportChannelProvider(
+ AssuredWorkloadsServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ .build();
+ AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
+ AssuredWorkloadsServiceClient.create(assuredWorkloadsServiceSettings);
+ }
+}
+// [END
+// assuredworkloads_v1_generated_assuredworkloadsserviceclient_create_setcredentialsprovider1_sync]
diff --git a/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/create/SyncCreateSetEndpoint.java
new file mode 100644
index 00000000..1ff0e1c9
--- /dev/null
+++ b/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/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.assuredworkloads.v1.samples;
+
+// [START assuredworkloads_v1_generated_assuredworkloadsserviceclient_create_setendpoint_sync]
+import com.google.cloud.assuredworkloads.v1.AssuredWorkloadsServiceClient;
+import com.google.cloud.assuredworkloads.v1.AssuredWorkloadsServiceSettings;
+import com.google.cloud.assuredworkloads.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.
+ AssuredWorkloadsServiceSettings assuredWorkloadsServiceSettings =
+ AssuredWorkloadsServiceSettings.newBuilder().setEndpoint(myEndpoint).build();
+ AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
+ AssuredWorkloadsServiceClient.create(assuredWorkloadsServiceSettings);
+ }
+}
+// [END assuredworkloads_v1_generated_assuredworkloadsserviceclient_create_setendpoint_sync]
diff --git a/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/createworkload/AsyncCreateWorkload.java b/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/createworkload/AsyncCreateWorkload.java
new file mode 100644
index 00000000..67365c6f
--- /dev/null
+++ b/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/createworkload/AsyncCreateWorkload.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.assuredworkloads.v1.samples;
+
+// [START assuredworkloads_v1_generated_assuredworkloadsserviceclient_createworkload_async]
+import com.google.api.core.ApiFuture;
+import com.google.cloud.assuredworkloads.v1.AssuredWorkloadsServiceClient;
+import com.google.cloud.assuredworkloads.v1.CreateWorkloadRequest;
+import com.google.cloud.assuredworkloads.v1.LocationName;
+import com.google.cloud.assuredworkloads.v1.Workload;
+import com.google.longrunning.Operation;
+
+public class AsyncCreateWorkload {
+
+ public static void main(String[] args) throws Exception {
+ asyncCreateWorkload();
+ }
+
+ public static void asyncCreateWorkload() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
+ AssuredWorkloadsServiceClient.create()) {
+ CreateWorkloadRequest request =
+ CreateWorkloadRequest.newBuilder()
+ .setParent(LocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
+ .setWorkload(Workload.newBuilder().build())
+ .setExternalId("externalId-1699764666")
+ .build();
+ ApiFuture future =
+ assuredWorkloadsServiceClient.createWorkloadCallable().futureCall(request);
+ // Do something.
+ Operation response = future.get();
+ }
+ }
+}
+// [END assuredworkloads_v1_generated_assuredworkloadsserviceclient_createworkload_async]
diff --git a/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/createworkload/AsyncCreateWorkloadLRO.java b/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/createworkload/AsyncCreateWorkloadLRO.java
new file mode 100644
index 00000000..b485dd19
--- /dev/null
+++ b/samples/snippets/generated/com/google/cloud/assuredworkloads/v1/assuredworkloadsserviceclient/createworkload/AsyncCreateWorkloadLRO.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.assuredworkloads.v1.samples;
+
+// [START assuredworkloads_v1_generated_assuredworkloadsserviceclient_createworkload_lro_async]
+import com.google.api.gax.longrunning.OperationFuture;
+import com.google.cloud.assuredworkloads.v1.AssuredWorkloadsServiceClient;
+import com.google.cloud.assuredworkloads.v1.CreateWorkloadOperationMetadata;
+import com.google.cloud.assuredworkloads.v1.CreateWorkloadRequest;
+import com.google.cloud.assuredworkloads.v1.LocationName;
+import com.google.cloud.assuredworkloads.v1.Workload;
+
+public class AsyncCreateWorkloadLRO {
+
+ public static void main(String[] args) throws Exception {
+ asyncCreateWorkloadLRO();
+ }
+
+ public static void asyncCreateWorkloadLRO() throws Exception {
+ // This snippet has been automatically generated for illustrative purposes only.
+ // It may require modifications to work in your environment.
+ try (AssuredWorkloadsServiceClient assuredWorkloadsServiceClient =
+ AssuredWorkloadsServiceClient.create()) {
+ CreateWorkloadRequest request =
+ CreateWorkloadRequest.newBuilder()
+ .setParent(LocationName.of("[ORGANIZATION]", "[LOCATION]").toString())
+ .setWorkload(Workload.newBuilder().build())
+ .setExternalId("externalId-1699764666")
+ .build();
+ OperationFuture