diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index f60d7749..a454a61e 100644 --- a/.github/.OwlBot.lock.yaml +++ b/.github/.OwlBot.lock.yaml @@ -13,5 +13,5 @@ # limitations under the License. docker: image: gcr.io/cloud-devrel-public-resources/owlbot-java:latest - digest: sha256:fc52b202aa298a50a12c64efd04fea3884d867947effe2fa85382a246c09e813 -# created: 2022-04-06T16:30:03.627422514Z + digest: sha256:6d4e3a15c62cfdcb823d60e16da7521e7c6fc00eba07c8ff12e4de9924a57d28 +# created: 2022-06-29T23:17:33.110417661Z diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml index 31d961ac..b11618d9 100644 --- a/.github/.OwlBot.yaml +++ b/.github/.OwlBot.yaml @@ -16,6 +16,7 @@ docker: image: "gcr.io/cloud-devrel-public-resources/owlbot-java:latest" deep-remove-regex: +- "/samples/snippets/generated" - "/grpc-google-.*/src" - "/proto-google-.*/src" - "/google-.*/src" @@ -27,3 +28,5 @@ deep-copy-regex: dest: "/owl-bot-staging/$1/grpc-google-cloud-os-config-$1/src" - source: "/google/cloud/osconfig/(v.*)/.*-java/gapic-google-.*/src" dest: "/owl-bot-staging/$1/google-cloud-os-config/src" +- source: "/google/cloud/osconfig/(v.*)/.*-java/samples/snippets/generated" + dest: "/owl-bot-staging/$1/samples/snippets/generated" diff --git a/.github/sync-repo-settings.yaml b/.github/sync-repo-settings.yaml index 6f09d695..dd5626f3 100644 --- a/.github/sync-repo-settings.yaml +++ b/.github/sync-repo-settings.yaml @@ -11,7 +11,6 @@ branchProtectionRules: - dependencies (8) - dependencies (11) - lint - - clirr - units (8) - units (11) - 'Kokoro - Test: Integration' @@ -26,7 +25,6 @@ branchProtectionRules: - dependencies (8) - dependencies (11) - lint - - clirr - units (7) - units (8) - units (11) diff --git a/.kokoro/build.sh b/.kokoro/build.sh index 06fb8017..2ee9ea2f 100755 --- a/.kokoro/build.sh +++ b/.kokoro/build.sh @@ -74,6 +74,11 @@ graalvm) mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative -Penable-integration-tests test RETURN_CODE=$? ;; +graalvm17) + # Run Unit and Integration Tests with Native Image + mvn -B ${INTEGRATION_TEST_ARGS} -ntp -Pnative -Penable-integration-tests test + RETURN_CODE=$? + ;; samples) SAMPLES_DIR=samples # only run ITs in snapshot/ on presubmit PRs. run ITs in all 3 samples/ subdirectories otherwise. diff --git a/.kokoro/common.sh b/.kokoro/common.sh index ace89f45..f8f957af 100644 --- a/.kokoro/common.sh +++ b/.kokoro/common.sh @@ -55,4 +55,6 @@ function retry_with_backoff { ## Helper functionss function now() { date +"%Y-%m-%d %H:%M:%S" | tr -d '\n'; } function msg() { println "$*" >&2; } -function println() { printf '%s\n' "$(now) $*"; } \ No newline at end of file +function println() { printf '%s\n' "$(now) $*"; } + +## Helper comment to trigger updated repo dependency release \ No newline at end of file diff --git a/.kokoro/presubmit/graalvm-native-17.cfg b/.kokoro/presubmit/graalvm-native-17.cfg new file mode 100644 index 00000000..a3f7fb9d --- /dev/null +++ b/.kokoro/presubmit/graalvm-native-17.cfg @@ -0,0 +1,33 @@ +# Format: //devtools/kokoro/config/proto/build.proto + +# Configure the docker image for kokoro-trampoline. +env_vars: { + key: "TRAMPOLINE_IMAGE" + value: "gcr.io/cloud-devrel-kokoro-resources/graalvm17" +} + +env_vars: { + key: "JOB_TYPE" + value: "graalvm17" +} + +# TODO: remove this after we've migrated all tests and scripts +env_vars: { + key: "GCLOUD_PROJECT" + value: "gcloud-devel" +} + +env_vars: { + key: "GOOGLE_CLOUD_PROJECT" + value: "gcloud-devel" +} + +env_vars: { + key: "GOOGLE_APPLICATION_CREDENTIALS" + value: "secret_manager/java-it-service-account" +} + +env_vars: { + key: "SECRET_MANAGER_KEYS" + value: "java-it-service-account" +} \ No newline at end of file diff --git a/.kokoro/release/stage.sh b/.kokoro/release/stage.sh index 77dc4e8f..1dba8de1 100755 --- a/.kokoro/release/stage.sh +++ b/.kokoro/release/stage.sh @@ -32,6 +32,7 @@ retry_with_backoff 3 10 \ mvn clean deploy -B \ --settings ${MAVEN_SETTINGS_FILE} \ -DskipTests=true \ + -Dclirr.skip=true \ -DperformRelease=true \ -Dgpg.executable=gpg \ -Dgpg.passphrase=${GPG_PASSPHRASE} \ @@ -42,4 +43,4 @@ then mvn nexus-staging:release -B \ -DperformRelease=true \ --settings=settings.xml -fi \ No newline at end of file +fi diff --git a/CHANGELOG.md b/CHANGELOG.md index 84cd7d96..60996345 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,23 @@ # Changelog +## [2.5.0](https://github.com/googleapis/java-os-config/compare/v2.4.3...v2.5.0) (2022-07-01) + + +### Features + +* add build scripts for native image testing in Java 17 ([#1440](https://github.com/googleapis/java-os-config/issues/1440)) ([#477](https://github.com/googleapis/java-os-config/issues/477)) ([0891ed6](https://github.com/googleapis/java-os-config/commit/0891ed6362b9592b7fcca6bfd9299e24653a9f3d)) +* Enable REST transport for most of Java and Go clients ([#489](https://github.com/googleapis/java-os-config/issues/489)) ([2be3336](https://github.com/googleapis/java-os-config/commit/2be3336b765ddd818093d536fe5755a00ca08b30)) + + +### Bug Fixes + +* update gapic-generator-java with mock service generation fixes ([#491](https://github.com/googleapis/java-os-config/issues/491)) ([8145795](https://github.com/googleapis/java-os-config/commit/8145795ab21617583384b1a2c159cadac337ad21)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#488](https://github.com/googleapis/java-os-config/issues/488)) ([876c3b2](https://github.com/googleapis/java-os-config/commit/876c3b20dbb4d279d658dce2e27ce0459515175c)) + ### [2.4.3](https://github.com/googleapis/java-os-config/compare/v2.4.2...v2.4.3) (2022-05-19) diff --git a/README.md b/README.md index a602f55f..128e0b4e 100644 --- a/README.md +++ b/README.md @@ -19,20 +19,20 @@ If you are using Maven, add this to your pom.xml file: com.google.cloud google-cloud-os-config - 2.4.2 + 2.4.3 ``` If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-os-config:2.4.2' +implementation 'com.google.cloud:google-cloud-os-config:2.4.3' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-os-config" % "2.4.2" +libraryDependencies += "com.google.cloud" % "google-cloud-os-config" % "2.4.3" ``` ## Authentication diff --git a/google-cloud-os-config-bom/pom.xml b/google-cloud-os-config-bom/pom.xml index aec63925..de591282 100644 --- a/google-cloud-os-config-bom/pom.xml +++ b/google-cloud-os-config-bom/pom.xml @@ -3,12 +3,12 @@ 4.0.0 com.google.cloud google-cloud-os-config-bom - 2.4.3 + 2.5.0 pom com.google.cloud google-cloud-shared-config - 1.4.0 + 1.5.0 Google OS Config API BOM @@ -52,37 +52,37 @@ com.google.cloud google-cloud-os-config - 2.4.3 + 2.5.0 com.google.api.grpc grpc-google-cloud-os-config-v1 - 2.4.3 + 2.5.0 com.google.api.grpc grpc-google-cloud-os-config-v1beta - 2.4.3 + 2.5.0 com.google.api.grpc grpc-google-cloud-os-config-v1alpha - 2.4.3 + 2.5.0 com.google.api.grpc proto-google-cloud-os-config-v1 - 2.4.3 + 2.5.0 com.google.api.grpc proto-google-cloud-os-config-v1alpha - 2.4.3 + 2.5.0 com.google.api.grpc proto-google-cloud-os-config-v1beta - 2.4.3 + 2.5.0 diff --git a/google-cloud-os-config/pom.xml b/google-cloud-os-config/pom.xml index 52e97711..1568fe76 100644 --- a/google-cloud-os-config/pom.xml +++ b/google-cloud-os-config/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-os-config - 2.4.3 + 2.5.0 jar Google OS Config API https://github.com/googleapis/java-os-config @@ -11,7 +11,7 @@ com.google.cloud google-cloud-os-config-parent - 2.4.3 + 2.5.0 google-cloud-os-config @@ -66,6 +66,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -93,12 +97,24 @@ test + + com.google.api + gax + testlib + test + com.google.api gax-grpc testlib test + + com.google.api + gax-httpjson + testlib + test + diff --git a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceClient.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceClient.java index 79ba3983..3312e93e 100644 --- a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceClient.java +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceClient.java @@ -18,7 +18,6 @@ import com.google.api.core.ApiFuture; import com.google.api.core.ApiFutures; -import com.google.api.core.BetaApi; import com.google.api.gax.core.BackgroundResource; import com.google.api.gax.paging.AbstractFixedSizeCollection; import com.google.api.gax.paging.AbstractPage; @@ -115,6 +114,21 @@ * OsConfigServiceClient.create(osConfigServiceSettings); * } * + *

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.
+ * OsConfigServiceSettings osConfigServiceSettings =
+ *     OsConfigServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             OsConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * OsConfigServiceClient osConfigServiceClient =
+ *     OsConfigServiceClient.create(osConfigServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") @@ -140,7 +154,6 @@ public static final OsConfigServiceClient create(OsConfigServiceSettings setting * Constructs an instance of OsConfigServiceClient, using the given stub for making calls. This is * for advanced usage - prefer using create(OsConfigServiceSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final OsConfigServiceClient create(OsConfigServiceStub stub) { return new OsConfigServiceClient(stub); } @@ -155,7 +168,6 @@ protected OsConfigServiceClient(OsConfigServiceSettings settings) throws IOExcep this.stub = ((OsConfigServiceStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected OsConfigServiceClient(OsConfigServiceStub stub) { this.settings = null; this.stub = stub; @@ -165,7 +177,6 @@ public final OsConfigServiceSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public OsConfigServiceStub getStub() { return stub; } @@ -526,7 +537,7 @@ public final ListPatchJobsPagedResponse listPatchJobs(PatchJobs.ListPatchJobsReq * while (true) { * PatchJobs.ListPatchJobsResponse response = * osConfigServiceClient.listPatchJobsCallable().call(request); - * for (PatchJobs.PatchJob element : response.getResponsesList()) { + * for (PatchJobs.PatchJob element : response.getPatchJobsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -687,7 +698,8 @@ public final ListPatchJobInstanceDetailsPagedResponse listPatchJobInstanceDetail * while (true) { * PatchJobs.ListPatchJobInstanceDetailsResponse response = * osConfigServiceClient.listPatchJobInstanceDetailsCallable().call(request); - * for (PatchJobs.PatchJobInstanceDetails element : response.getResponsesList()) { + * for (PatchJobs.PatchJobInstanceDetails element : + * response.getPatchJobInstanceDetailsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1099,7 +1111,7 @@ public final ListPatchDeploymentsPagedResponse listPatchDeployments( * while (true) { * PatchDeployments.ListPatchDeploymentsResponse response = * osConfigServiceClient.listPatchDeploymentsCallable().call(request); - * for (PatchDeployments.PatchDeployment element : response.getResponsesList()) { + * for (PatchDeployments.PatchDeployment element : response.getPatchDeploymentsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceSettings.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceSettings.java index e61e2143..d984e7eb 100644 --- a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceSettings.java +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigServiceSettings.java @@ -25,6 +25,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; @@ -184,11 +185,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return OsConfigServiceStubSettings.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 OsConfigServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return OsConfigServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return OsConfigServiceStubSettings.defaultTransportChannelProvider(); } @@ -198,11 +206,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return OsConfigServiceStubSettings.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); @@ -240,6 +254,11 @@ private static Builder createDefault() { return new Builder(OsConfigServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(OsConfigServiceStubSettings.newHttpJsonBuilder()); + } + public OsConfigServiceStubSettings.Builder getStubSettingsBuilder() { return ((OsConfigServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClient.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClient.java index 6f927c3b..d999c42f 100644 --- a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClient.java +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClient.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.osconfig.v1.stub.OsConfigZonalServiceStubSettings; 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; @@ -111,13 +111,29 @@ * OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); * } * + *

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.
+ * OsConfigZonalServiceSettings osConfigZonalServiceSettings =
+ *     OsConfigZonalServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             OsConfigZonalServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * OsConfigZonalServiceClient osConfigZonalServiceClient =
+ *     OsConfigZonalServiceClient.create(osConfigZonalServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") public class OsConfigZonalServiceClient implements BackgroundResource { private final OsConfigZonalServiceSettings settings; private final OsConfigZonalServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of OsConfigZonalServiceClient with default settings. */ public static final OsConfigZonalServiceClient create() throws IOException { @@ -137,7 +153,6 @@ public static final OsConfigZonalServiceClient create(OsConfigZonalServiceSettin * Constructs an instance of OsConfigZonalServiceClient, using the given stub for making calls. * This is for advanced usage - prefer using create(OsConfigZonalServiceSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final OsConfigZonalServiceClient create(OsConfigZonalServiceStub stub) { return new OsConfigZonalServiceClient(stub); } @@ -150,21 +165,23 @@ public static final OsConfigZonalServiceClient create(OsConfigZonalServiceStub s protected OsConfigZonalServiceClient(OsConfigZonalServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((OsConfigZonalServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected OsConfigZonalServiceClient(OsConfigZonalServiceStub 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 OsConfigZonalServiceSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public OsConfigZonalServiceStub getStub() { return stub; } @@ -173,10 +190,19 @@ public OsConfigZonalServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Create an OS policy assignment. @@ -837,7 +863,7 @@ public final ListOSPolicyAssignmentsPagedResponse listOSPolicyAssignments( * while (true) { * ListOSPolicyAssignmentsResponse response = * osConfigZonalServiceClient.listOSPolicyAssignmentsCallable().call(request); - * for (OSPolicyAssignment element : response.getResponsesList()) { + * for (OSPolicyAssignment element : response.getOsPolicyAssignmentsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1009,7 +1035,7 @@ public final ListOSPolicyAssignmentRevisionsPagedResponse listOSPolicyAssignment * while (true) { * ListOSPolicyAssignmentRevisionsResponse response = * osConfigZonalServiceClient.listOSPolicyAssignmentRevisionsCallable().call(request); - * for (OSPolicyAssignment element : response.getResponsesList()) { + * for (OSPolicyAssignment element : response.getOsPolicyAssignmentsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1550,7 +1576,7 @@ public final ListOSPolicyAssignmentReportsPagedResponse listOSPolicyAssignmentRe * while (true) { * ListOSPolicyAssignmentReportsResponse response = * osConfigZonalServiceClient.listOSPolicyAssignmentReportsCallable().call(request); - * for (OSPolicyAssignmentReport element : response.getResponsesList()) { + * for (OSPolicyAssignmentReport element : response.getOsPolicyAssignmentReportsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1694,7 +1720,7 @@ public final UnaryCallable getInventoryCallable( * try (OsConfigZonalServiceClient osConfigZonalServiceClient = * OsConfigZonalServiceClient.create()) { * InstanceName parent = - * InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]"); + * InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); * for (Inventory element : osConfigZonalServiceClient.listInventories(parent).iterateAll()) { * // doThingsWith(element); * } @@ -1757,7 +1783,8 @@ public final ListInventoriesPagedResponse listInventories(String parent) { * ListInventoriesRequest request = * ListInventoriesRequest.newBuilder() * .setParent( - * InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]") + * InstanceName.ofProjectLocationInstanceName( + * "[PROJECT]", "[LOCATION]", "[INSTANCE]") * .toString()) * .setView(InventoryView.forNumber(0)) * .setPageSize(883849137) @@ -1791,7 +1818,8 @@ public final ListInventoriesPagedResponse listInventories(ListInventoriesRequest * ListInventoriesRequest request = * ListInventoriesRequest.newBuilder() * .setParent( - * InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]") + * InstanceName.ofProjectLocationInstanceName( + * "[PROJECT]", "[LOCATION]", "[INSTANCE]") * .toString()) * .setView(InventoryView.forNumber(0)) * .setPageSize(883849137) @@ -1826,7 +1854,8 @@ public final ListInventoriesPagedResponse listInventories(ListInventoriesRequest * ListInventoriesRequest request = * ListInventoriesRequest.newBuilder() * .setParent( - * InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]") + * InstanceName.ofProjectLocationInstanceName( + * "[PROJECT]", "[LOCATION]", "[INSTANCE]") * .toString()) * .setView(InventoryView.forNumber(0)) * .setPageSize(883849137) @@ -1836,7 +1865,7 @@ public final ListInventoriesPagedResponse listInventories(ListInventoriesRequest * while (true) { * ListInventoriesResponse response = * osConfigZonalServiceClient.listInventoriesCallable().call(request); - * for (Inventory element : response.getResponsesList()) { + * for (Inventory element : response.getInventoriesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1986,7 +2015,7 @@ public final VulnerabilityReport getVulnerabilityReport(GetVulnerabilityReportRe * try (OsConfigZonalServiceClient osConfigZonalServiceClient = * OsConfigZonalServiceClient.create()) { * InstanceName parent = - * InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]"); + * InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); * for (VulnerabilityReport element : * osConfigZonalServiceClient.listVulnerabilityReports(parent).iterateAll()) { * // doThingsWith(element); @@ -2052,7 +2081,8 @@ public final ListVulnerabilityReportsPagedResponse listVulnerabilityReports(Stri * ListVulnerabilityReportsRequest request = * ListVulnerabilityReportsRequest.newBuilder() * .setParent( - * InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]") + * InstanceName.ofProjectLocationInstanceName( + * "[PROJECT]", "[LOCATION]", "[INSTANCE]") * .toString()) * .setPageSize(883849137) * .setPageToken("pageToken873572522") @@ -2087,7 +2117,8 @@ public final ListVulnerabilityReportsPagedResponse listVulnerabilityReports( * ListVulnerabilityReportsRequest request = * ListVulnerabilityReportsRequest.newBuilder() * .setParent( - * InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]") + * InstanceName.ofProjectLocationInstanceName( + * "[PROJECT]", "[LOCATION]", "[INSTANCE]") * .toString()) * .setPageSize(883849137) * .setPageToken("pageToken873572522") @@ -2121,7 +2152,8 @@ public final ListVulnerabilityReportsPagedResponse listVulnerabilityReports( * ListVulnerabilityReportsRequest request = * ListVulnerabilityReportsRequest.newBuilder() * .setParent( - * InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]") + * InstanceName.ofProjectLocationInstanceName( + * "[PROJECT]", "[LOCATION]", "[INSTANCE]") * .toString()) * .setPageSize(883849137) * .setPageToken("pageToken873572522") @@ -2130,7 +2162,7 @@ public final ListVulnerabilityReportsPagedResponse listVulnerabilityReports( * while (true) { * ListVulnerabilityReportsResponse response = * osConfigZonalServiceClient.listVulnerabilityReportsCallable().call(request); - * for (VulnerabilityReport element : response.getResponsesList()) { + * for (VulnerabilityReport element : response.getVulnerabilityReportsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceSettings.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceSettings.java index a9f89186..31ebc4cc 100644 --- a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceSettings.java +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceSettings.java @@ -27,6 +27,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; @@ -219,11 +220,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return OsConfigZonalServiceStubSettings.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 OsConfigZonalServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return OsConfigZonalServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return OsConfigZonalServiceStubSettings.defaultTransportChannelProvider(); } @@ -233,11 +241,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return OsConfigZonalServiceStubSettings.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); @@ -276,6 +290,11 @@ private static Builder createDefault() { return new Builder(OsConfigZonalServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(OsConfigZonalServiceStubSettings.newHttpJsonBuilder()); + } + public OsConfigZonalServiceStubSettings.Builder getStubSettingsBuilder() { return ((OsConfigZonalServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigServiceCallableFactory.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigServiceCallableFactory.java new file mode 100644 index 00000000..878cde9b --- /dev/null +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigServiceCallableFactory.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.osconfig.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 OsConfigService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonOsConfigServiceCallableFactory + 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-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigServiceStub.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigServiceStub.java new file mode 100644 index 00000000..29c595e6 --- /dev/null +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigServiceStub.java @@ -0,0 +1,930 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.stub; + +import static com.google.cloud.osconfig.v1.OsConfigServiceClient.ListPatchDeploymentsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigServiceClient.ListPatchJobInstanceDetailsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigServiceClient.ListPatchJobsPagedResponse; + +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.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.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.PatchJobs; +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 OsConfigService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonOsConfigServiceStub extends OsConfigServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + executePatchJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/ExecutePatchJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/patchJobs:execute", + 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(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchJobs.PatchJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getPatchJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/GetPatchJob") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/patchJobs/*}", + 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(PatchJobs.PatchJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + cancelPatchJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/CancelPatchJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/patchJobs/*}:cancel", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchJobs.PatchJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchJobs.ListPatchJobsRequest, PatchJobs.ListPatchJobsResponse> + listPatchJobsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/ListPatchJobs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*}/patchJobs", + 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(PatchJobs.ListPatchJobsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigService/ListPatchJobInstanceDetails") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{parent=projects/*/patchJobs/*}/instanceDetails", + 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( + PatchJobs.ListPatchJobInstanceDetailsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/CreatePatchDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{parent=projects/*}/patchDeployments", + 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, "patchDeploymentId", request.getPatchDeploymentId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("patchDeployment", request.getPatchDeployment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.GetPatchDeploymentRequest, PatchDeployments.PatchDeployment> + getPatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/GetPatchDeployment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{name=projects/*/patchDeployments/*}", + 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(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/ListPatchDeployments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{parent=projects/*}/patchDeployments", + 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, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser + .newBuilder() + .setDefaultInstance( + PatchDeployments.ListPatchDeploymentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deletePatchDeploymentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/DeletePatchDeployment") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{name=projects/*/patchDeployments/*}", + 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(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/UpdatePatchDeployment") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{patchDeployment.name=projects/*/patchDeployments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "patchDeployment.name", + request.getPatchDeployment().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("patchDeployment", request.getPatchDeployment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/PausePatchDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{name=projects/*/patchDeployments/*}:pause", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigService/ResumePatchDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1/{name=projects/*/patchDeployments/*}:resume", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + executePatchJobCallable; + private final UnaryCallable getPatchJobCallable; + private final UnaryCallable + cancelPatchJobCallable; + private final UnaryCallable + listPatchJobsCallable; + private final UnaryCallable + listPatchJobsPagedCallable; + private final UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsCallable; + private final UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, ListPatchJobInstanceDetailsPagedResponse> + listPatchJobInstanceDetailsPagedCallable; + private final UnaryCallable< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.GetPatchDeploymentRequest, PatchDeployments.PatchDeployment> + getPatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsCallable; + private final UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, ListPatchDeploymentsPagedResponse> + listPatchDeploymentsPagedCallable; + private final UnaryCallable + deletePatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonOsConfigServiceStub create(OsConfigServiceStubSettings settings) + throws IOException { + return new HttpJsonOsConfigServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonOsConfigServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonOsConfigServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonOsConfigServiceStub, 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 HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonOsConfigServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonOsConfigServiceStub, 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 HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + executePatchJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(executePatchJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getPatchJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getPatchJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + cancelPatchJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(cancelPatchJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listPatchJobsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listPatchJobsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listPatchJobInstanceDetailsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(createPatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.GetPatchDeploymentRequest, PatchDeployments.PatchDeployment> + getPatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(getPatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listPatchDeploymentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deletePatchDeploymentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deletePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(updatePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(pausePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(resumePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.executePatchJobCallable = + callableFactory.createUnaryCallable( + executePatchJobTransportSettings, settings.executePatchJobSettings(), clientContext); + this.getPatchJobCallable = + callableFactory.createUnaryCallable( + getPatchJobTransportSettings, settings.getPatchJobSettings(), clientContext); + this.cancelPatchJobCallable = + callableFactory.createUnaryCallable( + cancelPatchJobTransportSettings, settings.cancelPatchJobSettings(), clientContext); + this.listPatchJobsCallable = + callableFactory.createUnaryCallable( + listPatchJobsTransportSettings, settings.listPatchJobsSettings(), clientContext); + this.listPatchJobsPagedCallable = + callableFactory.createPagedCallable( + listPatchJobsTransportSettings, settings.listPatchJobsSettings(), clientContext); + this.listPatchJobInstanceDetailsCallable = + callableFactory.createUnaryCallable( + listPatchJobInstanceDetailsTransportSettings, + settings.listPatchJobInstanceDetailsSettings(), + clientContext); + this.listPatchJobInstanceDetailsPagedCallable = + callableFactory.createPagedCallable( + listPatchJobInstanceDetailsTransportSettings, + settings.listPatchJobInstanceDetailsSettings(), + clientContext); + this.createPatchDeploymentCallable = + callableFactory.createUnaryCallable( + createPatchDeploymentTransportSettings, + settings.createPatchDeploymentSettings(), + clientContext); + this.getPatchDeploymentCallable = + callableFactory.createUnaryCallable( + getPatchDeploymentTransportSettings, + settings.getPatchDeploymentSettings(), + clientContext); + this.listPatchDeploymentsCallable = + callableFactory.createUnaryCallable( + listPatchDeploymentsTransportSettings, + settings.listPatchDeploymentsSettings(), + clientContext); + this.listPatchDeploymentsPagedCallable = + callableFactory.createPagedCallable( + listPatchDeploymentsTransportSettings, + settings.listPatchDeploymentsSettings(), + clientContext); + this.deletePatchDeploymentCallable = + callableFactory.createUnaryCallable( + deletePatchDeploymentTransportSettings, + settings.deletePatchDeploymentSettings(), + clientContext); + this.updatePatchDeploymentCallable = + callableFactory.createUnaryCallable( + updatePatchDeploymentTransportSettings, + settings.updatePatchDeploymentSettings(), + clientContext); + this.pausePatchDeploymentCallable = + callableFactory.createUnaryCallable( + pausePatchDeploymentTransportSettings, + settings.pausePatchDeploymentSettings(), + clientContext); + this.resumePatchDeploymentCallable = + callableFactory.createUnaryCallable( + resumePatchDeploymentTransportSettings, + settings.resumePatchDeploymentSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(executePatchJobMethodDescriptor); + methodDescriptors.add(getPatchJobMethodDescriptor); + methodDescriptors.add(cancelPatchJobMethodDescriptor); + methodDescriptors.add(listPatchJobsMethodDescriptor); + methodDescriptors.add(listPatchJobInstanceDetailsMethodDescriptor); + methodDescriptors.add(createPatchDeploymentMethodDescriptor); + methodDescriptors.add(getPatchDeploymentMethodDescriptor); + methodDescriptors.add(listPatchDeploymentsMethodDescriptor); + methodDescriptors.add(deletePatchDeploymentMethodDescriptor); + methodDescriptors.add(updatePatchDeploymentMethodDescriptor); + methodDescriptors.add(pausePatchDeploymentMethodDescriptor); + methodDescriptors.add(resumePatchDeploymentMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + executePatchJobCallable() { + return executePatchJobCallable; + } + + @Override + public UnaryCallable getPatchJobCallable() { + return getPatchJobCallable; + } + + @Override + public UnaryCallable + cancelPatchJobCallable() { + return cancelPatchJobCallable; + } + + @Override + public UnaryCallable + listPatchJobsCallable() { + return listPatchJobsCallable; + } + + @Override + public UnaryCallable + listPatchJobsPagedCallable() { + return listPatchJobsPagedCallable; + } + + @Override + public UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsCallable() { + return listPatchJobInstanceDetailsCallable; + } + + @Override + public UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, ListPatchJobInstanceDetailsPagedResponse> + listPatchJobInstanceDetailsPagedCallable() { + return listPatchJobInstanceDetailsPagedCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentCallable() { + return createPatchDeploymentCallable; + } + + @Override + public UnaryCallable + getPatchDeploymentCallable() { + return getPatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsCallable() { + return listPatchDeploymentsCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, ListPatchDeploymentsPagedResponse> + listPatchDeploymentsPagedCallable() { + return listPatchDeploymentsPagedCallable; + } + + @Override + public UnaryCallable + deletePatchDeploymentCallable() { + return deletePatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentCallable() { + return updatePatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentCallable() { + return pausePatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentCallable() { + return resumePatchDeploymentCallable; + } + + @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-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigZonalServiceCallableFactory.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigZonalServiceCallableFactory.java new file mode 100644 index 00000000..d5b8ad33 --- /dev/null +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigZonalServiceCallableFactory.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.osconfig.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 OsConfigZonalService service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonOsConfigZonalServiceCallableFactory + 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-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigZonalServiceStub.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigZonalServiceStub.java new file mode 100644 index 00000000..dcb753e2 --- /dev/null +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/HttpJsonOsConfigZonalServiceStub.java @@ -0,0 +1,1004 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.stub; + +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListInventoriesPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListOSPolicyAssignmentReportsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListOSPolicyAssignmentRevisionsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListOSPolicyAssignmentsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListVulnerabilityReportsPagedResponse; + +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.osconfig.v1.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.GetInventoryRequest; +import com.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest; +import com.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.GetVulnerabilityReportRequest; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.ListInventoriesRequest; +import com.google.cloud.osconfig.v1.ListInventoriesResponse; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsResponse; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsResponse; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentsResponse; +import com.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1.ListVulnerabilityReportsResponse; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.VulnerabilityReport; +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 OsConfigZonalService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonOsConfigZonalServiceStub extends OsConfigZonalServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(OSPolicyAssignmentOperationMetadata.getDescriptor()) + .add(OSPolicyAssignment.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/CreateOSPolicyAssignment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/osPolicyAssignments", + 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, "osPolicyAssignmentId", request.getOsPolicyAssignmentId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("osPolicyAssignment", request.getOsPolicyAssignment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateOSPolicyAssignmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/UpdateOSPolicyAssignment") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{osPolicyAssignment.name=projects/*/locations/*/osPolicyAssignments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "osPolicyAssignment.name", + request.getOsPolicyAssignment().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("osPolicyAssignment", request.getOsPolicyAssignment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateOSPolicyAssignmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/GetOSPolicyAssignment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/osPolicyAssignments/*}", + 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(OSPolicyAssignment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListOSPolicyAssignmentsRequest, ListOSPolicyAssignmentsResponse> + listOSPolicyAssignmentsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/ListOSPolicyAssignments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/osPolicyAssignments", + 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, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListOSPolicyAssignmentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/ListOSPolicyAssignmentRevisions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/osPolicyAssignments/*}:listRevisions", + 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, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance( + ListOSPolicyAssignmentRevisionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/DeleteOSPolicyAssignment") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/osPolicyAssignments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteOSPolicyAssignmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor< + GetOSPolicyAssignmentReportRequest, OSPolicyAssignmentReport> + getOSPolicyAssignmentReportMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/GetOSPolicyAssignmentReport") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/instances/*/osPolicyAssignments/*/report}", + 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(OSPolicyAssignmentReport.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsResponse> + listOSPolicyAssignmentReportsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/ListOSPolicyAssignmentReports") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/instances/*/osPolicyAssignments/*}/reports", + 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( + ListOSPolicyAssignmentReportsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getInventoryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigZonalService/GetInventory") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/instances/*/inventory}", + 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, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Inventory.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1.OsConfigZonalService/ListInventories") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/instances/*}/inventories", + 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()); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListInventoriesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getVulnerabilityReportMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/GetVulnerabilityReport") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/instances/*/vulnerabilityReport}", + 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(VulnerabilityReport.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListVulnerabilityReportsRequest, ListVulnerabilityReportsResponse> + listVulnerabilityReportsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1.OsConfigZonalService/ListVulnerabilityReports") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*/instances/*}/vulnerabilityReports", + 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(ListVulnerabilityReportsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + createOSPolicyAssignmentCallable; + private final OperationCallable< + CreateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + createOSPolicyAssignmentOperationCallable; + private final UnaryCallable + updateOSPolicyAssignmentCallable; + private final OperationCallable< + UpdateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + updateOSPolicyAssignmentOperationCallable; + private final UnaryCallable + getOSPolicyAssignmentCallable; + private final UnaryCallable + listOSPolicyAssignmentsCallable; + private final UnaryCallable + listOSPolicyAssignmentsPagedCallable; + private final UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsCallable; + private final UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsPagedResponse> + listOSPolicyAssignmentRevisionsPagedCallable; + private final UnaryCallable + deleteOSPolicyAssignmentCallable; + private final OperationCallable< + DeleteOSPolicyAssignmentRequest, Empty, OSPolicyAssignmentOperationMetadata> + deleteOSPolicyAssignmentOperationCallable; + private final UnaryCallable + getOSPolicyAssignmentReportCallable; + private final UnaryCallable< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsResponse> + listOSPolicyAssignmentReportsCallable; + private final UnaryCallable< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsPagedResponse> + listOSPolicyAssignmentReportsPagedCallable; + private final UnaryCallable getInventoryCallable; + private final UnaryCallable + listInventoriesCallable; + private final UnaryCallable + listInventoriesPagedCallable; + private final UnaryCallable + getVulnerabilityReportCallable; + private final UnaryCallable + listVulnerabilityReportsCallable; + private final UnaryCallable< + ListVulnerabilityReportsRequest, ListVulnerabilityReportsPagedResponse> + listVulnerabilityReportsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonOsConfigZonalServiceStub create( + OsConfigZonalServiceStubSettings settings) throws IOException { + return new HttpJsonOsConfigZonalServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonOsConfigZonalServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonOsConfigZonalServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonOsConfigZonalServiceStub, 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 HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonOsConfigZonalServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonOsConfigZonalServiceStub, 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 HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + createOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listOSPolicyAssignmentsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listOSPolicyAssignmentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listOSPolicyAssignmentRevisionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getOSPolicyAssignmentReportTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(getOSPolicyAssignmentReportMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsResponse> + listOSPolicyAssignmentReportsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listOSPolicyAssignmentReportsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getInventoryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInventoryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getVulnerabilityReportTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getVulnerabilityReportMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listVulnerabilityReportsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listVulnerabilityReportsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + createOSPolicyAssignmentTransportSettings, + settings.createOSPolicyAssignmentSettings(), + clientContext); + this.createOSPolicyAssignmentOperationCallable = + callableFactory.createOperationCallable( + createOSPolicyAssignmentTransportSettings, + settings.createOSPolicyAssignmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + updateOSPolicyAssignmentTransportSettings, + settings.updateOSPolicyAssignmentSettings(), + clientContext); + this.updateOSPolicyAssignmentOperationCallable = + callableFactory.createOperationCallable( + updateOSPolicyAssignmentTransportSettings, + settings.updateOSPolicyAssignmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + getOSPolicyAssignmentTransportSettings, + settings.getOSPolicyAssignmentSettings(), + clientContext); + this.listOSPolicyAssignmentsCallable = + callableFactory.createUnaryCallable( + listOSPolicyAssignmentsTransportSettings, + settings.listOSPolicyAssignmentsSettings(), + clientContext); + this.listOSPolicyAssignmentsPagedCallable = + callableFactory.createPagedCallable( + listOSPolicyAssignmentsTransportSettings, + settings.listOSPolicyAssignmentsSettings(), + clientContext); + this.listOSPolicyAssignmentRevisionsCallable = + callableFactory.createUnaryCallable( + listOSPolicyAssignmentRevisionsTransportSettings, + settings.listOSPolicyAssignmentRevisionsSettings(), + clientContext); + this.listOSPolicyAssignmentRevisionsPagedCallable = + callableFactory.createPagedCallable( + listOSPolicyAssignmentRevisionsTransportSettings, + settings.listOSPolicyAssignmentRevisionsSettings(), + clientContext); + this.deleteOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + deleteOSPolicyAssignmentTransportSettings, + settings.deleteOSPolicyAssignmentSettings(), + clientContext); + this.deleteOSPolicyAssignmentOperationCallable = + callableFactory.createOperationCallable( + deleteOSPolicyAssignmentTransportSettings, + settings.deleteOSPolicyAssignmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getOSPolicyAssignmentReportCallable = + callableFactory.createUnaryCallable( + getOSPolicyAssignmentReportTransportSettings, + settings.getOSPolicyAssignmentReportSettings(), + clientContext); + this.listOSPolicyAssignmentReportsCallable = + callableFactory.createUnaryCallable( + listOSPolicyAssignmentReportsTransportSettings, + settings.listOSPolicyAssignmentReportsSettings(), + clientContext); + this.listOSPolicyAssignmentReportsPagedCallable = + callableFactory.createPagedCallable( + listOSPolicyAssignmentReportsTransportSettings, + settings.listOSPolicyAssignmentReportsSettings(), + clientContext); + this.getInventoryCallable = + callableFactory.createUnaryCallable( + getInventoryTransportSettings, settings.getInventorySettings(), clientContext); + this.listInventoriesCallable = + callableFactory.createUnaryCallable( + listInventoriesTransportSettings, settings.listInventoriesSettings(), clientContext); + this.listInventoriesPagedCallable = + callableFactory.createPagedCallable( + listInventoriesTransportSettings, settings.listInventoriesSettings(), clientContext); + this.getVulnerabilityReportCallable = + callableFactory.createUnaryCallable( + getVulnerabilityReportTransportSettings, + settings.getVulnerabilityReportSettings(), + clientContext); + this.listVulnerabilityReportsCallable = + callableFactory.createUnaryCallable( + listVulnerabilityReportsTransportSettings, + settings.listVulnerabilityReportsSettings(), + clientContext); + this.listVulnerabilityReportsPagedCallable = + callableFactory.createPagedCallable( + listVulnerabilityReportsTransportSettings, + settings.listVulnerabilityReportsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(updateOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(getOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(listOSPolicyAssignmentsMethodDescriptor); + methodDescriptors.add(listOSPolicyAssignmentRevisionsMethodDescriptor); + methodDescriptors.add(deleteOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(getOSPolicyAssignmentReportMethodDescriptor); + methodDescriptors.add(listOSPolicyAssignmentReportsMethodDescriptor); + methodDescriptors.add(getInventoryMethodDescriptor); + methodDescriptors.add(listInventoriesMethodDescriptor); + methodDescriptors.add(getVulnerabilityReportMethodDescriptor); + methodDescriptors.add(listVulnerabilityReportsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + createOSPolicyAssignmentCallable() { + return createOSPolicyAssignmentCallable; + } + + @Override + public OperationCallable< + CreateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + createOSPolicyAssignmentOperationCallable() { + return createOSPolicyAssignmentOperationCallable; + } + + @Override + public UnaryCallable + updateOSPolicyAssignmentCallable() { + return updateOSPolicyAssignmentCallable; + } + + @Override + public OperationCallable< + UpdateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + updateOSPolicyAssignmentOperationCallable() { + return updateOSPolicyAssignmentOperationCallable; + } + + @Override + public UnaryCallable + getOSPolicyAssignmentCallable() { + return getOSPolicyAssignmentCallable; + } + + @Override + public UnaryCallable + listOSPolicyAssignmentsCallable() { + return listOSPolicyAssignmentsCallable; + } + + @Override + public UnaryCallable + listOSPolicyAssignmentsPagedCallable() { + return listOSPolicyAssignmentsPagedCallable; + } + + @Override + public UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsCallable() { + return listOSPolicyAssignmentRevisionsCallable; + } + + @Override + public UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsPagedResponse> + listOSPolicyAssignmentRevisionsPagedCallable() { + return listOSPolicyAssignmentRevisionsPagedCallable; + } + + @Override + public UnaryCallable + deleteOSPolicyAssignmentCallable() { + return deleteOSPolicyAssignmentCallable; + } + + @Override + public OperationCallable< + DeleteOSPolicyAssignmentRequest, Empty, OSPolicyAssignmentOperationMetadata> + deleteOSPolicyAssignmentOperationCallable() { + return deleteOSPolicyAssignmentOperationCallable; + } + + @Override + public UnaryCallable + getOSPolicyAssignmentReportCallable() { + return getOSPolicyAssignmentReportCallable; + } + + @Override + public UnaryCallable + listOSPolicyAssignmentReportsCallable() { + return listOSPolicyAssignmentReportsCallable; + } + + @Override + public UnaryCallable< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsPagedResponse> + listOSPolicyAssignmentReportsPagedCallable() { + return listOSPolicyAssignmentReportsPagedCallable; + } + + @Override + public UnaryCallable getInventoryCallable() { + return getInventoryCallable; + } + + @Override + public UnaryCallable listInventoriesCallable() { + return listInventoriesCallable; + } + + @Override + public UnaryCallable + listInventoriesPagedCallable() { + return listInventoriesPagedCallable; + } + + @Override + public UnaryCallable + getVulnerabilityReportCallable() { + return getVulnerabilityReportCallable; + } + + @Override + public UnaryCallable + listVulnerabilityReportsCallable() { + return listVulnerabilityReportsCallable; + } + + @Override + public UnaryCallable + listVulnerabilityReportsPagedCallable() { + return listVulnerabilityReportsPagedCallable; + } + + @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-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigServiceStubSettings.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigServiceStubSettings.java index f0cc2542..b3bc7fbe 100644 --- a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigServiceStubSettings.java +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigServiceStubSettings.java @@ -29,6 +29,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +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.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -449,13 +452,17 @@ public UnaryCallSettings getPa return resumePatchDeploymentSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public OsConfigServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcOsConfigServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonOsConfigServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -488,18 +495,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(OsConfigServiceStubSettings.class)) @@ -507,11 +521,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(OsConfigServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return OsConfigServiceStubSettings.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); @@ -697,6 +730,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 .executePatchJobSettings() diff --git a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStub.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStub.java index 9a2a1ba7..5ea80e63 100644 --- a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStub.java +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStub.java @@ -62,7 +62,11 @@ public abstract class OsConfigZonalServiceStub 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-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStubSettings.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStubSettings.java index cd142873..d424cef3 100644 --- a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStubSettings.java +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1/stub/OsConfigZonalServiceStubSettings.java @@ -32,6 +32,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; @@ -639,13 +642,17 @@ public UnaryCallSettings getInventorySettings() return listVulnerabilityReportsSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public OsConfigZonalServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcOsConfigZonalServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonOsConfigZonalServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -678,18 +685,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(OsConfigZonalServiceStubSettings.class)) @@ -697,11 +711,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(OsConfigZonalServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return OsConfigZonalServiceStubSettings.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); @@ -921,6 +954,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 .createOSPolicyAssignmentSettings() diff --git a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClient.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClient.java index aedc2cdf..1ece1f25 100644 --- a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClient.java +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClient.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.osconfig.v1alpha.stub.OsConfigZonalServiceStubSettings; 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; @@ -111,6 +111,21 @@ * OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); * } * + *

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.
+ * OsConfigZonalServiceSettings osConfigZonalServiceSettings =
+ *     OsConfigZonalServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             OsConfigZonalServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * OsConfigZonalServiceClient osConfigZonalServiceClient =
+ *     OsConfigZonalServiceClient.create(osConfigZonalServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -118,7 +133,8 @@ public class OsConfigZonalServiceClient implements BackgroundResource { private final OsConfigZonalServiceSettings settings; private final OsConfigZonalServiceStub stub; - private final OperationsClient operationsClient; + private final OperationsClient httpJsonOperationsClient; + private final com.google.longrunning.OperationsClient operationsClient; /** Constructs an instance of OsConfigZonalServiceClient with default settings. */ public static final OsConfigZonalServiceClient create() throws IOException { @@ -138,7 +154,6 @@ public static final OsConfigZonalServiceClient create(OsConfigZonalServiceSettin * Constructs an instance of OsConfigZonalServiceClient, using the given stub for making calls. * This is for advanced usage - prefer using create(OsConfigZonalServiceSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final OsConfigZonalServiceClient create(OsConfigZonalServiceStub stub) { return new OsConfigZonalServiceClient(stub); } @@ -151,21 +166,23 @@ public static final OsConfigZonalServiceClient create(OsConfigZonalServiceStub s protected OsConfigZonalServiceClient(OsConfigZonalServiceSettings settings) throws IOException { this.settings = settings; this.stub = ((OsConfigZonalServiceStubSettings) settings.getStubSettings()).createStub(); - this.operationsClient = OperationsClient.create(this.stub.getOperationsStub()); + this.operationsClient = + com.google.longrunning.OperationsClient.create(this.stub.getOperationsStub()); + this.httpJsonOperationsClient = OperationsClient.create(this.stub.getHttpJsonOperationsStub()); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected OsConfigZonalServiceClient(OsConfigZonalServiceStub 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 OsConfigZonalServiceSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public OsConfigZonalServiceStub getStub() { return stub; } @@ -174,10 +191,19 @@ public OsConfigZonalServiceStub getStub() { * Returns the OperationsClient that can be used to query the status of a long-running operation * returned by another API method call. */ - public final OperationsClient getOperationsClient() { + public final com.google.longrunning.OperationsClient getOperationsClient() { return operationsClient; } + /** + * Returns the OperationsClient that can be used to query the status of a long-running operation + * returned by another API method call. + */ + @BetaApi + public final OperationsClient getHttpJsonOperationsClient() { + return httpJsonOperationsClient; + } + // AUTO-GENERATED DOCUMENTATION AND METHOD. /** * Create an OS policy assignment. @@ -838,7 +864,7 @@ public final ListOSPolicyAssignmentsPagedResponse listOSPolicyAssignments( * while (true) { * ListOSPolicyAssignmentsResponse response = * osConfigZonalServiceClient.listOSPolicyAssignmentsCallable().call(request); - * for (OSPolicyAssignment element : response.getResponsesList()) { + * for (OSPolicyAssignment element : response.getOsPolicyAssignmentsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1010,7 +1036,7 @@ public final ListOSPolicyAssignmentRevisionsPagedResponse listOSPolicyAssignment * while (true) { * ListOSPolicyAssignmentRevisionsResponse response = * osConfigZonalServiceClient.listOSPolicyAssignmentRevisionsCallable().call(request); - * for (OSPolicyAssignment element : response.getResponsesList()) { + * for (OSPolicyAssignment element : response.getOsPolicyAssignmentsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1525,7 +1551,8 @@ public final ListInstanceOSPoliciesCompliancesPagedResponse listInstanceOSPolici * while (true) { * ListInstanceOSPoliciesCompliancesResponse response = * osConfigZonalServiceClient.listInstanceOSPoliciesCompliancesCallable().call(request); - * for (InstanceOSPoliciesCompliance element : response.getResponsesList()) { + * for (InstanceOSPoliciesCompliance element : + * response.getInstanceOsPoliciesCompliancesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1868,7 +1895,7 @@ public final ListOSPolicyAssignmentReportsPagedResponse listOSPolicyAssignmentRe * while (true) { * ListOSPolicyAssignmentReportsResponse response = * osConfigZonalServiceClient.listOSPolicyAssignmentReportsCallable().call(request); - * for (OSPolicyAssignmentReport element : response.getResponsesList()) { + * for (OSPolicyAssignmentReport element : response.getOsPolicyAssignmentReportsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2146,7 +2173,7 @@ public final ListInventoriesPagedResponse listInventories(ListInventoriesRequest * while (true) { * ListInventoriesResponse response = * osConfigZonalServiceClient.listInventoriesCallable().call(request); - * for (Inventory element : response.getResponsesList()) { + * for (Inventory element : response.getInventoriesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -2432,7 +2459,7 @@ public final ListVulnerabilityReportsPagedResponse listVulnerabilityReports( * while (true) { * ListVulnerabilityReportsResponse response = * osConfigZonalServiceClient.listVulnerabilityReportsCallable().call(request); - * for (VulnerabilityReport element : response.getResponsesList()) { + * for (VulnerabilityReport element : response.getVulnerabilityReportsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceSettings.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceSettings.java index 6104e552..6fab56d7 100644 --- a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceSettings.java +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceSettings.java @@ -28,6 +28,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -248,11 +249,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return OsConfigZonalServiceStubSettings.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 OsConfigZonalServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return OsConfigZonalServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return OsConfigZonalServiceStubSettings.defaultTransportChannelProvider(); } @@ -262,11 +270,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return OsConfigZonalServiceStubSettings.defaultApiClientHeaderProviderBuilder(); } - /** Returns a new builder for this class. */ + /** Returns a new gRPC builder for this class. */ public static Builder newBuilder() { return Builder.createDefault(); } + /** Returns a new REST builder for this class. */ + @BetaApi + public static Builder newHttpJsonBuilder() { + return Builder.createHttpJsonDefault(); + } + /** Returns a new builder for this class. */ public static Builder newBuilder(ClientContext clientContext) { return new Builder(clientContext); @@ -305,6 +319,11 @@ private static Builder createDefault() { return new Builder(OsConfigZonalServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(OsConfigZonalServiceStubSettings.newHttpJsonBuilder()); + } + public OsConfigZonalServiceStubSettings.Builder getStubSettingsBuilder() { return ((OsConfigZonalServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/HttpJsonOsConfigZonalServiceCallableFactory.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/HttpJsonOsConfigZonalServiceCallableFactory.java new file mode 100644 index 00000000..3713cf21 --- /dev/null +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/HttpJsonOsConfigZonalServiceCallableFactory.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.osconfig.v1alpha.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 OsConfigZonalService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonOsConfigZonalServiceCallableFactory + 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-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/HttpJsonOsConfigZonalServiceStub.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/HttpJsonOsConfigZonalServiceStub.java new file mode 100644 index 00000000..31ff24fd --- /dev/null +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/HttpJsonOsConfigZonalServiceStub.java @@ -0,0 +1,1150 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.stub; + +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListInstanceOSPoliciesCompliancesPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListInventoriesPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignmentReportsPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignmentRevisionsPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignmentsPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListVulnerabilityReportsPagedResponse; + +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.osconfig.v1alpha.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest; +import com.google.cloud.osconfig.v1alpha.GetInventoryRequest; +import com.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest; +import com.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest; +import com.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesResponse; +import com.google.cloud.osconfig.v1alpha.ListInventoriesRequest; +import com.google.cloud.osconfig.v1alpha.ListInventoriesResponse; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsResponse; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsResponse; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsResponse; +import com.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsResponse; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; +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 OsConfigZonalService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonOsConfigZonalServiceStub extends OsConfigZonalServiceStub { + private static final TypeRegistry typeRegistry = + TypeRegistry.newBuilder() + .add(Empty.getDescriptor()) + .add(OSPolicyAssignmentOperationMetadata.getDescriptor()) + .add(OSPolicyAssignment.getDescriptor()) + .build(); + + private static final ApiMethodDescriptor + createOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/CreateOSPolicyAssignment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*}/osPolicyAssignments", + 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, "osPolicyAssignmentId", request.getOsPolicyAssignmentId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("osPolicyAssignment", request.getOsPolicyAssignment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (CreateOSPolicyAssignmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + updateOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/UpdateOSPolicyAssignment") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{osPolicyAssignment.name=projects/*/locations/*/osPolicyAssignments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "osPolicyAssignment.name", + request.getOsPolicyAssignment().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("osPolicyAssignment", request.getOsPolicyAssignment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (UpdateOSPolicyAssignmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor + getOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/GetOSPolicyAssignment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*}", + 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(OSPolicyAssignment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListOSPolicyAssignmentsRequest, ListOSPolicyAssignmentsResponse> + listOSPolicyAssignmentsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/ListOSPolicyAssignments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*}/osPolicyAssignments", + 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, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListOSPolicyAssignmentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/ListOSPolicyAssignmentRevisions") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*}:listRevisions", + 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, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance( + ListOSPolicyAssignmentRevisionsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteOSPolicyAssignmentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/DeleteOSPolicyAssignment") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/osPolicyAssignments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Operation.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .setOperationSnapshotFactory( + (DeleteOSPolicyAssignmentRequest request, Operation response) -> + HttpJsonOperationSnapshot.create(response)) + .build(); + + private static final ApiMethodDescriptor< + GetInstanceOSPoliciesComplianceRequest, InstanceOSPoliciesCompliance> + getInstanceOSPoliciesComplianceMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/GetInstanceOSPoliciesCompliance") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/instanceOSPoliciesCompliances/*}", + 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(InstanceOSPoliciesCompliance.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListInstanceOSPoliciesCompliancesRequest, ListInstanceOSPoliciesCompliancesResponse> + listInstanceOSPoliciesCompliancesMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/ListInstanceOSPoliciesCompliances") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*}/instanceOSPoliciesCompliances", + 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( + ListInstanceOSPoliciesCompliancesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + GetOSPolicyAssignmentReportRequest, OSPolicyAssignmentReport> + getOSPolicyAssignmentReportMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/GetOSPolicyAssignmentReport") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/instances/*/osPolicyAssignments/*/report}", + 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(OSPolicyAssignmentReport.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsResponse> + listOSPolicyAssignmentReportsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/ListOSPolicyAssignmentReports") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*/instances/*/osPolicyAssignments/*}/reports", + 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( + ListOSPolicyAssignmentReportsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getInventoryMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1alpha.OsConfigZonalService/GetInventory") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/instances/*/inventory}", + 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, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Inventory.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + listInventoriesMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/ListInventories") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*/instances/*}/inventories", + 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()); + serializer.putQueryParam(fields, "view", request.getView()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(ListInventoriesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getVulnerabilityReportMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/GetVulnerabilityReport") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{name=projects/*/locations/*/instances/*/vulnerabilityReport}", + 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(VulnerabilityReport.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + ListVulnerabilityReportsRequest, ListVulnerabilityReportsResponse> + listVulnerabilityReportsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1alpha.OsConfigZonalService/ListVulnerabilityReports") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1alpha/{parent=projects/*/locations/*/instances/*}/vulnerabilityReports", + 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(ListVulnerabilityReportsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + createOSPolicyAssignmentCallable; + private final OperationCallable< + CreateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + createOSPolicyAssignmentOperationCallable; + private final UnaryCallable + updateOSPolicyAssignmentCallable; + private final OperationCallable< + UpdateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + updateOSPolicyAssignmentOperationCallable; + private final UnaryCallable + getOSPolicyAssignmentCallable; + private final UnaryCallable + listOSPolicyAssignmentsCallable; + private final UnaryCallable + listOSPolicyAssignmentsPagedCallable; + private final UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsCallable; + private final UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsPagedResponse> + listOSPolicyAssignmentRevisionsPagedCallable; + private final UnaryCallable + deleteOSPolicyAssignmentCallable; + private final OperationCallable< + DeleteOSPolicyAssignmentRequest, Empty, OSPolicyAssignmentOperationMetadata> + deleteOSPolicyAssignmentOperationCallable; + private final UnaryCallable + getInstanceOSPoliciesComplianceCallable; + private final UnaryCallable< + ListInstanceOSPoliciesCompliancesRequest, ListInstanceOSPoliciesCompliancesResponse> + listInstanceOSPoliciesCompliancesCallable; + private final UnaryCallable< + ListInstanceOSPoliciesCompliancesRequest, ListInstanceOSPoliciesCompliancesPagedResponse> + listInstanceOSPoliciesCompliancesPagedCallable; + private final UnaryCallable + getOSPolicyAssignmentReportCallable; + private final UnaryCallable< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsResponse> + listOSPolicyAssignmentReportsCallable; + private final UnaryCallable< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsPagedResponse> + listOSPolicyAssignmentReportsPagedCallable; + private final UnaryCallable getInventoryCallable; + private final UnaryCallable + listInventoriesCallable; + private final UnaryCallable + listInventoriesPagedCallable; + private final UnaryCallable + getVulnerabilityReportCallable; + private final UnaryCallable + listVulnerabilityReportsCallable; + private final UnaryCallable< + ListVulnerabilityReportsRequest, ListVulnerabilityReportsPagedResponse> + listVulnerabilityReportsPagedCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonOperationsStub httpJsonOperationsStub; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonOsConfigZonalServiceStub create( + OsConfigZonalServiceStubSettings settings) throws IOException { + return new HttpJsonOsConfigZonalServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonOsConfigZonalServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonOsConfigZonalServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings.newHttpJsonBuilder().build(), + clientContext, + callableFactory); + } + + /** + * Constructs an instance of HttpJsonOsConfigZonalServiceStub, 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 HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonOsConfigZonalServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonOsConfigZonalServiceStub, 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 HttpJsonOsConfigZonalServiceStub( + OsConfigZonalServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + this.httpJsonOperationsStub = + HttpJsonOperationsStub.create(clientContext, callableFactory, typeRegistry); + + HttpJsonCallSettings + createOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listOSPolicyAssignmentsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listOSPolicyAssignmentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listOSPolicyAssignmentRevisionsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteOSPolicyAssignmentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteOSPolicyAssignmentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getInstanceOSPoliciesComplianceTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(getInstanceOSPoliciesComplianceMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + ListInstanceOSPoliciesCompliancesRequest, ListInstanceOSPoliciesCompliancesResponse> + listInstanceOSPoliciesCompliancesTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listInstanceOSPoliciesCompliancesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getOSPolicyAssignmentReportTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(getOSPolicyAssignmentReportMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsResponse> + listOSPolicyAssignmentReportsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listOSPolicyAssignmentReportsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getInventoryTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getInventoryMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listInventoriesTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listInventoriesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getVulnerabilityReportTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getVulnerabilityReportMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listVulnerabilityReportsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listVulnerabilityReportsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.createOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + createOSPolicyAssignmentTransportSettings, + settings.createOSPolicyAssignmentSettings(), + clientContext); + this.createOSPolicyAssignmentOperationCallable = + callableFactory.createOperationCallable( + createOSPolicyAssignmentTransportSettings, + settings.createOSPolicyAssignmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.updateOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + updateOSPolicyAssignmentTransportSettings, + settings.updateOSPolicyAssignmentSettings(), + clientContext); + this.updateOSPolicyAssignmentOperationCallable = + callableFactory.createOperationCallable( + updateOSPolicyAssignmentTransportSettings, + settings.updateOSPolicyAssignmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + getOSPolicyAssignmentTransportSettings, + settings.getOSPolicyAssignmentSettings(), + clientContext); + this.listOSPolicyAssignmentsCallable = + callableFactory.createUnaryCallable( + listOSPolicyAssignmentsTransportSettings, + settings.listOSPolicyAssignmentsSettings(), + clientContext); + this.listOSPolicyAssignmentsPagedCallable = + callableFactory.createPagedCallable( + listOSPolicyAssignmentsTransportSettings, + settings.listOSPolicyAssignmentsSettings(), + clientContext); + this.listOSPolicyAssignmentRevisionsCallable = + callableFactory.createUnaryCallable( + listOSPolicyAssignmentRevisionsTransportSettings, + settings.listOSPolicyAssignmentRevisionsSettings(), + clientContext); + this.listOSPolicyAssignmentRevisionsPagedCallable = + callableFactory.createPagedCallable( + listOSPolicyAssignmentRevisionsTransportSettings, + settings.listOSPolicyAssignmentRevisionsSettings(), + clientContext); + this.deleteOSPolicyAssignmentCallable = + callableFactory.createUnaryCallable( + deleteOSPolicyAssignmentTransportSettings, + settings.deleteOSPolicyAssignmentSettings(), + clientContext); + this.deleteOSPolicyAssignmentOperationCallable = + callableFactory.createOperationCallable( + deleteOSPolicyAssignmentTransportSettings, + settings.deleteOSPolicyAssignmentOperationSettings(), + clientContext, + httpJsonOperationsStub); + this.getInstanceOSPoliciesComplianceCallable = + callableFactory.createUnaryCallable( + getInstanceOSPoliciesComplianceTransportSettings, + settings.getInstanceOSPoliciesComplianceSettings(), + clientContext); + this.listInstanceOSPoliciesCompliancesCallable = + callableFactory.createUnaryCallable( + listInstanceOSPoliciesCompliancesTransportSettings, + settings.listInstanceOSPoliciesCompliancesSettings(), + clientContext); + this.listInstanceOSPoliciesCompliancesPagedCallable = + callableFactory.createPagedCallable( + listInstanceOSPoliciesCompliancesTransportSettings, + settings.listInstanceOSPoliciesCompliancesSettings(), + clientContext); + this.getOSPolicyAssignmentReportCallable = + callableFactory.createUnaryCallable( + getOSPolicyAssignmentReportTransportSettings, + settings.getOSPolicyAssignmentReportSettings(), + clientContext); + this.listOSPolicyAssignmentReportsCallable = + callableFactory.createUnaryCallable( + listOSPolicyAssignmentReportsTransportSettings, + settings.listOSPolicyAssignmentReportsSettings(), + clientContext); + this.listOSPolicyAssignmentReportsPagedCallable = + callableFactory.createPagedCallable( + listOSPolicyAssignmentReportsTransportSettings, + settings.listOSPolicyAssignmentReportsSettings(), + clientContext); + this.getInventoryCallable = + callableFactory.createUnaryCallable( + getInventoryTransportSettings, settings.getInventorySettings(), clientContext); + this.listInventoriesCallable = + callableFactory.createUnaryCallable( + listInventoriesTransportSettings, settings.listInventoriesSettings(), clientContext); + this.listInventoriesPagedCallable = + callableFactory.createPagedCallable( + listInventoriesTransportSettings, settings.listInventoriesSettings(), clientContext); + this.getVulnerabilityReportCallable = + callableFactory.createUnaryCallable( + getVulnerabilityReportTransportSettings, + settings.getVulnerabilityReportSettings(), + clientContext); + this.listVulnerabilityReportsCallable = + callableFactory.createUnaryCallable( + listVulnerabilityReportsTransportSettings, + settings.listVulnerabilityReportsSettings(), + clientContext); + this.listVulnerabilityReportsPagedCallable = + callableFactory.createPagedCallable( + listVulnerabilityReportsTransportSettings, + settings.listVulnerabilityReportsSettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(createOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(updateOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(getOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(listOSPolicyAssignmentsMethodDescriptor); + methodDescriptors.add(listOSPolicyAssignmentRevisionsMethodDescriptor); + methodDescriptors.add(deleteOSPolicyAssignmentMethodDescriptor); + methodDescriptors.add(getInstanceOSPoliciesComplianceMethodDescriptor); + methodDescriptors.add(listInstanceOSPoliciesCompliancesMethodDescriptor); + methodDescriptors.add(getOSPolicyAssignmentReportMethodDescriptor); + methodDescriptors.add(listOSPolicyAssignmentReportsMethodDescriptor); + methodDescriptors.add(getInventoryMethodDescriptor); + methodDescriptors.add(listInventoriesMethodDescriptor); + methodDescriptors.add(getVulnerabilityReportMethodDescriptor); + methodDescriptors.add(listVulnerabilityReportsMethodDescriptor); + return methodDescriptors; + } + + public HttpJsonOperationsStub getHttpJsonOperationsStub() { + return httpJsonOperationsStub; + } + + @Override + public UnaryCallable + createOSPolicyAssignmentCallable() { + return createOSPolicyAssignmentCallable; + } + + @Override + public OperationCallable< + CreateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + createOSPolicyAssignmentOperationCallable() { + return createOSPolicyAssignmentOperationCallable; + } + + @Override + public UnaryCallable + updateOSPolicyAssignmentCallable() { + return updateOSPolicyAssignmentCallable; + } + + @Override + public OperationCallable< + UpdateOSPolicyAssignmentRequest, OSPolicyAssignment, OSPolicyAssignmentOperationMetadata> + updateOSPolicyAssignmentOperationCallable() { + return updateOSPolicyAssignmentOperationCallable; + } + + @Override + public UnaryCallable + getOSPolicyAssignmentCallable() { + return getOSPolicyAssignmentCallable; + } + + @Override + public UnaryCallable + listOSPolicyAssignmentsCallable() { + return listOSPolicyAssignmentsCallable; + } + + @Override + public UnaryCallable + listOSPolicyAssignmentsPagedCallable() { + return listOSPolicyAssignmentsPagedCallable; + } + + @Override + public UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsResponse> + listOSPolicyAssignmentRevisionsCallable() { + return listOSPolicyAssignmentRevisionsCallable; + } + + @Override + public UnaryCallable< + ListOSPolicyAssignmentRevisionsRequest, ListOSPolicyAssignmentRevisionsPagedResponse> + listOSPolicyAssignmentRevisionsPagedCallable() { + return listOSPolicyAssignmentRevisionsPagedCallable; + } + + @Override + public UnaryCallable + deleteOSPolicyAssignmentCallable() { + return deleteOSPolicyAssignmentCallable; + } + + @Override + public OperationCallable< + DeleteOSPolicyAssignmentRequest, Empty, OSPolicyAssignmentOperationMetadata> + deleteOSPolicyAssignmentOperationCallable() { + return deleteOSPolicyAssignmentOperationCallable; + } + + @Override + public UnaryCallable + getInstanceOSPoliciesComplianceCallable() { + return getInstanceOSPoliciesComplianceCallable; + } + + @Override + public UnaryCallable< + ListInstanceOSPoliciesCompliancesRequest, ListInstanceOSPoliciesCompliancesResponse> + listInstanceOSPoliciesCompliancesCallable() { + return listInstanceOSPoliciesCompliancesCallable; + } + + @Override + public UnaryCallable< + ListInstanceOSPoliciesCompliancesRequest, ListInstanceOSPoliciesCompliancesPagedResponse> + listInstanceOSPoliciesCompliancesPagedCallable() { + return listInstanceOSPoliciesCompliancesPagedCallable; + } + + @Override + public UnaryCallable + getOSPolicyAssignmentReportCallable() { + return getOSPolicyAssignmentReportCallable; + } + + @Override + public UnaryCallable + listOSPolicyAssignmentReportsCallable() { + return listOSPolicyAssignmentReportsCallable; + } + + @Override + public UnaryCallable< + ListOSPolicyAssignmentReportsRequest, ListOSPolicyAssignmentReportsPagedResponse> + listOSPolicyAssignmentReportsPagedCallable() { + return listOSPolicyAssignmentReportsPagedCallable; + } + + @Override + public UnaryCallable getInventoryCallable() { + return getInventoryCallable; + } + + @Override + public UnaryCallable listInventoriesCallable() { + return listInventoriesCallable; + } + + @Override + public UnaryCallable + listInventoriesPagedCallable() { + return listInventoriesPagedCallable; + } + + @Override + public UnaryCallable + getVulnerabilityReportCallable() { + return getVulnerabilityReportCallable; + } + + @Override + public UnaryCallable + listVulnerabilityReportsCallable() { + return listVulnerabilityReportsCallable; + } + + @Override + public UnaryCallable + listVulnerabilityReportsPagedCallable() { + return listVulnerabilityReportsPagedCallable; + } + + @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-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStub.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStub.java index adf31c79..62b2aebe 100644 --- a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStub.java +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStub.java @@ -69,7 +69,11 @@ public abstract class OsConfigZonalServiceStub 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-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStubSettings.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStubSettings.java index 10d76ffa..02d35ba7 100644 --- a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStubSettings.java +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1alpha/stub/OsConfigZonalServiceStubSettings.java @@ -33,6 +33,9 @@ import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; import com.google.api.gax.grpc.ProtoOperationTransformers; +import com.google.api.gax.httpjson.GaxHttpJsonProperties; +import com.google.api.gax.httpjson.HttpJsonTransportChannel; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.longrunning.OperationSnapshot; import com.google.api.gax.longrunning.OperationTimedPollAlgorithm; import com.google.api.gax.retrying.RetrySettings; @@ -760,13 +763,17 @@ public UnaryCallSettings getInventorySettings() return listVulnerabilityReportsSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public OsConfigZonalServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcOsConfigZonalServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonOsConfigZonalServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -799,18 +806,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(OsConfigZonalServiceStubSettings.class)) @@ -818,11 +832,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(OsConfigZonalServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return OsConfigZonalServiceStubSettings.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); @@ -1065,6 +1098,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 .createOSPolicyAssignmentSettings() diff --git a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClient.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClient.java index 37109aa1..bbf2fb0e 100644 --- a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClient.java +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClient.java @@ -115,6 +115,21 @@ * OsConfigServiceClient.create(osConfigServiceSettings); * } * + *

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.
+ * OsConfigServiceSettings osConfigServiceSettings =
+ *     OsConfigServiceSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             OsConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * OsConfigServiceClient osConfigServiceClient =
+ *     OsConfigServiceClient.create(osConfigServiceSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -141,7 +156,6 @@ public static final OsConfigServiceClient create(OsConfigServiceSettings setting * Constructs an instance of OsConfigServiceClient, using the given stub for making calls. This is * for advanced usage - prefer using create(OsConfigServiceSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final OsConfigServiceClient create(OsConfigServiceStub stub) { return new OsConfigServiceClient(stub); } @@ -156,7 +170,6 @@ protected OsConfigServiceClient(OsConfigServiceSettings settings) throws IOExcep this.stub = ((OsConfigServiceStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected OsConfigServiceClient(OsConfigServiceStub stub) { this.settings = null; this.stub = stub; @@ -166,7 +179,6 @@ public final OsConfigServiceSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public OsConfigServiceStub getStub() { return stub; } @@ -413,7 +425,7 @@ public final ListPatchJobsPagedResponse listPatchJobs(PatchJobs.ListPatchJobsReq * while (true) { * PatchJobs.ListPatchJobsResponse response = * osConfigServiceClient.listPatchJobsCallable().call(request); - * for (PatchJobs.PatchJob element : response.getResponsesList()) { + * for (PatchJobs.PatchJob element : response.getPatchJobsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -543,7 +555,8 @@ public final ListPatchJobInstanceDetailsPagedResponse listPatchJobInstanceDetail * while (true) { * PatchJobs.ListPatchJobInstanceDetailsResponse response = * osConfigServiceClient.listPatchJobInstanceDetailsCallable().call(request); - * for (PatchJobs.PatchJobInstanceDetails element : response.getResponsesList()) { + * for (PatchJobs.PatchJobInstanceDetails element : + * response.getPatchJobInstanceDetailsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -751,7 +764,7 @@ public final ListPatchDeploymentsPagedResponse listPatchDeployments( * while (true) { * PatchDeployments.ListPatchDeploymentsResponse response = * osConfigServiceClient.listPatchDeploymentsCallable().call(request); - * for (PatchDeployments.PatchDeployment element : response.getResponsesList()) { + * for (PatchDeployments.PatchDeployment element : response.getPatchDeploymentsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); @@ -1489,7 +1502,7 @@ public final ListGuestPoliciesPagedResponse listGuestPolicies( * while (true) { * GuestPolicies.ListGuestPoliciesResponse response = * osConfigServiceClient.listGuestPoliciesCallable().call(request); - * for (GuestPolicies.GuestPolicy element : response.getResponsesList()) { + * for (GuestPolicies.GuestPolicy element : response.getGuestPoliciesList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceSettings.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceSettings.java index 9fe9edc9..6d712455 100644 --- a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceSettings.java +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/OsConfigServiceSettings.java @@ -26,6 +26,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -226,11 +227,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return OsConfigServiceStubSettings.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 OsConfigServiceStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return OsConfigServiceStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return OsConfigServiceStubSettings.defaultTransportChannelProvider(); } @@ -240,11 +248,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return OsConfigServiceStubSettings.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); @@ -282,6 +296,11 @@ private static Builder createDefault() { return new Builder(OsConfigServiceStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(OsConfigServiceStubSettings.newHttpJsonBuilder()); + } + public OsConfigServiceStubSettings.Builder getStubSettingsBuilder() { return ((OsConfigServiceStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/HttpJsonOsConfigServiceCallableFactory.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/HttpJsonOsConfigServiceCallableFactory.java new file mode 100644 index 00000000..c1333332 --- /dev/null +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/HttpJsonOsConfigServiceCallableFactory.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.osconfig.v1beta.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 OsConfigService service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonOsConfigServiceCallableFactory + 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-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/HttpJsonOsConfigServiceStub.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/HttpJsonOsConfigServiceStub.java new file mode 100644 index 00000000..0e810d0c --- /dev/null +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/HttpJsonOsConfigServiceStub.java @@ -0,0 +1,1311 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.stub; + +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListGuestPoliciesPagedResponse; +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListPatchDeploymentsPagedResponse; +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListPatchJobInstanceDetailsPagedResponse; +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListPatchJobsPagedResponse; + +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.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.rpc.ClientContext; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.PatchDeployments; +import com.google.cloud.osconfig.v1beta.PatchJobs; +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 OsConfigService service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonOsConfigServiceStub extends OsConfigServiceStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + executePatchJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/ExecutePatchJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*}/patchJobs:execute", + 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(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearParent().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchJobs.PatchJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + getPatchJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/GetPatchJob") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/patchJobs/*}", + 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(PatchJobs.PatchJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + cancelPatchJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/CancelPatchJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/patchJobs/*}:cancel", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchJobs.PatchJob.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchJobs.ListPatchJobsRequest, PatchJobs.ListPatchJobsResponse> + listPatchJobsMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/ListPatchJobs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*}/patchJobs", + 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(PatchJobs.ListPatchJobsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/ListPatchJobInstanceDetails") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{parent=projects/*/patchJobs/*}/instanceDetails", + 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( + PatchJobs.ListPatchJobInstanceDetailsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/CreatePatchDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{parent=projects/*}/patchDeployments", + 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, "patchDeploymentId", request.getPatchDeploymentId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("patchDeployment", request.getPatchDeployment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.GetPatchDeploymentRequest, PatchDeployments.PatchDeployment> + getPatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/GetPatchDeployment") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{name=projects/*/patchDeployments/*}", + 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(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/ListPatchDeployments") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{parent=projects/*}/patchDeployments", + 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, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser + .newBuilder() + .setDefaultInstance( + PatchDeployments.ListPatchDeploymentsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deletePatchDeploymentMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/DeletePatchDeployment") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{name=projects/*/patchDeployments/*}", + 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(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/UpdatePatchDeployment") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{patchDeployment.name=projects/*/patchDeployments/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + serializer.putPathParam( + fields, + "patchDeployment.name", + request.getPatchDeployment().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("patchDeployment", request.getPatchDeployment())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/PausePatchDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{name=projects/*/patchDeployments/*}:pause", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/ResumePatchDeployment") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{name=projects/*/patchDeployments/*}:resume", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + serializer.putPathParam(fields, "name", request.getName()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearName().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(PatchDeployments.PatchDeployment.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + GuestPolicies.CreateGuestPolicyRequest, GuestPolicies.GuestPolicy> + createGuestPolicyMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/CreateGuestPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*}/guestPolicies", + 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, "guestPolicyId", request.getGuestPolicyId()); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("guestPolicy", request.getGuestPolicy())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GuestPolicies.GuestPolicy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + GuestPolicies.GetGuestPolicyRequest, GuestPolicies.GuestPolicy> + getGuestPolicyMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/GetGuestPolicy") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/guestPolicies/*}", + 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(GuestPolicies.GuestPolicy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + GuestPolicies.ListGuestPoliciesRequest, GuestPolicies.ListGuestPoliciesResponse> + listGuestPoliciesMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/ListGuestPolicies") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{parent=projects/*}/guestPolicies", + 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, "pageSize", request.getPageSize()); + serializer.putQueryParam(fields, "pageToken", request.getPageToken()); + return fields; + }) + .setRequestBodyExtractor(request -> null) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance( + GuestPolicies.ListGuestPoliciesResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + GuestPolicies.UpdateGuestPolicyRequest, GuestPolicies.GuestPolicy> + updateGuestPolicyMethodDescriptor = + ApiMethodDescriptor + .newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/UpdateGuestPolicy") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{guestPolicy.name=projects/*/guestPolicies/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam( + fields, "guestPolicy.name", request.getGuestPolicy().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("guestPolicy", request.getGuestPolicy())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GuestPolicies.GuestPolicy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor + deleteGuestPolicyMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.osconfig.v1beta.OsConfigService/DeleteGuestPolicy") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta/{name=projects/*/guestPolicies/*}", + 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(Empty.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor< + GuestPolicies.LookupEffectiveGuestPolicyRequest, GuestPolicies.EffectiveGuestPolicy> + lookupEffectiveGuestPolicyMethodDescriptor = + ApiMethodDescriptor + . + newBuilder() + .setFullMethodName( + "google.cloud.osconfig.v1beta.OsConfigService/LookupEffectiveGuestPolicy") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter + .newBuilder() + .setPath( + "/v1beta/{instance=projects/*/zones/*/instances/*}:lookupEffectiveGuestPolicy", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + serializer.putPathParam(fields, "instance", request.getInstance()); + return fields; + }) + .setQueryParamsExtractor( + request -> { + Map> fields = new HashMap<>(); + ProtoRestSerializer + serializer = ProtoRestSerializer.create(); + return fields; + }) + .setRequestBodyExtractor( + request -> + ProtoRestSerializer.create() + .toBody("*", request.toBuilder().clearInstance().build())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(GuestPolicies.EffectiveGuestPolicy.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable + executePatchJobCallable; + private final UnaryCallable getPatchJobCallable; + private final UnaryCallable + cancelPatchJobCallable; + private final UnaryCallable + listPatchJobsCallable; + private final UnaryCallable + listPatchJobsPagedCallable; + private final UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsCallable; + private final UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, ListPatchJobInstanceDetailsPagedResponse> + listPatchJobInstanceDetailsPagedCallable; + private final UnaryCallable< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.GetPatchDeploymentRequest, PatchDeployments.PatchDeployment> + getPatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsCallable; + private final UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, ListPatchDeploymentsPagedResponse> + listPatchDeploymentsPagedCallable; + private final UnaryCallable + deletePatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentCallable; + private final UnaryCallable< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentCallable; + private final UnaryCallable + createGuestPolicyCallable; + private final UnaryCallable + getGuestPolicyCallable; + private final UnaryCallable< + GuestPolicies.ListGuestPoliciesRequest, GuestPolicies.ListGuestPoliciesResponse> + listGuestPoliciesCallable; + private final UnaryCallable< + GuestPolicies.ListGuestPoliciesRequest, ListGuestPoliciesPagedResponse> + listGuestPoliciesPagedCallable; + private final UnaryCallable + updateGuestPolicyCallable; + private final UnaryCallable + deleteGuestPolicyCallable; + private final UnaryCallable< + GuestPolicies.LookupEffectiveGuestPolicyRequest, GuestPolicies.EffectiveGuestPolicy> + lookupEffectiveGuestPolicyCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonOsConfigServiceStub create(OsConfigServiceStubSettings settings) + throws IOException { + return new HttpJsonOsConfigServiceStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonOsConfigServiceStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonOsConfigServiceStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonOsConfigServiceStub, 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 HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonOsConfigServiceCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonOsConfigServiceStub, 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 HttpJsonOsConfigServiceStub( + OsConfigServiceStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings + executePatchJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(executePatchJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getPatchJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getPatchJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + cancelPatchJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(cancelPatchJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + listPatchJobsTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(listPatchJobsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listPatchJobInstanceDetailsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(createPatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.GetPatchDeploymentRequest, PatchDeployments.PatchDeployment> + getPatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(getPatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listPatchDeploymentsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deletePatchDeploymentTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deletePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(updatePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(pausePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(resumePatchDeploymentMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + createGuestPolicyTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(createGuestPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + getGuestPolicyTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(getGuestPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + GuestPolicies.ListGuestPoliciesRequest, GuestPolicies.ListGuestPoliciesResponse> + listGuestPoliciesTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(listGuestPoliciesMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + updateGuestPolicyTransportSettings = + HttpJsonCallSettings + .newBuilder() + .setMethodDescriptor(updateGuestPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings + deleteGuestPolicyTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteGuestPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings< + GuestPolicies.LookupEffectiveGuestPolicyRequest, GuestPolicies.EffectiveGuestPolicy> + lookupEffectiveGuestPolicyTransportSettings = + HttpJsonCallSettings + . + newBuilder() + .setMethodDescriptor(lookupEffectiveGuestPolicyMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.executePatchJobCallable = + callableFactory.createUnaryCallable( + executePatchJobTransportSettings, settings.executePatchJobSettings(), clientContext); + this.getPatchJobCallable = + callableFactory.createUnaryCallable( + getPatchJobTransportSettings, settings.getPatchJobSettings(), clientContext); + this.cancelPatchJobCallable = + callableFactory.createUnaryCallable( + cancelPatchJobTransportSettings, settings.cancelPatchJobSettings(), clientContext); + this.listPatchJobsCallable = + callableFactory.createUnaryCallable( + listPatchJobsTransportSettings, settings.listPatchJobsSettings(), clientContext); + this.listPatchJobsPagedCallable = + callableFactory.createPagedCallable( + listPatchJobsTransportSettings, settings.listPatchJobsSettings(), clientContext); + this.listPatchJobInstanceDetailsCallable = + callableFactory.createUnaryCallable( + listPatchJobInstanceDetailsTransportSettings, + settings.listPatchJobInstanceDetailsSettings(), + clientContext); + this.listPatchJobInstanceDetailsPagedCallable = + callableFactory.createPagedCallable( + listPatchJobInstanceDetailsTransportSettings, + settings.listPatchJobInstanceDetailsSettings(), + clientContext); + this.createPatchDeploymentCallable = + callableFactory.createUnaryCallable( + createPatchDeploymentTransportSettings, + settings.createPatchDeploymentSettings(), + clientContext); + this.getPatchDeploymentCallable = + callableFactory.createUnaryCallable( + getPatchDeploymentTransportSettings, + settings.getPatchDeploymentSettings(), + clientContext); + this.listPatchDeploymentsCallable = + callableFactory.createUnaryCallable( + listPatchDeploymentsTransportSettings, + settings.listPatchDeploymentsSettings(), + clientContext); + this.listPatchDeploymentsPagedCallable = + callableFactory.createPagedCallable( + listPatchDeploymentsTransportSettings, + settings.listPatchDeploymentsSettings(), + clientContext); + this.deletePatchDeploymentCallable = + callableFactory.createUnaryCallable( + deletePatchDeploymentTransportSettings, + settings.deletePatchDeploymentSettings(), + clientContext); + this.updatePatchDeploymentCallable = + callableFactory.createUnaryCallable( + updatePatchDeploymentTransportSettings, + settings.updatePatchDeploymentSettings(), + clientContext); + this.pausePatchDeploymentCallable = + callableFactory.createUnaryCallable( + pausePatchDeploymentTransportSettings, + settings.pausePatchDeploymentSettings(), + clientContext); + this.resumePatchDeploymentCallable = + callableFactory.createUnaryCallable( + resumePatchDeploymentTransportSettings, + settings.resumePatchDeploymentSettings(), + clientContext); + this.createGuestPolicyCallable = + callableFactory.createUnaryCallable( + createGuestPolicyTransportSettings, + settings.createGuestPolicySettings(), + clientContext); + this.getGuestPolicyCallable = + callableFactory.createUnaryCallable( + getGuestPolicyTransportSettings, settings.getGuestPolicySettings(), clientContext); + this.listGuestPoliciesCallable = + callableFactory.createUnaryCallable( + listGuestPoliciesTransportSettings, + settings.listGuestPoliciesSettings(), + clientContext); + this.listGuestPoliciesPagedCallable = + callableFactory.createPagedCallable( + listGuestPoliciesTransportSettings, + settings.listGuestPoliciesSettings(), + clientContext); + this.updateGuestPolicyCallable = + callableFactory.createUnaryCallable( + updateGuestPolicyTransportSettings, + settings.updateGuestPolicySettings(), + clientContext); + this.deleteGuestPolicyCallable = + callableFactory.createUnaryCallable( + deleteGuestPolicyTransportSettings, + settings.deleteGuestPolicySettings(), + clientContext); + this.lookupEffectiveGuestPolicyCallable = + callableFactory.createUnaryCallable( + lookupEffectiveGuestPolicyTransportSettings, + settings.lookupEffectiveGuestPolicySettings(), + clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(executePatchJobMethodDescriptor); + methodDescriptors.add(getPatchJobMethodDescriptor); + methodDescriptors.add(cancelPatchJobMethodDescriptor); + methodDescriptors.add(listPatchJobsMethodDescriptor); + methodDescriptors.add(listPatchJobInstanceDetailsMethodDescriptor); + methodDescriptors.add(createPatchDeploymentMethodDescriptor); + methodDescriptors.add(getPatchDeploymentMethodDescriptor); + methodDescriptors.add(listPatchDeploymentsMethodDescriptor); + methodDescriptors.add(deletePatchDeploymentMethodDescriptor); + methodDescriptors.add(updatePatchDeploymentMethodDescriptor); + methodDescriptors.add(pausePatchDeploymentMethodDescriptor); + methodDescriptors.add(resumePatchDeploymentMethodDescriptor); + methodDescriptors.add(createGuestPolicyMethodDescriptor); + methodDescriptors.add(getGuestPolicyMethodDescriptor); + methodDescriptors.add(listGuestPoliciesMethodDescriptor); + methodDescriptors.add(updateGuestPolicyMethodDescriptor); + methodDescriptors.add(deleteGuestPolicyMethodDescriptor); + methodDescriptors.add(lookupEffectiveGuestPolicyMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable + executePatchJobCallable() { + return executePatchJobCallable; + } + + @Override + public UnaryCallable getPatchJobCallable() { + return getPatchJobCallable; + } + + @Override + public UnaryCallable + cancelPatchJobCallable() { + return cancelPatchJobCallable; + } + + @Override + public UnaryCallable + listPatchJobsCallable() { + return listPatchJobsCallable; + } + + @Override + public UnaryCallable + listPatchJobsPagedCallable() { + return listPatchJobsPagedCallable; + } + + @Override + public UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, + PatchJobs.ListPatchJobInstanceDetailsResponse> + listPatchJobInstanceDetailsCallable() { + return listPatchJobInstanceDetailsCallable; + } + + @Override + public UnaryCallable< + PatchJobs.ListPatchJobInstanceDetailsRequest, ListPatchJobInstanceDetailsPagedResponse> + listPatchJobInstanceDetailsPagedCallable() { + return listPatchJobInstanceDetailsPagedCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.CreatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + createPatchDeploymentCallable() { + return createPatchDeploymentCallable; + } + + @Override + public UnaryCallable + getPatchDeploymentCallable() { + return getPatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, + PatchDeployments.ListPatchDeploymentsResponse> + listPatchDeploymentsCallable() { + return listPatchDeploymentsCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.ListPatchDeploymentsRequest, ListPatchDeploymentsPagedResponse> + listPatchDeploymentsPagedCallable() { + return listPatchDeploymentsPagedCallable; + } + + @Override + public UnaryCallable + deletePatchDeploymentCallable() { + return deletePatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.UpdatePatchDeploymentRequest, PatchDeployments.PatchDeployment> + updatePatchDeploymentCallable() { + return updatePatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.PausePatchDeploymentRequest, PatchDeployments.PatchDeployment> + pausePatchDeploymentCallable() { + return pausePatchDeploymentCallable; + } + + @Override + public UnaryCallable< + PatchDeployments.ResumePatchDeploymentRequest, PatchDeployments.PatchDeployment> + resumePatchDeploymentCallable() { + return resumePatchDeploymentCallable; + } + + @Override + public UnaryCallable + createGuestPolicyCallable() { + return createGuestPolicyCallable; + } + + @Override + public UnaryCallable + getGuestPolicyCallable() { + return getGuestPolicyCallable; + } + + @Override + public UnaryCallable< + GuestPolicies.ListGuestPoliciesRequest, GuestPolicies.ListGuestPoliciesResponse> + listGuestPoliciesCallable() { + return listGuestPoliciesCallable; + } + + @Override + public UnaryCallable + listGuestPoliciesPagedCallable() { + return listGuestPoliciesPagedCallable; + } + + @Override + public UnaryCallable + updateGuestPolicyCallable() { + return updateGuestPolicyCallable; + } + + @Override + public UnaryCallable deleteGuestPolicyCallable() { + return deleteGuestPolicyCallable; + } + + @Override + public UnaryCallable< + GuestPolicies.LookupEffectiveGuestPolicyRequest, GuestPolicies.EffectiveGuestPolicy> + lookupEffectiveGuestPolicyCallable() { + return lookupEffectiveGuestPolicyCallable; + } + + @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-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/OsConfigServiceStubSettings.java b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/OsConfigServiceStubSettings.java index 44d93fa7..75c7b861 100644 --- a/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/OsConfigServiceStubSettings.java +++ b/google-cloud-os-config/src/main/java/com/google/cloud/osconfig/v1beta/stub/OsConfigServiceStubSettings.java @@ -30,6 +30,9 @@ import com.google.api.gax.grpc.GaxGrpcProperties; import com.google.api.gax.grpc.GrpcTransportChannel; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +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.retrying.RetrySettings; import com.google.api.gax.rpc.ApiCallContext; import com.google.api.gax.rpc.ApiClientHeaderProvider; @@ -586,13 +589,17 @@ public UnaryCallSettings getPa return lookupEffectiveGuestPolicySettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public OsConfigServiceStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcOsConfigServiceStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonOsConfigServiceStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -625,18 +632,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(OsConfigServiceStubSettings.class)) @@ -644,11 +658,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(OsConfigServiceStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return OsConfigServiceStubSettings.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); @@ -884,6 +917,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 .executePatchJobSettings() diff --git a/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigServiceClientHttpJsonTest.java b/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigServiceClientHttpJsonTest.java new file mode 100644 index 00000000..739cb860 --- /dev/null +++ b/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigServiceClientHttpJsonTest.java @@ -0,0 +1,1242 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1; + +import static com.google.cloud.osconfig.v1.OsConfigServiceClient.ListPatchDeploymentsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigServiceClient.ListPatchJobInstanceDetailsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigServiceClient.ListPatchJobsPagedResponse; + +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.osconfig.v1.stub.HttpJsonOsConfigServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Duration; +import com.google.protobuf.Empty; +import com.google.protobuf.FieldMask; +import com.google.protobuf.Timestamp; +import java.io.IOException; +import java.util.Arrays; +import java.util.List; +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 OsConfigServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static OsConfigServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonOsConfigServiceStub.getMethodDescriptors(), + OsConfigServiceSettings.getDefaultEndpoint()); + OsConfigServiceSettings settings = + OsConfigServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + OsConfigServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = OsConfigServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void executePatchJobTest() throws Exception { + PatchJobs.PatchJob expectedResponse = + PatchJobs.PatchJob.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setInstanceDetailsSummary( + PatchJobs.PatchJob.InstanceDetailsSummary.newBuilder().build()) + .setDryRun(true) + .setErrorMessage("errorMessage1203236063") + .setPercentComplete(-1960969229) + .setPatchDeployment( + PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + + PatchJobs.PatchJob actualResponse = client.executePatchJob(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void executePatchJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + client.executePatchJob(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPatchJobTest() throws Exception { + PatchJobs.PatchJob expectedResponse = + PatchJobs.PatchJob.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setInstanceDetailsSummary( + PatchJobs.PatchJob.InstanceDetailsSummary.newBuilder().build()) + .setDryRun(true) + .setErrorMessage("errorMessage1203236063") + .setPercentComplete(-1960969229) + .setPatchDeployment( + PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobName name = PatchJobName.of("[PROJECT]", "[PATCH_JOB]"); + + PatchJobs.PatchJob actualResponse = client.getPatchJob(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 getPatchJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobName name = PatchJobName.of("[PROJECT]", "[PATCH_JOB]"); + client.getPatchJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPatchJobTest2() throws Exception { + PatchJobs.PatchJob expectedResponse = + PatchJobs.PatchJob.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setInstanceDetailsSummary( + PatchJobs.PatchJob.InstanceDetailsSummary.newBuilder().build()) + .setDryRun(true) + .setErrorMessage("errorMessage1203236063") + .setPercentComplete(-1960969229) + .setPatchDeployment( + PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3014/patchJobs/patchJob-3014"; + + PatchJobs.PatchJob actualResponse = client.getPatchJob(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 getPatchJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3014/patchJobs/patchJob-3014"; + client.getPatchJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void cancelPatchJobTest() throws Exception { + PatchJobs.PatchJob expectedResponse = + PatchJobs.PatchJob.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setInstanceDetailsSummary( + PatchJobs.PatchJob.InstanceDetailsSummary.newBuilder().build()) + .setDryRun(true) + .setErrorMessage("errorMessage1203236063") + .setPercentComplete(-1960969229) + .setPatchDeployment( + PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .build(); + + PatchJobs.PatchJob actualResponse = client.cancelPatchJob(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void cancelPatchJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .build(); + client.cancelPatchJob(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchJobsTest() throws Exception { + PatchJobs.PatchJob responsesElement = PatchJobs.PatchJob.newBuilder().build(); + PatchJobs.ListPatchJobsResponse expectedResponse = + PatchJobs.ListPatchJobsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchJobs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListPatchJobsPagedResponse pagedListResponse = client.listPatchJobs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchJobsList().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 listPatchJobsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listPatchJobs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchJobsTest2() throws Exception { + PatchJobs.PatchJob responsesElement = PatchJobs.PatchJob.newBuilder().build(); + PatchJobs.ListPatchJobsResponse expectedResponse = + PatchJobs.ListPatchJobsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchJobs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListPatchJobsPagedResponse pagedListResponse = client.listPatchJobs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchJobsList().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 listPatchJobsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listPatchJobs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchJobInstanceDetailsTest() throws Exception { + PatchJobs.PatchJobInstanceDetails responsesElement = + PatchJobs.PatchJobInstanceDetails.newBuilder().build(); + PatchJobs.ListPatchJobInstanceDetailsResponse expectedResponse = + PatchJobs.ListPatchJobInstanceDetailsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchJobInstanceDetails(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobName parent = PatchJobName.of("[PROJECT]", "[PATCH_JOB]"); + + ListPatchJobInstanceDetailsPagedResponse pagedListResponse = + client.listPatchJobInstanceDetails(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchJobInstanceDetailsList().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 listPatchJobInstanceDetailsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobName parent = PatchJobName.of("[PROJECT]", "[PATCH_JOB]"); + client.listPatchJobInstanceDetails(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchJobInstanceDetailsTest2() throws Exception { + PatchJobs.PatchJobInstanceDetails responsesElement = + PatchJobs.PatchJobInstanceDetails.newBuilder().build(); + PatchJobs.ListPatchJobInstanceDetailsResponse expectedResponse = + PatchJobs.ListPatchJobInstanceDetailsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchJobInstanceDetails(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-1881/patchJobs/patchJob-1881"; + + ListPatchJobInstanceDetailsPagedResponse pagedListResponse = + client.listPatchJobInstanceDetails(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchJobInstanceDetailsList().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 listPatchJobInstanceDetailsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-1881/patchJobs/patchJob-1881"; + client.listPatchJobInstanceDetails(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + String patchDeploymentId = "patchDeploymentId-1180405976"; + + PatchDeployments.PatchDeployment actualResponse = + client.createPatchDeployment(parent, patchDeployment, patchDeploymentId); + 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 createPatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + String patchDeploymentId = "patchDeploymentId-1180405976"; + client.createPatchDeployment(parent, patchDeployment, patchDeploymentId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPatchDeploymentTest2() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + String patchDeploymentId = "patchDeploymentId-1180405976"; + + PatchDeployments.PatchDeployment actualResponse = + client.createPatchDeployment(parent, patchDeployment, patchDeploymentId); + 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 createPatchDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + String patchDeploymentId = "patchDeploymentId-1180405976"; + client.createPatchDeployment(parent, patchDeployment, patchDeploymentId); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + + PatchDeployments.PatchDeployment actualResponse = client.getPatchDeployment(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 getPatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + client.getPatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPatchDeploymentTest2() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + + PatchDeployments.PatchDeployment actualResponse = client.getPatchDeployment(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 getPatchDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + client.getPatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchDeploymentsTest() throws Exception { + PatchDeployments.PatchDeployment responsesElement = + PatchDeployments.PatchDeployment.newBuilder().build(); + PatchDeployments.ListPatchDeploymentsResponse expectedResponse = + PatchDeployments.ListPatchDeploymentsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchDeployments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListPatchDeploymentsPagedResponse pagedListResponse = client.listPatchDeployments(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchDeploymentsList().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 listPatchDeploymentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listPatchDeployments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchDeploymentsTest2() throws Exception { + PatchDeployments.PatchDeployment responsesElement = + PatchDeployments.PatchDeployment.newBuilder().build(); + PatchDeployments.ListPatchDeploymentsResponse expectedResponse = + PatchDeployments.ListPatchDeploymentsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchDeployments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListPatchDeploymentsPagedResponse pagedListResponse = client.listPatchDeployments(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchDeploymentsList().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 listPatchDeploymentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listPatchDeployments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deletePatchDeploymentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + + client.deletePatchDeployment(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 deletePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + client.deletePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deletePatchDeploymentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + + client.deletePatchDeployment(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 deletePatchDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + client.deletePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updatePatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + PatchDeployments.PatchDeployment actualResponse = + client.updatePatchDeployment(patchDeployment, 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 updatePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updatePatchDeployment(patchDeployment, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pausePatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + + PatchDeployments.PatchDeployment actualResponse = client.pausePatchDeployment(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 pausePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + client.pausePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pausePatchDeploymentTest2() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + + PatchDeployments.PatchDeployment actualResponse = client.pausePatchDeployment(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 pausePatchDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + client.pausePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resumePatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + + PatchDeployments.PatchDeployment actualResponse = client.resumePatchDeployment(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 resumePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + client.resumePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resumePatchDeploymentTest2() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + + PatchDeployments.PatchDeployment actualResponse = client.resumePatchDeployment(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 resumePatchDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + client.resumePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClientHttpJsonTest.java b/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClientHttpJsonTest.java new file mode 100644 index 00000000..3f589023 --- /dev/null +++ b/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClientHttpJsonTest.java @@ -0,0 +1,1359 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1; + +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListInventoriesPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListOSPolicyAssignmentReportsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListOSPolicyAssignmentRevisionsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListOSPolicyAssignmentsPagedResponse; +import static com.google.cloud.osconfig.v1.OsConfigZonalServiceClient.ListVulnerabilityReportsPagedResponse; + +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.osconfig.v1.stub.HttpJsonOsConfigZonalServiceStub; +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 OsConfigZonalServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static OsConfigZonalServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonOsConfigZonalServiceStub.getMethodDescriptors(), + OsConfigZonalServiceSettings.getDefaultEndpoint()); + OsConfigZonalServiceSettings settings = + OsConfigZonalServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + OsConfigZonalServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = OsConfigZonalServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createOSPolicyAssignmentTest() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + + OSPolicyAssignment actualResponse = + client + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .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 createOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + client.createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createOSPolicyAssignmentTest2() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + + OSPolicyAssignment actualResponse = + client + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .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 createOSPolicyAssignmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + client.createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateOSPolicyAssignmentTest() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + OSPolicyAssignment osPolicyAssignment = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + OSPolicyAssignment actualResponse = + client.updateOSPolicyAssignmentAsync(osPolicyAssignment, updateMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignment osPolicyAssignment = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateOSPolicyAssignmentAsync(osPolicyAssignment, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getOSPolicyAssignmentTest() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + mockService.addResponse(expectedResponse); + + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + + OSPolicyAssignment actualResponse = client.getOSPolicyAssignment(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 getOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + client.getOSPolicyAssignment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOSPolicyAssignmentTest2() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + + OSPolicyAssignment actualResponse = client.getOSPolicyAssignment(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 getOSPolicyAssignmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + client.getOSPolicyAssignment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentsTest() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentsResponse expectedResponse = + ListOSPolicyAssignmentsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListOSPolicyAssignmentsPagedResponse pagedListResponse = client.listOSPolicyAssignments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listOSPolicyAssignments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentsTest2() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentsResponse expectedResponse = + ListOSPolicyAssignmentsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListOSPolicyAssignmentsPagedResponse pagedListResponse = client.listOSPolicyAssignments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listOSPolicyAssignments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentRevisionsTest() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentRevisionsResponse expectedResponse = + ListOSPolicyAssignmentRevisionsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + + ListOSPolicyAssignmentRevisionsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentRevisions(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentRevisionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + client.listOSPolicyAssignmentRevisions(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentRevisionsTest2() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentRevisionsResponse expectedResponse = + ListOSPolicyAssignmentRevisionsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + + ListOSPolicyAssignmentRevisionsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentRevisions(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentRevisionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + client.listOSPolicyAssignmentRevisions(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteOSPolicyAssignmentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + + client.deleteOSPolicyAssignmentAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + client.deleteOSPolicyAssignmentAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteOSPolicyAssignmentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + + client.deleteOSPolicyAssignmentAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteOSPolicyAssignmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + client.deleteOSPolicyAssignmentAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getOSPolicyAssignmentReportTest() throws Exception { + OSPolicyAssignmentReport expectedResponse = + OSPolicyAssignmentReport.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setInstance("instance555127957") + .setOsPolicyAssignment( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .addAllOsPolicyCompliances(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunId("lastRunId2001336336") + .build(); + mockService.addResponse(expectedResponse); + + OSPolicyAssignmentReportName name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + + OSPolicyAssignmentReport actualResponse = client.getOSPolicyAssignmentReport(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 getOSPolicyAssignmentReportExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentReportName name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + client.getOSPolicyAssignmentReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOSPolicyAssignmentReportTest2() throws Exception { + OSPolicyAssignmentReport expectedResponse = + OSPolicyAssignmentReport.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setInstance("instance555127957") + .setOsPolicyAssignment( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .addAllOsPolicyCompliances(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunId("lastRunId2001336336") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6771/locations/location-6771/instances/instance-6771/osPolicyAssignments/osPolicyAssignment-6771/report"; + + OSPolicyAssignmentReport actualResponse = client.getOSPolicyAssignmentReport(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 getOSPolicyAssignmentReportExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6771/locations/location-6771/instances/instance-6771/osPolicyAssignments/osPolicyAssignment-6771/report"; + client.getOSPolicyAssignmentReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentReportsTest() throws Exception { + OSPolicyAssignmentReport responsesElement = OSPolicyAssignmentReport.newBuilder().build(); + ListOSPolicyAssignmentReportsResponse expectedResponse = + ListOSPolicyAssignmentReportsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignmentReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InstanceOSPolicyAssignmentName parent = + InstanceOSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + + ListOSPolicyAssignmentReportsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals( + expectedResponse.getOsPolicyAssignmentReportsList().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 listOSPolicyAssignmentReportsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceOSPolicyAssignmentName parent = + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + client.listOSPolicyAssignmentReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentReportsTest2() throws Exception { + OSPolicyAssignmentReport responsesElement = OSPolicyAssignmentReport.newBuilder().build(); + ListOSPolicyAssignmentReportsResponse expectedResponse = + ListOSPolicyAssignmentReportsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignmentReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-6863/locations/location-6863/instances/instance-6863/osPolicyAssignments/osPolicyAssignment-6863"; + + ListOSPolicyAssignmentReportsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals( + expectedResponse.getOsPolicyAssignmentReportsList().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 listOSPolicyAssignmentReportsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-6863/locations/location-6863/instances/instance-6863/osPolicyAssignments/osPolicyAssignment-6863"; + client.listOSPolicyAssignmentReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInventoryTest() throws Exception { + Inventory expectedResponse = + Inventory.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setOsInfo(Inventory.OsInfo.newBuilder().build()) + .putAllItems(new HashMap()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + InventoryName name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + Inventory actualResponse = client.getInventory(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 getInventoryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InventoryName name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.getInventory(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInventoryTest2() throws Exception { + Inventory expectedResponse = + Inventory.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setOsInfo(Inventory.OsInfo.newBuilder().build()) + .putAllItems(new HashMap()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-943/locations/location-943/instances/instance-943/inventory"; + + Inventory actualResponse = client.getInventory(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 getInventoryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-943/locations/location-943/instances/instance-943/inventory"; + client.getInventory(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInventoriesTest() throws Exception { + Inventory responsesElement = Inventory.newBuilder().build(); + ListInventoriesResponse expectedResponse = + ListInventoriesResponse.newBuilder() + .setNextPageToken("") + .addAllInventories(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InstanceName parent = + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + ListInventoriesPagedResponse pagedListResponse = client.listInventories(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInventoriesList().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 listInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName parent = + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.listInventories(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInventoriesTest2() throws Exception { + Inventory responsesElement = Inventory.newBuilder().build(); + ListInventoriesResponse expectedResponse = + ListInventoriesResponse.newBuilder() + .setNextPageToken("") + .addAllInventories(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + + ListInventoriesPagedResponse pagedListResponse = client.listInventories(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInventoriesList().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 listInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + client.listInventories(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVulnerabilityReportTest() throws Exception { + VulnerabilityReport expectedResponse = + VulnerabilityReport.newBuilder() + .setName(VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .addAllVulnerabilities(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + VulnerabilityReportName name = + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + VulnerabilityReport actualResponse = client.getVulnerabilityReport(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 getVulnerabilityReportExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + VulnerabilityReportName name = + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.getVulnerabilityReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVulnerabilityReportTest2() throws Exception { + VulnerabilityReport expectedResponse = + VulnerabilityReport.newBuilder() + .setName(VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .addAllVulnerabilities(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-2379/locations/location-2379/instances/instance-2379/vulnerabilityReport"; + + VulnerabilityReport actualResponse = client.getVulnerabilityReport(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 getVulnerabilityReportExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-2379/locations/location-2379/instances/instance-2379/vulnerabilityReport"; + client.getVulnerabilityReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listVulnerabilityReportsTest() throws Exception { + VulnerabilityReport responsesElement = VulnerabilityReport.newBuilder().build(); + ListVulnerabilityReportsResponse expectedResponse = + ListVulnerabilityReportsResponse.newBuilder() + .setNextPageToken("") + .addAllVulnerabilityReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InstanceName parent = + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + ListVulnerabilityReportsPagedResponse pagedListResponse = + client.listVulnerabilityReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVulnerabilityReportsList().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 listVulnerabilityReportsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName parent = + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.listVulnerabilityReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listVulnerabilityReportsTest2() throws Exception { + VulnerabilityReport responsesElement = VulnerabilityReport.newBuilder().build(); + ListVulnerabilityReportsResponse expectedResponse = + ListVulnerabilityReportsResponse.newBuilder() + .setNextPageToken("") + .addAllVulnerabilityReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + + ListVulnerabilityReportsPagedResponse pagedListResponse = + client.listVulnerabilityReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVulnerabilityReportsList().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 listVulnerabilityReportsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + client.listVulnerabilityReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClientTest.java b/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClientTest.java index e39265d1..18a97c47 100644 --- a/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClientTest.java +++ b/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1/OsConfigZonalServiceClientTest.java @@ -961,7 +961,7 @@ public void listInventoriesTest() throws Exception { mockOsConfigZonalService.addResponse(expectedResponse); InstanceName parent = - InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]"); + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); ListInventoriesPagedResponse pagedListResponse = client.listInventories(parent); @@ -988,7 +988,7 @@ public void listInventoriesExceptionTest() throws Exception { try { InstanceName parent = - InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]"); + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); client.listInventories(parent); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { @@ -1135,7 +1135,7 @@ public void listVulnerabilityReportsTest() throws Exception { mockOsConfigZonalService.addResponse(expectedResponse); InstanceName parent = - InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]"); + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); ListVulnerabilityReportsPagedResponse pagedListResponse = client.listVulnerabilityReports(parent); @@ -1164,7 +1164,7 @@ public void listVulnerabilityReportsExceptionTest() throws Exception { try { InstanceName parent = - InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]"); + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); client.listVulnerabilityReports(parent); Assert.fail("No exception raised"); } catch (InvalidArgumentException e) { diff --git a/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClientHttpJsonTest.java b/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClientHttpJsonTest.java new file mode 100644 index 00000000..44e3bfba --- /dev/null +++ b/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1alpha/OsConfigZonalServiceClientHttpJsonTest.java @@ -0,0 +1,1576 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha; + +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListInstanceOSPoliciesCompliancesPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListInventoriesPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignmentReportsPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignmentRevisionsPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListOSPolicyAssignmentsPagedResponse; +import static com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient.ListVulnerabilityReportsPagedResponse; + +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.osconfig.v1alpha.stub.HttpJsonOsConfigZonalServiceStub; +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 OsConfigZonalServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static OsConfigZonalServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonOsConfigZonalServiceStub.getMethodDescriptors(), + OsConfigZonalServiceSettings.getDefaultEndpoint()); + OsConfigZonalServiceSettings settings = + OsConfigZonalServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + OsConfigZonalServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = OsConfigZonalServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void createOSPolicyAssignmentTest() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + + OSPolicyAssignment actualResponse = + client + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .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 createOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + client.createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void createOSPolicyAssignmentTest2() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("createOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String parent = "projects/project-5833/locations/location-5833"; + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + + OSPolicyAssignment actualResponse = + client + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .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 createOSPolicyAssignmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + client.createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void updateOSPolicyAssignmentTest() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + Operation resultOperation = + Operation.newBuilder() + .setName("updateOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + OSPolicyAssignment osPolicyAssignment = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + OSPolicyAssignment actualResponse = + client.updateOSPolicyAssignmentAsync(osPolicyAssignment, updateMask).get(); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void updateOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignment osPolicyAssignment = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateOSPolicyAssignmentAsync(osPolicyAssignment, updateMask).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getOSPolicyAssignmentTest() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + mockService.addResponse(expectedResponse); + + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + + OSPolicyAssignment actualResponse = client.getOSPolicyAssignment(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 getOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + client.getOSPolicyAssignment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOSPolicyAssignmentTest2() throws Exception { + OSPolicyAssignment expectedResponse = + OSPolicyAssignment.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setDescription("description-1724546052") + .addAllOsPolicies(new ArrayList()) + .setInstanceFilter(OSPolicyAssignment.InstanceFilter.newBuilder().build()) + .setRollout(OSPolicyAssignment.Rollout.newBuilder().build()) + .setRevisionId("revisionId-1507445162") + .setRevisionCreateTime(Timestamp.newBuilder().build()) + .setEtag("etag3123477") + .setBaseline(true) + .setDeleted(true) + .setReconciling(true) + .setUid("uid115792") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + + OSPolicyAssignment actualResponse = client.getOSPolicyAssignment(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 getOSPolicyAssignmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + client.getOSPolicyAssignment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentsTest() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentsResponse expectedResponse = + ListOSPolicyAssignmentsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListOSPolicyAssignmentsPagedResponse pagedListResponse = client.listOSPolicyAssignments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listOSPolicyAssignments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentsTest2() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentsResponse expectedResponse = + ListOSPolicyAssignmentsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListOSPolicyAssignmentsPagedResponse pagedListResponse = client.listOSPolicyAssignments(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listOSPolicyAssignments(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentRevisionsTest() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentRevisionsResponse expectedResponse = + ListOSPolicyAssignmentRevisionsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + + ListOSPolicyAssignmentRevisionsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentRevisions(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentRevisionsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + client.listOSPolicyAssignmentRevisions(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentRevisionsTest2() throws Exception { + OSPolicyAssignment responsesElement = OSPolicyAssignment.newBuilder().build(); + ListOSPolicyAssignmentRevisionsResponse expectedResponse = + ListOSPolicyAssignmentRevisionsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + + ListOSPolicyAssignmentRevisionsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentRevisions(name); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getOsPolicyAssignmentsList().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 listOSPolicyAssignmentRevisionsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + client.listOSPolicyAssignmentRevisions(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteOSPolicyAssignmentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + + client.deleteOSPolicyAssignmentAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteOSPolicyAssignmentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + client.deleteOSPolicyAssignmentAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void deleteOSPolicyAssignmentTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + Operation resultOperation = + Operation.newBuilder() + .setName("deleteOSPolicyAssignmentTest") + .setDone(true) + .setResponse(Any.pack(expectedResponse)) + .build(); + mockService.addResponse(resultOperation); + + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + + client.deleteOSPolicyAssignmentAsync(name).get(); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void deleteOSPolicyAssignmentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1862/locations/location-1862/osPolicyAssignments/osPolicyAssignment-1862"; + client.deleteOSPolicyAssignmentAsync(name).get(); + Assert.fail("No exception raised"); + } catch (ExecutionException e) { + } + } + + @Test + public void getInstanceOSPoliciesComplianceTest() throws Exception { + InstanceOSPoliciesCompliance expectedResponse = + InstanceOSPoliciesCompliance.newBuilder() + .setName( + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setInstance("instance555127957") + .setState(OSPolicyComplianceState.forNumber(0)) + .setDetailedState("detailedState1829498305") + .setDetailedStateReason("detailedStateReason-790407323") + .addAllOsPolicyCompliances( + new ArrayList()) + .setLastComplianceCheckTime(Timestamp.newBuilder().build()) + .setLastComplianceRunId("lastComplianceRunId168782901") + .build(); + mockService.addResponse(expectedResponse); + + InstanceOSPoliciesComplianceName name = + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + InstanceOSPoliciesCompliance actualResponse = client.getInstanceOSPoliciesCompliance(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 getInstanceOSPoliciesComplianceExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceOSPoliciesComplianceName name = + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.getInstanceOSPoliciesCompliance(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInstanceOSPoliciesComplianceTest2() throws Exception { + InstanceOSPoliciesCompliance expectedResponse = + InstanceOSPoliciesCompliance.newBuilder() + .setName( + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setInstance("instance555127957") + .setState(OSPolicyComplianceState.forNumber(0)) + .setDetailedState("detailedState1829498305") + .setDetailedStateReason("detailedStateReason-790407323") + .addAllOsPolicyCompliances( + new ArrayList()) + .setLastComplianceCheckTime(Timestamp.newBuilder().build()) + .setLastComplianceRunId("lastComplianceRunId168782901") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-1829/locations/location-1829/instanceOSPoliciesCompliances/instanceOSPoliciesCompliance-1829"; + + InstanceOSPoliciesCompliance actualResponse = client.getInstanceOSPoliciesCompliance(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 getInstanceOSPoliciesComplianceExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-1829/locations/location-1829/instanceOSPoliciesCompliances/instanceOSPoliciesCompliance-1829"; + client.getInstanceOSPoliciesCompliance(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInstanceOSPoliciesCompliancesTest() throws Exception { + InstanceOSPoliciesCompliance responsesElement = + InstanceOSPoliciesCompliance.newBuilder().build(); + ListInstanceOSPoliciesCompliancesResponse expectedResponse = + ListInstanceOSPoliciesCompliancesResponse.newBuilder() + .setNextPageToken("") + .addAllInstanceOsPoliciesCompliances(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListInstanceOSPoliciesCompliancesPagedResponse pagedListResponse = + client.listInstanceOSPoliciesCompliances(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals( + expectedResponse.getInstanceOsPoliciesCompliancesList().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 listInstanceOSPoliciesCompliancesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + client.listInstanceOSPoliciesCompliances(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInstanceOSPoliciesCompliancesTest2() throws Exception { + InstanceOSPoliciesCompliance responsesElement = + InstanceOSPoliciesCompliance.newBuilder().build(); + ListInstanceOSPoliciesCompliancesResponse expectedResponse = + ListInstanceOSPoliciesCompliancesResponse.newBuilder() + .setNextPageToken("") + .addAllInstanceOsPoliciesCompliances(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListInstanceOSPoliciesCompliancesPagedResponse pagedListResponse = + client.listInstanceOSPoliciesCompliances(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals( + expectedResponse.getInstanceOsPoliciesCompliancesList().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 listInstanceOSPoliciesCompliancesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5833/locations/location-5833"; + client.listInstanceOSPoliciesCompliances(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOSPolicyAssignmentReportTest() throws Exception { + OSPolicyAssignmentReport expectedResponse = + OSPolicyAssignmentReport.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setInstance("instance555127957") + .setOsPolicyAssignment( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .addAllOsPolicyCompliances(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunId("lastRunId2001336336") + .build(); + mockService.addResponse(expectedResponse); + + OSPolicyAssignmentReportName name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + + OSPolicyAssignmentReport actualResponse = client.getOSPolicyAssignmentReport(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 getOSPolicyAssignmentReportExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + OSPolicyAssignmentReportName name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + client.getOSPolicyAssignmentReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getOSPolicyAssignmentReportTest2() throws Exception { + OSPolicyAssignmentReport expectedResponse = + OSPolicyAssignmentReport.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setInstance("instance555127957") + .setOsPolicyAssignment( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .addAllOsPolicyCompliances(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastRunId("lastRunId2001336336") + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-6771/locations/location-6771/instances/instance-6771/osPolicyAssignments/osPolicyAssignment-6771/report"; + + OSPolicyAssignmentReport actualResponse = client.getOSPolicyAssignmentReport(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 getOSPolicyAssignmentReportExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-6771/locations/location-6771/instances/instance-6771/osPolicyAssignments/osPolicyAssignment-6771/report"; + client.getOSPolicyAssignmentReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentReportsTest() throws Exception { + OSPolicyAssignmentReport responsesElement = OSPolicyAssignmentReport.newBuilder().build(); + ListOSPolicyAssignmentReportsResponse expectedResponse = + ListOSPolicyAssignmentReportsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignmentReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InstanceOSPolicyAssignmentName parent = + InstanceOSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + + ListOSPolicyAssignmentReportsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals( + expectedResponse.getOsPolicyAssignmentReportsList().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 listOSPolicyAssignmentReportsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceOSPolicyAssignmentName parent = + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + client.listOSPolicyAssignmentReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listOSPolicyAssignmentReportsTest2() throws Exception { + OSPolicyAssignmentReport responsesElement = OSPolicyAssignmentReport.newBuilder().build(); + ListOSPolicyAssignmentReportsResponse expectedResponse = + ListOSPolicyAssignmentReportsResponse.newBuilder() + .setNextPageToken("") + .addAllOsPolicyAssignmentReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = + "projects/project-6863/locations/location-6863/instances/instance-6863/osPolicyAssignments/osPolicyAssignment-6863"; + + ListOSPolicyAssignmentReportsPagedResponse pagedListResponse = + client.listOSPolicyAssignmentReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals( + expectedResponse.getOsPolicyAssignmentReportsList().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 listOSPolicyAssignmentReportsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = + "projects/project-6863/locations/location-6863/instances/instance-6863/osPolicyAssignments/osPolicyAssignment-6863"; + client.listOSPolicyAssignmentReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInventoryTest() throws Exception { + Inventory expectedResponse = + Inventory.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setOsInfo(Inventory.OsInfo.newBuilder().build()) + .putAllItems(new HashMap()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + InventoryName name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + Inventory actualResponse = client.getInventory(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 getInventoryExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InventoryName name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.getInventory(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getInventoryTest2() throws Exception { + Inventory expectedResponse = + Inventory.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setOsInfo(Inventory.OsInfo.newBuilder().build()) + .putAllItems(new HashMap()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-943/locations/location-943/instances/instance-943/inventory"; + + Inventory actualResponse = client.getInventory(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 getInventoryExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-943/locations/location-943/instances/instance-943/inventory"; + client.getInventory(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInventoriesTest() throws Exception { + Inventory responsesElement = Inventory.newBuilder().build(); + ListInventoriesResponse expectedResponse = + ListInventoriesResponse.newBuilder() + .setNextPageToken("") + .addAllInventories(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + ListInventoriesPagedResponse pagedListResponse = client.listInventories(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInventoriesList().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 listInventoriesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.listInventories(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listInventoriesTest2() throws Exception { + Inventory responsesElement = Inventory.newBuilder().build(); + ListInventoriesResponse expectedResponse = + ListInventoriesResponse.newBuilder() + .setNextPageToken("") + .addAllInventories(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + + ListInventoriesPagedResponse pagedListResponse = client.listInventories(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getInventoriesList().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 listInventoriesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + client.listInventories(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVulnerabilityReportTest() throws Exception { + VulnerabilityReport expectedResponse = + VulnerabilityReport.newBuilder() + .setName(VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .addAllVulnerabilities(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + VulnerabilityReportName name = + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + VulnerabilityReport actualResponse = client.getVulnerabilityReport(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 getVulnerabilityReportExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + VulnerabilityReportName name = + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.getVulnerabilityReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getVulnerabilityReportTest2() throws Exception { + VulnerabilityReport expectedResponse = + VulnerabilityReport.newBuilder() + .setName(VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .addAllVulnerabilities(new ArrayList()) + .setUpdateTime(Timestamp.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = + "projects/project-2379/locations/location-2379/instances/instance-2379/vulnerabilityReport"; + + VulnerabilityReport actualResponse = client.getVulnerabilityReport(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 getVulnerabilityReportExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = + "projects/project-2379/locations/location-2379/instances/instance-2379/vulnerabilityReport"; + client.getVulnerabilityReport(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listVulnerabilityReportsTest() throws Exception { + VulnerabilityReport responsesElement = VulnerabilityReport.newBuilder().build(); + ListVulnerabilityReportsResponse expectedResponse = + ListVulnerabilityReportsResponse.newBuilder() + .setNextPageToken("") + .addAllVulnerabilityReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + + ListVulnerabilityReportsPagedResponse pagedListResponse = + client.listVulnerabilityReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVulnerabilityReportsList().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 listVulnerabilityReportsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + client.listVulnerabilityReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listVulnerabilityReportsTest2() throws Exception { + VulnerabilityReport responsesElement = VulnerabilityReport.newBuilder().build(); + ListVulnerabilityReportsResponse expectedResponse = + ListVulnerabilityReportsResponse.newBuilder() + .setNextPageToken("") + .addAllVulnerabilityReports(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + + ListVulnerabilityReportsPagedResponse pagedListResponse = + client.listVulnerabilityReports(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getVulnerabilityReportsList().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 listVulnerabilityReportsExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-5197/locations/location-5197/instances/instance-5197"; + client.listVulnerabilityReports(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClientHttpJsonTest.java b/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClientHttpJsonTest.java new file mode 100644 index 00000000..bd55af09 --- /dev/null +++ b/google-cloud-os-config/src/test/java/com/google/cloud/osconfig/v1beta/OsConfigServiceClientHttpJsonTest.java @@ -0,0 +1,1447 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta; + +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListGuestPoliciesPagedResponse; +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListPatchDeploymentsPagedResponse; +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListPatchJobInstanceDetailsPagedResponse; +import static com.google.cloud.osconfig.v1beta.OsConfigServiceClient.ListPatchJobsPagedResponse; + +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.osconfig.v1beta.stub.HttpJsonOsConfigServiceStub; +import com.google.common.collect.Lists; +import com.google.protobuf.Duration; +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.List; +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 OsConfigServiceClientHttpJsonTest { + private static MockHttpService mockService; + private static OsConfigServiceClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonOsConfigServiceStub.getMethodDescriptors(), + OsConfigServiceSettings.getDefaultEndpoint()); + OsConfigServiceSettings settings = + OsConfigServiceSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + OsConfigServiceSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = OsConfigServiceClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void executePatchJobTest() throws Exception { + PatchJobs.PatchJob expectedResponse = + PatchJobs.PatchJob.newBuilder() + .setName("name3373707") + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setInstanceDetailsSummary( + PatchJobs.PatchJob.InstanceDetailsSummary.newBuilder().build()) + .setDryRun(true) + .setErrorMessage("errorMessage1203236063") + .setPercentComplete(-1960969229) + .setPatchDeployment("patchDeployment1500445997") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent("projects/project-2353") + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + + PatchJobs.PatchJob actualResponse = client.executePatchJob(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void executePatchJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent("projects/project-2353") + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + client.executePatchJob(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPatchJobTest() throws Exception { + PatchJobs.PatchJob expectedResponse = + PatchJobs.PatchJob.newBuilder() + .setName("name3373707") + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setInstanceDetailsSummary( + PatchJobs.PatchJob.InstanceDetailsSummary.newBuilder().build()) + .setDryRun(true) + .setErrorMessage("errorMessage1203236063") + .setPercentComplete(-1960969229) + .setPatchDeployment("patchDeployment1500445997") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobs.GetPatchJobRequest request = + PatchJobs.GetPatchJobRequest.newBuilder() + .setName("projects/project-3014/patchJobs/patchJob-3014") + .build(); + + PatchJobs.PatchJob actualResponse = client.getPatchJob(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getPatchJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobs.GetPatchJobRequest request = + PatchJobs.GetPatchJobRequest.newBuilder() + .setName("projects/project-3014/patchJobs/patchJob-3014") + .build(); + client.getPatchJob(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void cancelPatchJobTest() throws Exception { + PatchJobs.PatchJob expectedResponse = + PatchJobs.PatchJob.newBuilder() + .setName("name3373707") + .setDisplayName("displayName1714148973") + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setInstanceDetailsSummary( + PatchJobs.PatchJob.InstanceDetailsSummary.newBuilder().build()) + .setDryRun(true) + .setErrorMessage("errorMessage1203236063") + .setPercentComplete(-1960969229) + .setPatchDeployment("patchDeployment1500445997") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder() + .setName("projects/project-3014/patchJobs/patchJob-3014") + .build(); + + PatchJobs.PatchJob actualResponse = client.cancelPatchJob(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void cancelPatchJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder() + .setName("projects/project-3014/patchJobs/patchJob-3014") + .build(); + client.cancelPatchJob(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchJobsTest() throws Exception { + PatchJobs.PatchJob responsesElement = PatchJobs.PatchJob.newBuilder().build(); + PatchJobs.ListPatchJobsResponse expectedResponse = + PatchJobs.ListPatchJobsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchJobs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent("projects/project-2353") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + + ListPatchJobsPagedResponse pagedListResponse = client.listPatchJobs(request); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchJobsList().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 listPatchJobsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent("projects/project-2353") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + client.listPatchJobs(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchJobInstanceDetailsTest() throws Exception { + PatchJobs.PatchJobInstanceDetails responsesElement = + PatchJobs.PatchJobInstanceDetails.newBuilder().build(); + PatchJobs.ListPatchJobInstanceDetailsResponse expectedResponse = + PatchJobs.ListPatchJobInstanceDetailsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchJobInstanceDetails(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-1881/patchJobs/patchJob-1881"; + + ListPatchJobInstanceDetailsPagedResponse pagedListResponse = + client.listPatchJobInstanceDetails(parent); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchJobInstanceDetailsList().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 listPatchJobInstanceDetailsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-1881/patchJobs/patchJob-1881"; + client.listPatchJobInstanceDetails(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createPatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeployments.CreatePatchDeploymentRequest request = + PatchDeployments.CreatePatchDeploymentRequest.newBuilder() + .setParent("projects/project-2353") + .setPatchDeploymentId("patchDeploymentId-1180405976") + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .build(); + + PatchDeployments.PatchDeployment actualResponse = client.createPatchDeployment(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void createPatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeployments.CreatePatchDeploymentRequest request = + PatchDeployments.CreatePatchDeploymentRequest.newBuilder() + .setParent("projects/project-2353") + .setPatchDeploymentId("patchDeploymentId-1180405976") + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .build(); + client.createPatchDeployment(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getPatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeployments.GetPatchDeploymentRequest request = + PatchDeployments.GetPatchDeploymentRequest.newBuilder() + .setName("projects/project-2608/patchDeployments/patchDeployment-2608") + .build(); + + PatchDeployments.PatchDeployment actualResponse = client.getPatchDeployment(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void getPatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeployments.GetPatchDeploymentRequest request = + PatchDeployments.GetPatchDeploymentRequest.newBuilder() + .setName("projects/project-2608/patchDeployments/patchDeployment-2608") + .build(); + client.getPatchDeployment(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listPatchDeploymentsTest() throws Exception { + PatchDeployments.PatchDeployment responsesElement = + PatchDeployments.PatchDeployment.newBuilder().build(); + PatchDeployments.ListPatchDeploymentsResponse expectedResponse = + PatchDeployments.ListPatchDeploymentsResponse.newBuilder() + .setNextPageToken("") + .addAllPatchDeployments(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent("projects/project-2353") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + + ListPatchDeploymentsPagedResponse pagedListResponse = client.listPatchDeployments(request); + + List resources = + Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getPatchDeploymentsList().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 listPatchDeploymentsExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent("projects/project-2353") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + client.listPatchDeployments(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deletePatchDeploymentTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + PatchDeployments.DeletePatchDeploymentRequest request = + PatchDeployments.DeletePatchDeploymentRequest.newBuilder() + .setName("projects/project-2608/patchDeployments/patchDeployment-2608") + .build(); + + client.deletePatchDeployment(request); + + 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 deletePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeployments.DeletePatchDeploymentRequest request = + PatchDeployments.DeletePatchDeploymentRequest.newBuilder() + .setName("projects/project-2608/patchDeployments/patchDeployment-2608") + .build(); + client.deletePatchDeployment(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updatePatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + PatchDeployments.PatchDeployment actualResponse = + client.updatePatchDeployment(patchDeployment, 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 updatePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updatePatchDeployment(patchDeployment, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pausePatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + + PatchDeployments.PatchDeployment actualResponse = client.pausePatchDeployment(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 pausePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + client.pausePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pausePatchDeploymentTest2() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + + PatchDeployments.PatchDeployment actualResponse = client.pausePatchDeployment(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 pausePatchDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + client.pausePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resumePatchDeploymentTest() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + + PatchDeployments.PatchDeployment actualResponse = client.resumePatchDeployment(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 resumePatchDeploymentExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + client.resumePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resumePatchDeploymentTest2() throws Exception { + PatchDeployments.PatchDeployment expectedResponse = + PatchDeployments.PatchDeployment.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setLastExecuteTime(Timestamp.newBuilder().build()) + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + + PatchDeployments.PatchDeployment actualResponse = client.resumePatchDeployment(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 resumePatchDeploymentExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-2608/patchDeployments/patchDeployment-2608"; + client.resumePatchDeployment(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createGuestPolicyTest() throws Exception { + GuestPolicies.GuestPolicy expectedResponse = + GuestPolicies.GuestPolicy.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAssignment(GuestPolicies.Assignment.newBuilder().build()) + .addAllPackages(new ArrayList()) + .addAllPackageRepositories(new ArrayList()) + .addAllRecipes(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + GuestPolicies.GuestPolicy guestPolicy = GuestPolicies.GuestPolicy.newBuilder().build(); + + GuestPolicies.GuestPolicy actualResponse = client.createGuestPolicy(parent, guestPolicy); + 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 createGuestPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + GuestPolicies.GuestPolicy guestPolicy = GuestPolicies.GuestPolicy.newBuilder().build(); + client.createGuestPolicy(parent, guestPolicy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createGuestPolicyTest2() throws Exception { + GuestPolicies.GuestPolicy expectedResponse = + GuestPolicies.GuestPolicy.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAssignment(GuestPolicies.Assignment.newBuilder().build()) + .addAllPackages(new ArrayList()) + .addAllPackageRepositories(new ArrayList()) + .addAllRecipes(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + GuestPolicies.GuestPolicy guestPolicy = GuestPolicies.GuestPolicy.newBuilder().build(); + + GuestPolicies.GuestPolicy actualResponse = client.createGuestPolicy(parent, guestPolicy); + 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 createGuestPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + GuestPolicies.GuestPolicy guestPolicy = GuestPolicies.GuestPolicy.newBuilder().build(); + client.createGuestPolicy(parent, guestPolicy); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getGuestPolicyTest() throws Exception { + GuestPolicies.GuestPolicy expectedResponse = + GuestPolicies.GuestPolicy.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAssignment(GuestPolicies.Assignment.newBuilder().build()) + .addAllPackages(new ArrayList()) + .addAllPackageRepositories(new ArrayList()) + .addAllRecipes(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + GuestPolicyName name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]"); + + GuestPolicies.GuestPolicy actualResponse = client.getGuestPolicy(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 getGuestPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GuestPolicyName name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]"); + client.getGuestPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getGuestPolicyTest2() throws Exception { + GuestPolicies.GuestPolicy expectedResponse = + GuestPolicies.GuestPolicy.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAssignment(GuestPolicies.Assignment.newBuilder().build()) + .addAllPackages(new ArrayList()) + .addAllPackageRepositories(new ArrayList()) + .addAllRecipes(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-6612/guestPolicies/guestPolicie-6612"; + + GuestPolicies.GuestPolicy actualResponse = client.getGuestPolicy(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 getGuestPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-6612/guestPolicies/guestPolicie-6612"; + client.getGuestPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listGuestPoliciesTest() throws Exception { + GuestPolicies.GuestPolicy responsesElement = GuestPolicies.GuestPolicy.newBuilder().build(); + GuestPolicies.ListGuestPoliciesResponse expectedResponse = + GuestPolicies.ListGuestPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllGuestPolicies(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + ProjectName parent = ProjectName.of("[PROJECT]"); + + ListGuestPoliciesPagedResponse pagedListResponse = client.listGuestPolicies(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGuestPoliciesList().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 listGuestPoliciesExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + ProjectName parent = ProjectName.of("[PROJECT]"); + client.listGuestPolicies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listGuestPoliciesTest2() throws Exception { + GuestPolicies.GuestPolicy responsesElement = GuestPolicies.GuestPolicy.newBuilder().build(); + GuestPolicies.ListGuestPoliciesResponse expectedResponse = + GuestPolicies.ListGuestPoliciesResponse.newBuilder() + .setNextPageToken("") + .addAllGuestPolicies(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-2353"; + + ListGuestPoliciesPagedResponse pagedListResponse = client.listGuestPolicies(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getGuestPoliciesList().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 listGuestPoliciesExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String parent = "projects/project-2353"; + client.listGuestPolicies(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateGuestPolicyTest() throws Exception { + GuestPolicies.GuestPolicy expectedResponse = + GuestPolicies.GuestPolicy.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAssignment(GuestPolicies.Assignment.newBuilder().build()) + .addAllPackages(new ArrayList()) + .addAllPackageRepositories(new ArrayList()) + .addAllRecipes(new ArrayList()) + .setEtag("etag3123477") + .build(); + mockService.addResponse(expectedResponse); + + GuestPolicies.GuestPolicy guestPolicy = + GuestPolicies.GuestPolicy.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAssignment(GuestPolicies.Assignment.newBuilder().build()) + .addAllPackages(new ArrayList()) + .addAllPackageRepositories(new ArrayList()) + .addAllRecipes(new ArrayList()) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + GuestPolicies.GuestPolicy actualResponse = client.updateGuestPolicy(guestPolicy, 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 updateGuestPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GuestPolicies.GuestPolicy guestPolicy = + GuestPolicies.GuestPolicy.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .setDescription("description-1724546052") + .setCreateTime(Timestamp.newBuilder().build()) + .setUpdateTime(Timestamp.newBuilder().build()) + .setAssignment(GuestPolicies.Assignment.newBuilder().build()) + .addAllPackages(new ArrayList()) + .addAllPackageRepositories(new ArrayList()) + .addAllRecipes(new ArrayList()) + .setEtag("etag3123477") + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateGuestPolicy(guestPolicy, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteGuestPolicyTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + GuestPolicyName name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]"); + + client.deleteGuestPolicy(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 deleteGuestPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GuestPolicyName name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]"); + client.deleteGuestPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteGuestPolicyTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-6612/guestPolicies/guestPolicie-6612"; + + client.deleteGuestPolicy(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 deleteGuestPolicyExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-6612/guestPolicies/guestPolicie-6612"; + client.deleteGuestPolicy(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void lookupEffectiveGuestPolicyTest() throws Exception { + GuestPolicies.EffectiveGuestPolicy expectedResponse = + GuestPolicies.EffectiveGuestPolicy.newBuilder() + .addAllPackages(new ArrayList()) + .addAllPackageRepositories( + new ArrayList()) + .addAllSoftwareRecipes( + new ArrayList()) + .build(); + mockService.addResponse(expectedResponse); + + GuestPolicies.LookupEffectiveGuestPolicyRequest request = + GuestPolicies.LookupEffectiveGuestPolicyRequest.newBuilder() + .setInstance("projects/project-4489/zones/zone-4489/instances/instance-4489") + .setOsShortName("osShortName1253394339") + .setOsVersion("osVersion1812004436") + .setOsArchitecture("osArchitecture1339954519") + .build(); + + GuestPolicies.EffectiveGuestPolicy actualResponse = client.lookupEffectiveGuestPolicy(request); + Assert.assertEquals(expectedResponse, actualResponse); + + List actualRequests = mockService.getRequestPaths(); + Assert.assertEquals(1, actualRequests.size()); + + String apiClientHeaderKey = + mockService + .getRequestHeaders() + .get(ApiClientHeaderProvider.getDefaultApiClientHeaderKey()) + .iterator() + .next(); + Assert.assertTrue( + GaxHttpJsonProperties.getDefaultApiClientHeaderPattern() + .matcher(apiClientHeaderKey) + .matches()); + } + + @Test + public void lookupEffectiveGuestPolicyExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + GuestPolicies.LookupEffectiveGuestPolicyRequest request = + GuestPolicies.LookupEffectiveGuestPolicyRequest.newBuilder() + .setInstance("projects/project-4489/zones/zone-4489/instances/instance-4489") + .setOsShortName("osShortName1253394339") + .setOsVersion("osVersion1812004436") + .setOsArchitecture("osArchitecture1339954519") + .build(); + client.lookupEffectiveGuestPolicy(request); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/grpc-google-cloud-os-config-v1/pom.xml b/grpc-google-cloud-os-config-v1/pom.xml index 4fb70bf9..6b5445c6 100644 --- a/grpc-google-cloud-os-config-v1/pom.xml +++ b/grpc-google-cloud-os-config-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-os-config-v1 - 2.4.3 + 2.5.0 grpc-google-cloud-os-config-v1 GRPC library for grpc-google-cloud-os-config-v1 com.google.cloud google-cloud-os-config-parent - 2.4.3 + 2.5.0 diff --git a/grpc-google-cloud-os-config-v1alpha/pom.xml b/grpc-google-cloud-os-config-v1alpha/pom.xml index a535213f..11cf38a9 100644 --- a/grpc-google-cloud-os-config-v1alpha/pom.xml +++ b/grpc-google-cloud-os-config-v1alpha/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-os-config-v1alpha - 2.4.3 + 2.5.0 grpc-google-cloud-os-config-v1alpha GRPC library for google-cloud-os-config com.google.cloud google-cloud-os-config-parent - 2.4.3 + 2.5.0 diff --git a/grpc-google-cloud-os-config-v1beta/pom.xml b/grpc-google-cloud-os-config-v1beta/pom.xml index 743cf3e1..336fffe6 100644 --- a/grpc-google-cloud-os-config-v1beta/pom.xml +++ b/grpc-google-cloud-os-config-v1beta/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-os-config-v1beta - 2.4.3 + 2.5.0 grpc-google-cloud-os-config-v1beta GRPC library for google-cloud-os-config com.google.cloud google-cloud-os-config-parent - 2.4.3 + 2.5.0 diff --git a/pom.xml b/pom.xml index 6b4057b2..d53747c4 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-os-config-parent pom - 2.4.3 + 2.5.0 Google OS Config API Parent https://github.com/googleapis/java-os-config @@ -14,7 +14,7 @@ com.google.cloud google-cloud-shared-config - 1.4.0 + 1.5.0 @@ -61,43 +61,43 @@ com.google.cloud google-cloud-os-config - 2.4.3 + 2.5.0 com.google.api.grpc proto-google-cloud-os-config-v1beta - 2.4.3 + 2.5.0 com.google.api.grpc proto-google-cloud-os-config-v1alpha - 2.4.3 + 2.5.0 com.google.api.grpc grpc-google-cloud-os-config-v1alpha - 2.4.3 + 2.5.0 com.google.api.grpc grpc-google-cloud-os-config-v1beta - 2.4.3 + 2.5.0 com.google.api.grpc proto-google-cloud-os-config-v1 - 2.4.3 + 2.5.0 com.google.api.grpc grpc-google-cloud-os-config-v1 - 2.4.3 + 2.5.0 com.google.cloud google-cloud-shared-dependencies - 2.12.0 + 2.13.0 pom import diff --git a/proto-google-cloud-os-config-v1/pom.xml b/proto-google-cloud-os-config-v1/pom.xml index 73596748..036676b2 100644 --- a/proto-google-cloud-os-config-v1/pom.xml +++ b/proto-google-cloud-os-config-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-os-config-v1 - 2.4.3 + 2.5.0 proto-google-cloud-os-config-v1 PROTO library for proto-google-cloud-os-config-v1 com.google.cloud google-cloud-os-config-parent - 2.4.3 + 2.5.0 diff --git a/proto-google-cloud-os-config-v1alpha/pom.xml b/proto-google-cloud-os-config-v1alpha/pom.xml index 4142ad5d..f6ea7fdc 100644 --- a/proto-google-cloud-os-config-v1alpha/pom.xml +++ b/proto-google-cloud-os-config-v1alpha/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-os-config-v1alpha - 2.4.3 + 2.5.0 proto-google-cloud-os-config-v1alpha Proto library for google-cloud-os-config com.google.cloud google-cloud-os-config-parent - 2.4.3 + 2.5.0 diff --git a/proto-google-cloud-os-config-v1beta/pom.xml b/proto-google-cloud-os-config-v1beta/pom.xml index 39a0684c..f48e0d1a 100644 --- a/proto-google-cloud-os-config-v1beta/pom.xml +++ b/proto-google-cloud-os-config-v1beta/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-os-config-v1beta - 2.4.3 + 2.5.0 proto-google-cloud-os-config-v1beta Proto library for google-cloud-os-config com.google.cloud google-cloud-os-config-parent - 2.4.3 + 2.5.0 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index 63810638..390f806e 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-os-config - 2.4.3 + 2.5.0 diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/cancelpatchjob/AsyncCancelPatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/cancelpatchjob/AsyncCancelPatchJob.java new file mode 100644 index 00000000..934a9470 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/cancelpatchjob/AsyncCancelPatchJob.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_cancelpatchjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class AsyncCancelPatchJob { + + public static void main(String[] args) throws Exception { + asyncCancelPatchJob(); + } + + public static void asyncCancelPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.cancelPatchJobCallable().futureCall(request); + // Do something. + PatchJobs.PatchJob response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_cancelpatchjob_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/cancelpatchjob/SyncCancelPatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/cancelpatchjob/SyncCancelPatchJob.java new file mode 100644 index 00000000..6c80b7ca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/cancelpatchjob/SyncCancelPatchJob.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_cancelpatchjob_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class SyncCancelPatchJob { + + public static void main(String[] args) throws Exception { + syncCancelPatchJob(); + } + + public static void syncCancelPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .build(); + PatchJobs.PatchJob response = osConfigServiceClient.cancelPatchJob(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_cancelpatchjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..7668a0a0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.OsConfigServiceSettings; +import com.google.cloud.osconfig.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. + OsConfigServiceSettings osConfigServiceSettings = + OsConfigServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + OsConfigServiceClient osConfigServiceClient = + OsConfigServiceClient.create(osConfigServiceSettings); + } +} +// [END osconfig_v1_generated_osconfigserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..d450bea3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.OsConfigServiceSettings; + +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. + OsConfigServiceSettings osConfigServiceSettings = + OsConfigServiceSettings.newBuilder() + .setTransportChannelProvider( + OsConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + OsConfigServiceClient osConfigServiceClient = + OsConfigServiceClient.create(osConfigServiceSettings); + } +} +// [END osconfig_v1_generated_osconfigserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..fcca9285 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_create_setendpoint_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.OsConfigServiceSettings; +import com.google.cloud.osconfig.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. + OsConfigServiceSettings osConfigServiceSettings = + OsConfigServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + OsConfigServiceClient osConfigServiceClient = + OsConfigServiceClient.create(osConfigServiceSettings); + } +} +// [END osconfig_v1_generated_osconfigserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/AsyncCreatePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/AsyncCreatePatchDeployment.java new file mode 100644 index 00000000..39b9b03f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/AsyncCreatePatchDeployment.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class AsyncCreatePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncCreatePatchDeployment(); + } + + public static void asyncCreatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.CreatePatchDeploymentRequest request = + PatchDeployments.CreatePatchDeploymentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPatchDeploymentId("patchDeploymentId-1180405976") + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.createPatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeployment.java new file mode 100644 index 00000000..ac0268aa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeployment.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncCreatePatchDeployment { + + public static void main(String[] args) throws Exception { + syncCreatePatchDeployment(); + } + + public static void syncCreatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.CreatePatchDeploymentRequest request = + PatchDeployments.CreatePatchDeploymentRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPatchDeploymentId("patchDeploymentId-1180405976") + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.createPatchDeployment(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeploymentProjectnamePatchdeploymentspatchdeploymentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeploymentProjectnamePatchdeploymentspatchdeploymentString.java new file mode 100644 index 00000000..f541f503 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeploymentProjectnamePatchdeploymentspatchdeploymentString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_projectnamepatchdeploymentspatchdeploymentstring_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncCreatePatchDeploymentProjectnamePatchdeploymentspatchdeploymentString { + + public static void main(String[] args) throws Exception { + syncCreatePatchDeploymentProjectnamePatchdeploymentspatchdeploymentString(); + } + + public static void syncCreatePatchDeploymentProjectnamePatchdeploymentspatchdeploymentString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + String patchDeploymentId = "patchDeploymentId-1180405976"; + PatchDeployments.PatchDeployment response = + osConfigServiceClient.createPatchDeployment(parent, patchDeployment, patchDeploymentId); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_projectnamepatchdeploymentspatchdeploymentstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeploymentStringPatchdeploymentspatchdeploymentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeploymentStringPatchdeploymentspatchdeploymentString.java new file mode 100644 index 00000000..00902648 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeploymentStringPatchdeploymentspatchdeploymentString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_stringpatchdeploymentspatchdeploymentstring_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncCreatePatchDeploymentStringPatchdeploymentspatchdeploymentString { + + public static void main(String[] args) throws Exception { + syncCreatePatchDeploymentStringPatchdeploymentspatchdeploymentString(); + } + + public static void syncCreatePatchDeploymentStringPatchdeploymentspatchdeploymentString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + String patchDeploymentId = "patchDeploymentId-1180405976"; + PatchDeployments.PatchDeployment response = + osConfigServiceClient.createPatchDeployment(parent, patchDeployment, patchDeploymentId); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_createpatchdeployment_stringpatchdeploymentspatchdeploymentstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/AsyncDeletePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/AsyncDeletePatchDeployment.java new file mode 100644 index 00000000..17464655 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/AsyncDeletePatchDeployment.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.protobuf.Empty; + +public class AsyncDeletePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncDeletePatchDeployment(); + } + + public static void asyncDeletePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.DeletePatchDeploymentRequest request = + PatchDeployments.DeletePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.deletePatchDeploymentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeployment.java new file mode 100644 index 00000000..48adb1fb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.protobuf.Empty; + +public class SyncDeletePatchDeployment { + + public static void main(String[] args) throws Exception { + syncDeletePatchDeployment(); + } + + public static void syncDeletePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.DeletePatchDeploymentRequest request = + PatchDeployments.DeletePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + osConfigServiceClient.deletePatchDeployment(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeploymentPatchdeploymentname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeploymentPatchdeploymentname.java new file mode 100644 index 00000000..6d7abe79 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeploymentPatchdeploymentname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_patchdeploymentname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.protobuf.Empty; + +public class SyncDeletePatchDeploymentPatchdeploymentname { + + public static void main(String[] args) throws Exception { + syncDeletePatchDeploymentPatchdeploymentname(); + } + + public static void syncDeletePatchDeploymentPatchdeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + osConfigServiceClient.deletePatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_patchdeploymentname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeploymentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeploymentString.java new file mode 100644 index 00000000..0d111a59 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeploymentString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.protobuf.Empty; + +public class SyncDeletePatchDeploymentString { + + public static void main(String[] args) throws Exception { + syncDeletePatchDeploymentString(); + } + + public static void syncDeletePatchDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString(); + osConfigServiceClient.deletePatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_deletepatchdeployment_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/executepatchjob/AsyncExecutePatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/executepatchjob/AsyncExecutePatchJob.java new file mode 100644 index 00000000..99e1d521 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/executepatchjob/AsyncExecutePatchJob.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_executepatchjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.cloud.osconfig.v1.ProjectName; +import com.google.protobuf.Duration; + +public class AsyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + asyncExecutePatchJob(); + } + + public static void asyncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.executePatchJobCallable().futureCall(request); + // Do something. + PatchJobs.PatchJob response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_executepatchjob_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/executepatchjob/SyncExecutePatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/executepatchjob/SyncExecutePatchJob.java new file mode 100644 index 00000000..f01e3d0d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/executepatchjob/SyncExecutePatchJob.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_executepatchjob_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.cloud.osconfig.v1.ProjectName; +import com.google.protobuf.Duration; + +public class SyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + syncExecutePatchJob(); + } + + public static void syncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + PatchJobs.PatchJob response = osConfigServiceClient.executePatchJob(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_executepatchjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/AsyncGetPatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/AsyncGetPatchDeployment.java new file mode 100644 index 00000000..f2566ae9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/AsyncGetPatchDeployment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class AsyncGetPatchDeployment { + + public static void main(String[] args) throws Exception { + asyncGetPatchDeployment(); + } + + public static void asyncGetPatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.GetPatchDeploymentRequest request = + PatchDeployments.GetPatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.getPatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeployment.java new file mode 100644 index 00000000..9730eb8a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeployment.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncGetPatchDeployment { + + public static void main(String[] args) throws Exception { + syncGetPatchDeployment(); + } + + public static void syncGetPatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.GetPatchDeploymentRequest request = + PatchDeployments.GetPatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + PatchDeployments.PatchDeployment response = osConfigServiceClient.getPatchDeployment(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeploymentPatchdeploymentname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeploymentPatchdeploymentname.java new file mode 100644 index 00000000..e8b7086e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeploymentPatchdeploymentname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_patchdeploymentname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncGetPatchDeploymentPatchdeploymentname { + + public static void main(String[] args) throws Exception { + syncGetPatchDeploymentPatchdeploymentname(); + } + + public static void syncGetPatchDeploymentPatchdeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + PatchDeployments.PatchDeployment response = osConfigServiceClient.getPatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_patchdeploymentname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeploymentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeploymentString.java new file mode 100644 index 00000000..544cc078 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeploymentString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncGetPatchDeploymentString { + + public static void main(String[] args) throws Exception { + syncGetPatchDeploymentString(); + } + + public static void syncGetPatchDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString(); + PatchDeployments.PatchDeployment response = osConfigServiceClient.getPatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchdeployment_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/AsyncGetPatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/AsyncGetPatchJob.java new file mode 100644 index 00000000..9898a322 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/AsyncGetPatchJob.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class AsyncGetPatchJob { + + public static void main(String[] args) throws Exception { + asyncGetPatchJob(); + } + + public static void asyncGetPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.GetPatchJobRequest request = + PatchJobs.GetPatchJobRequest.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.getPatchJobCallable().futureCall(request); + // Do something. + PatchJobs.PatchJob response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchjob_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJob.java new file mode 100644 index 00000000..d230cb8a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJob.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchjob_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class SyncGetPatchJob { + + public static void main(String[] args) throws Exception { + syncGetPatchJob(); + } + + public static void syncGetPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.GetPatchJobRequest request = + PatchJobs.GetPatchJobRequest.newBuilder() + .setName(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .build(); + PatchJobs.PatchJob response = osConfigServiceClient.getPatchJob(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJobPatchjobname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJobPatchjobname.java new file mode 100644 index 00000000..d82c0808 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJobPatchjobname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchjob_patchjobname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class SyncGetPatchJobPatchjobname { + + public static void main(String[] args) throws Exception { + syncGetPatchJobPatchjobname(); + } + + public static void syncGetPatchJobPatchjobname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobName name = PatchJobName.of("[PROJECT]", "[PATCH_JOB]"); + PatchJobs.PatchJob response = osConfigServiceClient.getPatchJob(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchjob_patchjobname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJobString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJobString.java new file mode 100644 index 00000000..d0906ecd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/getpatchjob/SyncGetPatchJobString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_getpatchjob_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class SyncGetPatchJobString { + + public static void main(String[] args) throws Exception { + syncGetPatchJobString(); + } + + public static void syncGetPatchJobString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString(); + PatchJobs.PatchJob response = osConfigServiceClient.getPatchJob(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_getpatchjob_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeployments.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeployments.java new file mode 100644 index 00000000..713f2d2e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeployments.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class AsyncListPatchDeployments { + + public static void main(String[] args) throws Exception { + asyncListPatchDeployments(); + } + + public static void asyncListPatchDeployments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigServiceClient.listPatchDeploymentsPagedCallable().futureCall(request); + // Do something. + for (PatchDeployments.PatchDeployment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeploymentsPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeploymentsPaged.java new file mode 100644 index 00000000..bbdc4fca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeploymentsPaged.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_paged_async] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListPatchDeploymentsPaged { + + public static void main(String[] args) throws Exception { + asyncListPatchDeploymentsPaged(); + } + + public static void asyncListPatchDeploymentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + PatchDeployments.ListPatchDeploymentsResponse response = + osConfigServiceClient.listPatchDeploymentsCallable().call(request); + for (PatchDeployments.PatchDeployment element : response.getPatchDeploymentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeployments.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeployments.java new file mode 100644 index 00000000..fe538800 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeployments.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncListPatchDeployments { + + public static void main(String[] args) throws Exception { + syncListPatchDeployments(); + } + + public static void syncListPatchDeployments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (PatchDeployments.PatchDeployment element : + osConfigServiceClient.listPatchDeployments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeploymentsProjectname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeploymentsProjectname.java new file mode 100644 index 00000000..06763d3c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeploymentsProjectname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_projectname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncListPatchDeploymentsProjectname { + + public static void main(String[] args) throws Exception { + syncListPatchDeploymentsProjectname(); + } + + public static void syncListPatchDeploymentsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (PatchDeployments.PatchDeployment element : + osConfigServiceClient.listPatchDeployments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_projectname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeploymentsString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeploymentsString.java new file mode 100644 index 00000000..5c2d21e9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchdeployments/SyncListPatchDeploymentsString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncListPatchDeploymentsString { + + public static void main(String[] args) throws Exception { + syncListPatchDeploymentsString(); + } + + public static void syncListPatchDeploymentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (PatchDeployments.PatchDeployment element : + osConfigServiceClient.listPatchDeployments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchdeployments_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetails.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetails.java new file mode 100644 index 00000000..3c98250c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetails.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class AsyncListPatchJobInstanceDetails { + + public static void main(String[] args) throws Exception { + asyncListPatchJobInstanceDetails(); + } + + public static void asyncListPatchJobInstanceDetails() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobInstanceDetailsRequest request = + PatchJobs.ListPatchJobInstanceDetailsRequest.newBuilder() + .setParent(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigServiceClient.listPatchJobInstanceDetailsPagedCallable().futureCall(request); + // Do something. + for (PatchJobs.PatchJobInstanceDetails element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetailsPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetailsPaged.java new file mode 100644 index 00000000..11b15482 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetailsPaged.java @@ -0,0 +1,59 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_paged_async] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.common.base.Strings; + +public class AsyncListPatchJobInstanceDetailsPaged { + + public static void main(String[] args) throws Exception { + asyncListPatchJobInstanceDetailsPaged(); + } + + public static void asyncListPatchJobInstanceDetailsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobInstanceDetailsRequest request = + PatchJobs.ListPatchJobInstanceDetailsRequest.newBuilder() + .setParent(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + PatchJobs.ListPatchJobInstanceDetailsResponse response = + osConfigServiceClient.listPatchJobInstanceDetailsCallable().call(request); + for (PatchJobs.PatchJobInstanceDetails element : + response.getPatchJobInstanceDetailsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetails.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetails.java new file mode 100644 index 00000000..a8369c41 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetails.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class SyncListPatchJobInstanceDetails { + + public static void main(String[] args) throws Exception { + syncListPatchJobInstanceDetails(); + } + + public static void syncListPatchJobInstanceDetails() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobInstanceDetailsRequest request = + PatchJobs.ListPatchJobInstanceDetailsRequest.newBuilder() + .setParent(PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (PatchJobs.PatchJobInstanceDetails element : + osConfigServiceClient.listPatchJobInstanceDetails(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsPatchjobname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsPatchjobname.java new file mode 100644 index 00000000..721de14c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsPatchjobname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_patchjobname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class SyncListPatchJobInstanceDetailsPatchjobname { + + public static void main(String[] args) throws Exception { + syncListPatchJobInstanceDetailsPatchjobname(); + } + + public static void syncListPatchJobInstanceDetailsPatchjobname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobName parent = PatchJobName.of("[PROJECT]", "[PATCH_JOB]"); + for (PatchJobs.PatchJobInstanceDetails element : + osConfigServiceClient.listPatchJobInstanceDetails(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_patchjobname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsString.java new file mode 100644 index 00000000..f8c62abd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobName; +import com.google.cloud.osconfig.v1.PatchJobs; + +public class SyncListPatchJobInstanceDetailsString { + + public static void main(String[] args) throws Exception { + syncListPatchJobInstanceDetailsString(); + } + + public static void syncListPatchJobInstanceDetailsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String parent = PatchJobName.of("[PROJECT]", "[PATCH_JOB]").toString(); + for (PatchJobs.PatchJobInstanceDetails element : + osConfigServiceClient.listPatchJobInstanceDetails(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobinstancedetails_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/AsyncListPatchJobs.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/AsyncListPatchJobs.java new file mode 100644 index 00000000..903aaa26 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/AsyncListPatchJobs.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.cloud.osconfig.v1.ProjectName; + +public class AsyncListPatchJobs { + + public static void main(String[] args) throws Exception { + asyncListPatchJobs(); + } + + public static void asyncListPatchJobs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigServiceClient.listPatchJobsPagedCallable().futureCall(request); + // Do something. + for (PatchJobs.PatchJob element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobs_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/AsyncListPatchJobsPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/AsyncListPatchJobsPaged.java new file mode 100644 index 00000000..a983ff62 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/AsyncListPatchJobsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobs_paged_async] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.cloud.osconfig.v1.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListPatchJobsPaged { + + public static void main(String[] args) throws Exception { + asyncListPatchJobsPaged(); + } + + public static void asyncListPatchJobsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + PatchJobs.ListPatchJobsResponse response = + osConfigServiceClient.listPatchJobsCallable().call(request); + for (PatchJobs.PatchJob element : response.getPatchJobsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobs.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobs.java new file mode 100644 index 00000000..c65234d5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobs.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobs_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncListPatchJobs { + + public static void main(String[] args) throws Exception { + syncListPatchJobs(); + } + + public static void syncListPatchJobs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (PatchJobs.PatchJob element : osConfigServiceClient.listPatchJobs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobs_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobsProjectname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobsProjectname.java new file mode 100644 index 00000000..c6b6d977 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobsProjectname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobs_projectname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncListPatchJobsProjectname { + + public static void main(String[] args) throws Exception { + syncListPatchJobsProjectname(); + } + + public static void syncListPatchJobsProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (PatchJobs.PatchJob element : osConfigServiceClient.listPatchJobs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobs_projectname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobsString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobsString.java new file mode 100644 index 00000000..93e9250f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/listpatchjobs/SyncListPatchJobsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_listpatchjobs_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchJobs; +import com.google.cloud.osconfig.v1.ProjectName; + +public class SyncListPatchJobsString { + + public static void main(String[] args) throws Exception { + syncListPatchJobsString(); + } + + public static void syncListPatchJobsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (PatchJobs.PatchJob element : osConfigServiceClient.listPatchJobs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_listpatchjobs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/AsyncPausePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/AsyncPausePatchDeployment.java new file mode 100644 index 00000000..afc3ea19 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/AsyncPausePatchDeployment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class AsyncPausePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncPausePatchDeployment(); + } + + public static void asyncPausePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.PausePatchDeploymentRequest request = + PatchDeployments.PausePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.pausePatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeployment.java new file mode 100644 index 00000000..bc0399c3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncPausePatchDeployment { + + public static void main(String[] args) throws Exception { + syncPausePatchDeployment(); + } + + public static void syncPausePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.PausePatchDeploymentRequest request = + PatchDeployments.PausePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.pausePatchDeployment(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentPatchdeploymentname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentPatchdeploymentname.java new file mode 100644 index 00000000..a92d2955 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentPatchdeploymentname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_patchdeploymentname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncPausePatchDeploymentPatchdeploymentname { + + public static void main(String[] args) throws Exception { + syncPausePatchDeploymentPatchdeploymentname(); + } + + public static void syncPausePatchDeploymentPatchdeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + PatchDeployments.PatchDeployment response = osConfigServiceClient.pausePatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_patchdeploymentname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentString.java new file mode 100644 index 00000000..d7a30e34 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncPausePatchDeploymentString { + + public static void main(String[] args) throws Exception { + syncPausePatchDeploymentString(); + } + + public static void syncPausePatchDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString(); + PatchDeployments.PatchDeployment response = osConfigServiceClient.pausePatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_pausepatchdeployment_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/AsyncResumePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/AsyncResumePatchDeployment.java new file mode 100644 index 00000000..939fdc4a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/AsyncResumePatchDeployment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class AsyncResumePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncResumePatchDeployment(); + } + + public static void asyncResumePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ResumePatchDeploymentRequest request = + PatchDeployments.ResumePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.resumePatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeployment.java new file mode 100644 index 00000000..0238f217 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncResumePatchDeployment { + + public static void main(String[] args) throws Exception { + syncResumePatchDeployment(); + } + + public static void syncResumePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ResumePatchDeploymentRequest request = + PatchDeployments.ResumePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.resumePatchDeployment(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentPatchdeploymentname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentPatchdeploymentname.java new file mode 100644 index 00000000..d76083ab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentPatchdeploymentname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_patchdeploymentname_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncResumePatchDeploymentPatchdeploymentname { + + public static void main(String[] args) throws Exception { + syncResumePatchDeploymentPatchdeploymentname(); + } + + public static void syncResumePatchDeploymentPatchdeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + PatchDeployments.PatchDeployment response = osConfigServiceClient.resumePatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_patchdeploymentname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentString.java new file mode 100644 index 00000000..350233d7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_string_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeploymentName; +import com.google.cloud.osconfig.v1.PatchDeployments; + +public class SyncResumePatchDeploymentString { + + public static void main(String[] args) throws Exception { + syncResumePatchDeploymentString(); + } + + public static void syncResumePatchDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString(); + PatchDeployments.PatchDeployment response = osConfigServiceClient.resumePatchDeployment(name); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_resumepatchdeployment_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/AsyncUpdatePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/AsyncUpdatePatchDeployment.java new file mode 100644 index 00000000..e395bcfe --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/AsyncUpdatePatchDeployment.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_updatepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.protobuf.FieldMask; + +public class AsyncUpdatePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncUpdatePatchDeployment(); + } + + public static void asyncUpdatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.UpdatePatchDeploymentRequest request = + PatchDeployments.UpdatePatchDeploymentRequest.newBuilder() + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.updatePatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_updatepatchdeployment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeployment.java new file mode 100644 index 00000000..87ec085c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeployment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_updatepatchdeployment_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.protobuf.FieldMask; + +public class SyncUpdatePatchDeployment { + + public static void main(String[] args) throws Exception { + syncUpdatePatchDeployment(); + } + + public static void syncUpdatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.UpdatePatchDeploymentRequest request = + PatchDeployments.UpdatePatchDeploymentRequest.newBuilder() + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.updatePatchDeployment(request); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_updatepatchdeployment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask.java new file mode 100644 index 00000000..e247e106 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigserviceclient_updatepatchdeployment_patchdeploymentspatchdeploymentfieldmask_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceClient; +import com.google.cloud.osconfig.v1.PatchDeployments; +import com.google.protobuf.FieldMask; + +public class SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask(); + } + + public static void syncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.updatePatchDeployment(patchDeployment, updateMask); + } + } +} +// [END osconfig_v1_generated_osconfigserviceclient_updatepatchdeployment_patchdeploymentspatchdeploymentfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigservicesettings/executepatchjob/SyncExecutePatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigservicesettings/executepatchjob/SyncExecutePatchJob.java new file mode 100644 index 00000000..a94e2601 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigservicesettings/executepatchjob/SyncExecutePatchJob.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigservicesettings_executepatchjob_sync] +import com.google.cloud.osconfig.v1.OsConfigServiceSettings; +import java.time.Duration; + +public class SyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + syncExecutePatchJob(); + } + + public static void syncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigServiceSettings.Builder osConfigServiceSettingsBuilder = + OsConfigServiceSettings.newBuilder(); + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .setRetrySettings( + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigServiceSettings osConfigServiceSettings = osConfigServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1_generated_osconfigservicesettings_executepatchjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..ab5bad56 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceSettings; +import com.google.cloud.osconfig.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. + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + OsConfigZonalServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..7b15dcea --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceSettings; + +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. + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + OsConfigZonalServiceSettings.newBuilder() + .setTransportChannelProvider( + OsConfigZonalServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..20560c38 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_create_setendpoint_sync] +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceSettings; +import com.google.cloud.osconfig.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. + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + OsConfigZonalServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignment.java new file mode 100644 index 00000000..b29015de --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignment.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.longrunning.Operation; + +public class AsyncCreateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncCreateOSPolicyAssignment(); + } + + public static void asyncCreateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + CreateOSPolicyAssignmentRequest request = + CreateOSPolicyAssignmentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074") + .build(); + ApiFuture future = + osConfigZonalServiceClient.createOSPolicyAssignmentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignmentLRO.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignmentLRO.java new file mode 100644 index 00000000..3eee2c27 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignmentLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncCreateOSPolicyAssignmentLRO { + + public static void main(String[] args) throws Exception { + asyncCreateOSPolicyAssignmentLRO(); + } + + public static void asyncCreateOSPolicyAssignmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + CreateOSPolicyAssignmentRequest request = + CreateOSPolicyAssignmentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074") + .build(); + OperationFuture future = + osConfigZonalServiceClient + .createOSPolicyAssignmentOperationCallable() + .futureCall(request); + // Do something. + OSPolicyAssignment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignment.java new file mode 100644 index 00000000..5ab163db --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignment.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_sync] +import com.google.cloud.osconfig.v1.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncCreateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncCreateOSPolicyAssignment(); + } + + public static void syncCreateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + CreateOSPolicyAssignmentRequest request = + CreateOSPolicyAssignmentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074") + .build(); + OSPolicyAssignment response = + osConfigZonalServiceClient.createOSPolicyAssignmentAsync(request).get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString.java new file mode 100644 index 00000000..eadbb051 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_locationnameospolicyassignmentstring_sync] +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString { + + public static void main(String[] args) throws Exception { + syncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString(); + } + + public static void syncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + OSPolicyAssignment response = + osConfigZonalServiceClient + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_locationnameospolicyassignmentstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentStringOspolicyassignmentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentStringOspolicyassignmentString.java new file mode 100644 index 00000000..fd223f0f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentStringOspolicyassignmentString.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_stringospolicyassignmentstring_sync] +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncCreateOSPolicyAssignmentStringOspolicyassignmentString { + + public static void main(String[] args) throws Exception { + syncCreateOSPolicyAssignmentStringOspolicyassignmentString(); + } + + public static void syncCreateOSPolicyAssignmentStringOspolicyassignmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + OSPolicyAssignment response = + osConfigZonalServiceClient + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_createospolicyassignment_stringospolicyassignmentstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignment.java new file mode 100644 index 00000000..dc5706d4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignment.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncDeleteOSPolicyAssignment(); + } + + public static void asyncDeleteOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + DeleteOSPolicyAssignmentRequest request = + DeleteOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.deleteOSPolicyAssignmentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignmentLRO.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignmentLRO.java new file mode 100644 index 00000000..f156c32c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignmentLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteOSPolicyAssignmentLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteOSPolicyAssignmentLRO(); + } + + public static void asyncDeleteOSPolicyAssignmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + DeleteOSPolicyAssignmentRequest request = + DeleteOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + OperationFuture future = + osConfigZonalServiceClient + .deleteOSPolicyAssignmentOperationCallable() + .futureCall(request); + // Do something. + future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignment.java new file mode 100644 index 00000000..ede37b68 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_sync] +import com.google.cloud.osconfig.v1.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncDeleteOSPolicyAssignment(); + } + + public static void syncDeleteOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + DeleteOSPolicyAssignmentRequest request = + DeleteOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(request).get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentOspolicyassignmentname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentOspolicyassignmentname.java new file mode 100644 index 00000000..f3c99ff9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentOspolicyassignmentname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_ospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteOSPolicyAssignmentOspolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncDeleteOSPolicyAssignmentOspolicyassignmentname(); + } + + public static void syncDeleteOSPolicyAssignmentOspolicyassignmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(name).get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_ospolicyassignmentname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentString.java new file mode 100644 index 00000000..3ed8c00f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_string_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteOSPolicyAssignmentString { + + public static void main(String[] args) throws Exception { + syncDeleteOSPolicyAssignmentString(); + } + + public static void syncDeleteOSPolicyAssignmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]").toString(); + osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(name).get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_deleteospolicyassignment_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/AsyncGetInventory.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/AsyncGetInventory.java new file mode 100644 index 00000000..fa59f18e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/AsyncGetInventory.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getinventory_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.GetInventoryRequest; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.InventoryName; +import com.google.cloud.osconfig.v1.InventoryView; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncGetInventory { + + public static void main(String[] args) throws Exception { + asyncGetInventory(); + } + + public static void asyncGetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetInventoryRequest request = + GetInventoryRequest.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setView(InventoryView.forNumber(0)) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getInventoryCallable().futureCall(request); + // Do something. + Inventory response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getinventory_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventory.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventory.java new file mode 100644 index 00000000..9062f4d6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventory.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getinventory_sync] +import com.google.cloud.osconfig.v1.GetInventoryRequest; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.InventoryName; +import com.google.cloud.osconfig.v1.InventoryView; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetInventory { + + public static void main(String[] args) throws Exception { + syncGetInventory(); + } + + public static void syncGetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetInventoryRequest request = + GetInventoryRequest.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setView(InventoryView.forNumber(0)) + .build(); + Inventory response = osConfigZonalServiceClient.getInventory(request); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getinventory_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventoryInventoryname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventoryInventoryname.java new file mode 100644 index 00000000..32f45585 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventoryInventoryname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getinventory_inventoryname_sync] +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.InventoryName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetInventoryInventoryname { + + public static void main(String[] args) throws Exception { + syncGetInventoryInventoryname(); + } + + public static void syncGetInventoryInventoryname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InventoryName name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + Inventory response = osConfigZonalServiceClient.getInventory(name); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getinventory_inventoryname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventoryString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventoryString.java new file mode 100644 index 00000000..85e4f87d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getinventory/SyncGetInventoryString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getinventory_string_sync] +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.InventoryName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetInventoryString { + + public static void main(String[] args) throws Exception { + syncGetInventoryString(); + } + + public static void syncGetInventoryString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + Inventory response = osConfigZonalServiceClient.getInventory(name); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getinventory_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/AsyncGetOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/AsyncGetOSPolicyAssignment.java new file mode 100644 index 00000000..ca2dec87 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/AsyncGetOSPolicyAssignment.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncGetOSPolicyAssignment(); + } + + public static void asyncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentRequest request = + GetOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getOSPolicyAssignmentCallable().futureCall(request); + // Do something. + OSPolicyAssignment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignment.java new file mode 100644 index 00000000..6bbf46e2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_sync] +import com.google.cloud.osconfig.v1.GetOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignment(); + } + + public static void syncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentRequest request = + GetOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(request); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentOspolicyassignmentname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentOspolicyassignmentname.java new file mode 100644 index 00000000..a488cbcd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentOspolicyassignmentname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_ospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentOspolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentOspolicyassignmentname(); + } + + public static void syncGetOSPolicyAssignmentOspolicyassignmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(name); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_ospolicyassignmentname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentString.java new file mode 100644 index 00000000..2904b57e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_string_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentString { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentString(); + } + + public static void syncGetOSPolicyAssignmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]").toString(); + OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(name); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignment_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/AsyncGetOSPolicyAssignmentReport.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/AsyncGetOSPolicyAssignmentReport.java new file mode 100644 index 00000000..f88f717a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/AsyncGetOSPolicyAssignmentReport.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncGetOSPolicyAssignmentReport { + + public static void main(String[] args) throws Exception { + asyncGetOSPolicyAssignmentReport(); + } + + public static void asyncGetOSPolicyAssignmentReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentReportRequest request = + GetOSPolicyAssignmentReportRequest.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getOSPolicyAssignmentReportCallable().futureCall(request); + // Do something. + OSPolicyAssignmentReport response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReport.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReport.java new file mode 100644 index 00000000..59fce3ba --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReport.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_sync] +import com.google.cloud.osconfig.v1.GetOSPolicyAssignmentReportRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentReport { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentReport(); + } + + public static void syncGetOSPolicyAssignmentReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentReportRequest request = + GetOSPolicyAssignmentReportRequest.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .build(); + OSPolicyAssignmentReport response = + osConfigZonalServiceClient.getOSPolicyAssignmentReport(request); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname.java new file mode 100644 index 00000000..101dd291 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_ospolicyassignmentreportname_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentReportOspolicyassignmentreportname(); + } + + public static void syncGetOSPolicyAssignmentReportOspolicyassignmentreportname() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentReportName name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + OSPolicyAssignmentReport response = + osConfigZonalServiceClient.getOSPolicyAssignmentReport(name); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_ospolicyassignmentreportname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportString.java new file mode 100644 index 00000000..2f823797 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_string_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentReportString { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentReportString(); + } + + public static void syncGetOSPolicyAssignmentReportString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString(); + OSPolicyAssignmentReport response = + osConfigZonalServiceClient.getOSPolicyAssignmentReport(name); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getospolicyassignmentreport_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/AsyncGetVulnerabilityReport.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/AsyncGetVulnerabilityReport.java new file mode 100644 index 00000000..fff8c732 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/AsyncGetVulnerabilityReport.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.GetVulnerabilityReportRequest; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; +import com.google.cloud.osconfig.v1.VulnerabilityReportName; + +public class AsyncGetVulnerabilityReport { + + public static void main(String[] args) throws Exception { + asyncGetVulnerabilityReport(); + } + + public static void asyncGetVulnerabilityReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetVulnerabilityReportRequest request = + GetVulnerabilityReportRequest.newBuilder() + .setName( + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getVulnerabilityReportCallable().futureCall(request); + // Do something. + VulnerabilityReport response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReport.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReport.java new file mode 100644 index 00000000..1ebdcfd3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReport.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_sync] +import com.google.cloud.osconfig.v1.GetVulnerabilityReportRequest; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; +import com.google.cloud.osconfig.v1.VulnerabilityReportName; + +public class SyncGetVulnerabilityReport { + + public static void main(String[] args) throws Exception { + syncGetVulnerabilityReport(); + } + + public static void syncGetVulnerabilityReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetVulnerabilityReportRequest request = + GetVulnerabilityReportRequest.newBuilder() + .setName( + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + VulnerabilityReport response = osConfigZonalServiceClient.getVulnerabilityReport(request); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportString.java new file mode 100644 index 00000000..15ab78a0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_string_sync] +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; +import com.google.cloud.osconfig.v1.VulnerabilityReportName; + +public class SyncGetVulnerabilityReportString { + + public static void main(String[] args) throws Exception { + syncGetVulnerabilityReportString(); + } + + public static void syncGetVulnerabilityReportString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + VulnerabilityReport response = osConfigZonalServiceClient.getVulnerabilityReport(name); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportVulnerabilityreportname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportVulnerabilityreportname.java new file mode 100644 index 00000000..76700335 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportVulnerabilityreportname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_vulnerabilityreportname_sync] +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; +import com.google.cloud.osconfig.v1.VulnerabilityReportName; + +public class SyncGetVulnerabilityReportVulnerabilityreportname { + + public static void main(String[] args) throws Exception { + syncGetVulnerabilityReportVulnerabilityreportname(); + } + + public static void syncGetVulnerabilityReportVulnerabilityreportname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + VulnerabilityReportName name = + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + VulnerabilityReport response = osConfigZonalServiceClient.getVulnerabilityReport(name); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_getvulnerabilityreport_vulnerabilityreportname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/AsyncListInventories.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/AsyncListInventories.java new file mode 100644 index 00000000..e2baa96e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/AsyncListInventories.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.InventoryView; +import com.google.cloud.osconfig.v1.ListInventoriesRequest; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncListInventories { + + public static void main(String[] args) throws Exception { + asyncListInventories(); + } + + public static void asyncListInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInventoriesRequest request = + ListInventoriesRequest.newBuilder() + .setParent( + InstanceName.ofProjectLocationInstanceName( + "[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setView(InventoryView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigZonalServiceClient.listInventoriesPagedCallable().futureCall(request); + // Do something. + for (Inventory element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listinventories_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/AsyncListInventoriesPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/AsyncListInventoriesPaged.java new file mode 100644 index 00000000..65e89726 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/AsyncListInventoriesPaged.java @@ -0,0 +1,66 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listinventories_paged_async] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.InventoryView; +import com.google.cloud.osconfig.v1.ListInventoriesRequest; +import com.google.cloud.osconfig.v1.ListInventoriesResponse; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListInventoriesPaged { + + public static void main(String[] args) throws Exception { + asyncListInventoriesPaged(); + } + + public static void asyncListInventoriesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInventoriesRequest request = + ListInventoriesRequest.newBuilder() + .setParent( + InstanceName.ofProjectLocationInstanceName( + "[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setView(InventoryView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListInventoriesResponse response = + osConfigZonalServiceClient.listInventoriesCallable().call(request); + for (Inventory element : response.getInventoriesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listinventories_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventories.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventories.java new file mode 100644 index 00000000..41eb7381 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventories.java @@ -0,0 +1,54 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listinventories_sync] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.InventoryView; +import com.google.cloud.osconfig.v1.ListInventoriesRequest; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListInventories { + + public static void main(String[] args) throws Exception { + syncListInventories(); + } + + public static void syncListInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInventoriesRequest request = + ListInventoriesRequest.newBuilder() + .setParent( + InstanceName.ofProjectLocationInstanceName( + "[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setView(InventoryView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Inventory element : osConfigZonalServiceClient.listInventories(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listinventories_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventoriesInstancename.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventoriesInstancename.java new file mode 100644 index 00000000..bf915c60 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventoriesInstancename.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listinventories_instancename_sync] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListInventoriesInstancename { + + public static void main(String[] args) throws Exception { + syncListInventoriesInstancename(); + } + + public static void syncListInventoriesInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InstanceName parent = + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + for (Inventory element : osConfigZonalServiceClient.listInventories(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listinventories_instancename_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventoriesString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventoriesString.java new file mode 100644 index 00000000..4a98b8a1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listinventories/SyncListInventoriesString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listinventories_string_sync] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.Inventory; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListInventoriesString { + + public static void main(String[] args) throws Exception { + syncListInventoriesString(); + } + + public static void syncListInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = + InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]").toString(); + for (Inventory element : osConfigZonalServiceClient.listInventories(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listinventories_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReports.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReports.java new file mode 100644 index 00000000..dc56c210 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReports.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncListOSPolicyAssignmentReports { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentReports(); + } + + public static void asyncListOSPolicyAssignmentReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentReportsRequest request = + ListOSPolicyAssignmentReportsRequest.newBuilder() + .setParent( + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigZonalServiceClient + .listOSPolicyAssignmentReportsPagedCallable() + .futureCall(request); + // Do something. + for (OSPolicyAssignmentReport element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReportsPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReportsPaged.java new file mode 100644 index 00000000..34908a66 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReportsPaged.java @@ -0,0 +1,64 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_paged_async] +import com.google.cloud.osconfig.v1.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsResponse; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListOSPolicyAssignmentReportsPaged { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentReportsPaged(); + } + + public static void asyncListOSPolicyAssignmentReportsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentReportsRequest request = + ListOSPolicyAssignmentReportsRequest.newBuilder() + .setParent( + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListOSPolicyAssignmentReportsResponse response = + osConfigZonalServiceClient.listOSPolicyAssignmentReportsCallable().call(request); + for (OSPolicyAssignmentReport element : response.getOsPolicyAssignmentReportsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReports.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReports.java new file mode 100644 index 00000000..c7025b2d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReports.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_sync] +import com.google.cloud.osconfig.v1.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentReports { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentReports(); + } + + public static void syncListOSPolicyAssignmentReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentReportsRequest request = + ListOSPolicyAssignmentReportsRequest.newBuilder() + .setParent( + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .build(); + for (OSPolicyAssignmentReport element : + osConfigZonalServiceClient.listOSPolicyAssignmentReports(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname.java new file mode 100644 index 00000000..8040c44d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_instanceospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentReportsInstanceospolicyassignmentname(); + } + + public static void syncListOSPolicyAssignmentReportsInstanceospolicyassignmentname() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InstanceOSPolicyAssignmentName parent = + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + for (OSPolicyAssignmentReport element : + osConfigZonalServiceClient.listOSPolicyAssignmentReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_instanceospolicyassignmentname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsString.java new file mode 100644 index 00000000..6e635390 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsString.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_string_sync] +import com.google.cloud.osconfig.v1.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentReportsString { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentReportsString(); + } + + public static void syncListOSPolicyAssignmentReportsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = + InstanceOSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString(); + for (OSPolicyAssignmentReport element : + osConfigZonalServiceClient.listOSPolicyAssignmentReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentreports_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisions.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisions.java new file mode 100644 index 00000000..53493bb0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisions.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncListOSPolicyAssignmentRevisions { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentRevisions(); + } + + public static void asyncListOSPolicyAssignmentRevisions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentRevisionsRequest request = + ListOSPolicyAssignmentRevisionsRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigZonalServiceClient + .listOSPolicyAssignmentRevisionsPagedCallable() + .futureCall(request); + // Do something. + for (OSPolicyAssignment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisionsPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisionsPaged.java new file mode 100644 index 00000000..2dd559d5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisionsPaged.java @@ -0,0 +1,62 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_paged_async] +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsResponse; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListOSPolicyAssignmentRevisionsPaged { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentRevisionsPaged(); + } + + public static void asyncListOSPolicyAssignmentRevisionsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentRevisionsRequest request = + ListOSPolicyAssignmentRevisionsRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListOSPolicyAssignmentRevisionsResponse response = + osConfigZonalServiceClient.listOSPolicyAssignmentRevisionsCallable().call(request); + for (OSPolicyAssignment element : response.getOsPolicyAssignmentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisions.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisions.java new file mode 100644 index 00000000..8c9a9a7b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisions.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_sync] +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentRevisions { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentRevisions(); + } + + public static void syncListOSPolicyAssignmentRevisions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentRevisionsRequest request = + ListOSPolicyAssignmentRevisionsRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignmentRevisions(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname.java new file mode 100644 index 00000000..b52262e5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_ospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentRevisionsOspolicyassignmentname(); + } + + public static void syncListOSPolicyAssignmentRevisionsOspolicyassignmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignmentRevisions(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_ospolicyassignmentname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsString.java new file mode 100644 index 00000000..6ca87918 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_string_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentRevisionsString { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentRevisionsString(); + } + + public static void syncListOSPolicyAssignmentRevisionsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]").toString(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignmentRevisions(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignments.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignments.java new file mode 100644 index 00000000..bec84cdd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignments.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class AsyncListOSPolicyAssignments { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignments(); + } + + public static void asyncListOSPolicyAssignments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentsRequest request = + ListOSPolicyAssignmentsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigZonalServiceClient.listOSPolicyAssignmentsPagedCallable().futureCall(request); + // Do something. + for (OSPolicyAssignment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignmentsPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignmentsPaged.java new file mode 100644 index 00000000..f0cfedb7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignmentsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_paged_async] +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentsResponse; +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListOSPolicyAssignmentsPaged { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentsPaged(); + } + + public static void asyncListOSPolicyAssignmentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentsRequest request = + ListOSPolicyAssignmentsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListOSPolicyAssignmentsResponse response = + osConfigZonalServiceClient.listOSPolicyAssignmentsCallable().call(request); + for (OSPolicyAssignment element : response.getOsPolicyAssignmentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignments.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignments.java new file mode 100644 index 00000000..c91c2aac --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignments.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_sync] +import com.google.cloud.osconfig.v1.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignments { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignments(); + } + + public static void syncListOSPolicyAssignments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentsRequest request = + ListOSPolicyAssignmentsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsLocationname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsLocationname.java new file mode 100644 index 00000000..9ab6801c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsLocationname.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_locationname_sync] +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentsLocationname { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentsLocationname(); + } + + public static void syncListOSPolicyAssignmentsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsString.java new file mode 100644 index 00000000..69a3e35e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_string_sync] +import com.google.cloud.osconfig.v1.LocationName; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentsString { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentsString(); + } + + public static void syncListOSPolicyAssignmentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listospolicyassignments_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReports.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReports.java new file mode 100644 index 00000000..5407771c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReports.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; + +public class AsyncListVulnerabilityReports { + + public static void main(String[] args) throws Exception { + asyncListVulnerabilityReports(); + } + + public static void asyncListVulnerabilityReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListVulnerabilityReportsRequest request = + ListVulnerabilityReportsRequest.newBuilder() + .setParent( + InstanceName.ofProjectLocationInstanceName( + "[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigZonalServiceClient.listVulnerabilityReportsPagedCallable().futureCall(request); + // Do something. + for (VulnerabilityReport element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReportsPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReportsPaged.java new file mode 100644 index 00000000..6c21d435 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReportsPaged.java @@ -0,0 +1,64 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_paged_async] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1.ListVulnerabilityReportsResponse; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; +import com.google.common.base.Strings; + +public class AsyncListVulnerabilityReportsPaged { + + public static void main(String[] args) throws Exception { + asyncListVulnerabilityReportsPaged(); + } + + public static void asyncListVulnerabilityReportsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListVulnerabilityReportsRequest request = + ListVulnerabilityReportsRequest.newBuilder() + .setParent( + InstanceName.ofProjectLocationInstanceName( + "[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListVulnerabilityReportsResponse response = + osConfigZonalServiceClient.listVulnerabilityReportsCallable().call(request); + for (VulnerabilityReport element : response.getVulnerabilityReportsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReports.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReports.java new file mode 100644 index 00000000..3c68ceca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReports.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_sync] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; + +public class SyncListVulnerabilityReports { + + public static void main(String[] args) throws Exception { + syncListVulnerabilityReports(); + } + + public static void syncListVulnerabilityReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListVulnerabilityReportsRequest request = + ListVulnerabilityReportsRequest.newBuilder() + .setParent( + InstanceName.ofProjectLocationInstanceName( + "[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (VulnerabilityReport element : + osConfigZonalServiceClient.listVulnerabilityReports(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsInstancename.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsInstancename.java new file mode 100644 index 00000000..9c332f7c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsInstancename.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_instancename_sync] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; + +public class SyncListVulnerabilityReportsInstancename { + + public static void main(String[] args) throws Exception { + syncListVulnerabilityReportsInstancename(); + } + + public static void syncListVulnerabilityReportsInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InstanceName parent = + InstanceName.ofProjectLocationInstanceName("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + for (VulnerabilityReport element : + osConfigZonalServiceClient.listVulnerabilityReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_instancename_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsString.java new file mode 100644 index 00000000..a2418dab --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsString.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_string_sync] +import com.google.cloud.osconfig.v1.InstanceName; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.VulnerabilityReport; + +public class SyncListVulnerabilityReportsString { + + public static void main(String[] args) throws Exception { + syncListVulnerabilityReportsString(); + } + + public static void syncListVulnerabilityReportsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = + InstanceName.ofProjectZoneInstanceName("[PROJECT]", "[ZONE]", "[INSTANCE]").toString(); + for (VulnerabilityReport element : + osConfigZonalServiceClient.listVulnerabilityReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_listvulnerabilityreports_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignment.java new file mode 100644 index 00000000..3e133eca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignment.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncUpdateOSPolicyAssignment(); + } + + public static void asyncUpdateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + UpdateOSPolicyAssignmentRequest request = + UpdateOSPolicyAssignmentRequest.newBuilder() + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.updateOSPolicyAssignmentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignmentLRO.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignmentLRO.java new file mode 100644 index 00000000..72ddeacf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignmentLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateOSPolicyAssignmentLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateOSPolicyAssignmentLRO(); + } + + public static void asyncUpdateOSPolicyAssignmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + UpdateOSPolicyAssignmentRequest request = + UpdateOSPolicyAssignmentRequest.newBuilder() + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + osConfigZonalServiceClient + .updateOSPolicyAssignmentOperationCallable() + .futureCall(request); + // Do something. + OSPolicyAssignment response = future.get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignment.java new file mode 100644 index 00000000..0ce43a41 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1.UpdateOSPolicyAssignmentRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncUpdateOSPolicyAssignment(); + } + + public static void syncUpdateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + UpdateOSPolicyAssignmentRequest request = + UpdateOSPolicyAssignmentRequest.newBuilder() + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OSPolicyAssignment response = + osConfigZonalServiceClient.updateOSPolicyAssignmentAsync(request).get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask.java new file mode 100644 index 00000000..2d00bffc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask.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.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_ospolicyassignmentfieldmask_sync] +import com.google.cloud.osconfig.v1.OSPolicyAssignment; +import com.google.cloud.osconfig.v1.OsConfigZonalServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask(); + } + + public static void syncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + OSPolicyAssignment response = + osConfigZonalServiceClient + .updateOSPolicyAssignmentAsync(osPolicyAssignment, updateMask) + .get(); + } + } +} +// [END osconfig_v1_generated_osconfigzonalserviceclient_updateospolicyassignment_ospolicyassignmentfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalservicesettings/getospolicyassignment/SyncGetOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalservicesettings/getospolicyassignment/SyncGetOSPolicyAssignment.java new file mode 100644 index 00000000..9152ef9b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/osconfigzonalservicesettings/getospolicyassignment/SyncGetOSPolicyAssignment.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.samples; + +// [START osconfig_v1_generated_osconfigzonalservicesettings_getospolicyassignment_sync] +import com.google.cloud.osconfig.v1.OsConfigZonalServiceSettings; +import java.time.Duration; + +public class SyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignment(); + } + + public static void syncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigZonalServiceSettings.Builder osConfigZonalServiceSettingsBuilder = + OsConfigZonalServiceSettings.newBuilder(); + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .setRetrySettings( + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + osConfigZonalServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1_generated_osconfigzonalservicesettings_getospolicyassignment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/stub/osconfigservicestubsettings/executepatchjob/SyncExecutePatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/stub/osconfigservicestubsettings/executepatchjob/SyncExecutePatchJob.java new file mode 100644 index 00000000..d66d1429 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/stub/osconfigservicestubsettings/executepatchjob/SyncExecutePatchJob.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.stub.samples; + +// [START osconfig_v1_generated_osconfigservicestubsettings_executepatchjob_sync] +import com.google.cloud.osconfig.v1.stub.OsConfigServiceStubSettings; +import java.time.Duration; + +public class SyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + syncExecutePatchJob(); + } + + public static void syncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigServiceStubSettings.Builder osConfigServiceSettingsBuilder = + OsConfigServiceStubSettings.newBuilder(); + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .setRetrySettings( + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigServiceStubSettings osConfigServiceSettings = osConfigServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1_generated_osconfigservicestubsettings_executepatchjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1/stub/osconfigzonalservicestubsettings/getospolicyassignment/SyncGetOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1/stub/osconfigzonalservicestubsettings/getospolicyassignment/SyncGetOSPolicyAssignment.java new file mode 100644 index 00000000..a48d9f0b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1/stub/osconfigzonalservicestubsettings/getospolicyassignment/SyncGetOSPolicyAssignment.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1.stub.samples; + +// [START osconfig_v1_generated_osconfigzonalservicestubsettings_getospolicyassignment_sync] +import com.google.cloud.osconfig.v1.stub.OsConfigZonalServiceStubSettings; +import java.time.Duration; + +public class SyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignment(); + } + + public static void syncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigZonalServiceStubSettings.Builder osConfigZonalServiceSettingsBuilder = + OsConfigZonalServiceStubSettings.newBuilder(); + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .setRetrySettings( + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigZonalServiceStubSettings osConfigZonalServiceSettings = + osConfigZonalServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1_generated_osconfigzonalservicestubsettings_getospolicyassignment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..740d76ca --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceSettings; +import com.google.cloud.osconfig.v1alpha.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. + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + OsConfigZonalServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..52061043 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceSettings; + +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. + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + OsConfigZonalServiceSettings.newBuilder() + .setTransportChannelProvider( + OsConfigZonalServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..fa7b736a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_create_setendpoint_sync] +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceSettings; +import com.google.cloud.osconfig.v1alpha.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. + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + OsConfigZonalServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create(osConfigZonalServiceSettings); + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignment.java new file mode 100644 index 00000000..950ce351 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignment.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.longrunning.Operation; + +public class AsyncCreateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncCreateOSPolicyAssignment(); + } + + public static void asyncCreateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + CreateOSPolicyAssignmentRequest request = + CreateOSPolicyAssignmentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074") + .build(); + ApiFuture future = + osConfigZonalServiceClient.createOSPolicyAssignmentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignmentLRO.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignmentLRO.java new file mode 100644 index 00000000..c3a26189 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/AsyncCreateOSPolicyAssignmentLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncCreateOSPolicyAssignmentLRO { + + public static void main(String[] args) throws Exception { + asyncCreateOSPolicyAssignmentLRO(); + } + + public static void asyncCreateOSPolicyAssignmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + CreateOSPolicyAssignmentRequest request = + CreateOSPolicyAssignmentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074") + .build(); + OperationFuture future = + osConfigZonalServiceClient + .createOSPolicyAssignmentOperationCallable() + .futureCall(request); + // Do something. + OSPolicyAssignment response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignment.java new file mode 100644 index 00000000..02b79c0e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignment.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_sync] +import com.google.cloud.osconfig.v1alpha.CreateOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncCreateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncCreateOSPolicyAssignment(); + } + + public static void syncCreateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + CreateOSPolicyAssignmentRequest request = + CreateOSPolicyAssignmentRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setOsPolicyAssignmentId("osPolicyAssignmentId-44079074") + .build(); + OSPolicyAssignment response = + osConfigZonalServiceClient.createOSPolicyAssignmentAsync(request).get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString.java new file mode 100644 index 00000000..02a2ef2f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_locationnameospolicyassignmentstring_sync] +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString { + + public static void main(String[] args) throws Exception { + syncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString(); + } + + public static void syncCreateOSPolicyAssignmentLocationnameOspolicyassignmentString() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + OSPolicyAssignment response = + osConfigZonalServiceClient + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_locationnameospolicyassignmentstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentStringOspolicyassignmentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentStringOspolicyassignmentString.java new file mode 100644 index 00000000..fdd34a5d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/createospolicyassignment/SyncCreateOSPolicyAssignmentStringOspolicyassignmentString.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_stringospolicyassignmentstring_sync] +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncCreateOSPolicyAssignmentStringOspolicyassignmentString { + + public static void main(String[] args) throws Exception { + syncCreateOSPolicyAssignmentStringOspolicyassignmentString(); + } + + public static void syncCreateOSPolicyAssignmentStringOspolicyassignmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + String osPolicyAssignmentId = "osPolicyAssignmentId-44079074"; + OSPolicyAssignment response = + osConfigZonalServiceClient + .createOSPolicyAssignmentAsync(parent, osPolicyAssignment, osPolicyAssignmentId) + .get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_createospolicyassignment_stringospolicyassignmentstring_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignment.java new file mode 100644 index 00000000..63629f8c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignment.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.longrunning.Operation; + +public class AsyncDeleteOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncDeleteOSPolicyAssignment(); + } + + public static void asyncDeleteOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + DeleteOSPolicyAssignmentRequest request = + DeleteOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.deleteOSPolicyAssignmentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignmentLRO.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignmentLRO.java new file mode 100644 index 00000000..c679b07b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/AsyncDeleteOSPolicyAssignmentLRO.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteOSPolicyAssignmentLRO { + + public static void main(String[] args) throws Exception { + asyncDeleteOSPolicyAssignmentLRO(); + } + + public static void asyncDeleteOSPolicyAssignmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + DeleteOSPolicyAssignmentRequest request = + DeleteOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + OperationFuture future = + osConfigZonalServiceClient + .deleteOSPolicyAssignmentOperationCallable() + .futureCall(request); + // Do something. + future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignment.java new file mode 100644 index 00000000..73f4c6e9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_sync] +import com.google.cloud.osconfig.v1alpha.DeleteOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncDeleteOSPolicyAssignment(); + } + + public static void syncDeleteOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + DeleteOSPolicyAssignmentRequest request = + DeleteOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(request).get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentOspolicyassignmentname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentOspolicyassignmentname.java new file mode 100644 index 00000000..830ed99a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentOspolicyassignmentname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_ospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteOSPolicyAssignmentOspolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncDeleteOSPolicyAssignmentOspolicyassignmentname(); + } + + public static void syncDeleteOSPolicyAssignmentOspolicyassignmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(name).get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_ospolicyassignmentname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentString.java new file mode 100644 index 00000000..9eb44868 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/deleteospolicyassignment/SyncDeleteOSPolicyAssignmentString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_string_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteOSPolicyAssignmentString { + + public static void main(String[] args) throws Exception { + syncDeleteOSPolicyAssignmentString(); + } + + public static void syncDeleteOSPolicyAssignmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]").toString(); + osConfigZonalServiceClient.deleteOSPolicyAssignmentAsync(name).get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_deleteospolicyassignment_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/AsyncGetInstanceOSPoliciesCompliance.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/AsyncGetInstanceOSPoliciesCompliance.java new file mode 100644 index 00000000..b7fc7c75 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/AsyncGetInstanceOSPoliciesCompliance.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesComplianceName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncGetInstanceOSPoliciesCompliance { + + public static void main(String[] args) throws Exception { + asyncGetInstanceOSPoliciesCompliance(); + } + + public static void asyncGetInstanceOSPoliciesCompliance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetInstanceOSPoliciesComplianceRequest request = + GetInstanceOSPoliciesComplianceRequest.newBuilder() + .setName( + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getInstanceOSPoliciesComplianceCallable().futureCall(request); + // Do something. + InstanceOSPoliciesCompliance response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesCompliance.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesCompliance.java new file mode 100644 index 00000000..a04af61b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesCompliance.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_sync] +import com.google.cloud.osconfig.v1alpha.GetInstanceOSPoliciesComplianceRequest; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesComplianceName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetInstanceOSPoliciesCompliance { + + public static void main(String[] args) throws Exception { + syncGetInstanceOSPoliciesCompliance(); + } + + public static void syncGetInstanceOSPoliciesCompliance() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetInstanceOSPoliciesComplianceRequest request = + GetInstanceOSPoliciesComplianceRequest.newBuilder() + .setName( + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]") + .toString()) + .build(); + InstanceOSPoliciesCompliance response = + osConfigZonalServiceClient.getInstanceOSPoliciesCompliance(request); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesComplianceInstanceospoliciescompliancename.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesComplianceInstanceospoliciescompliancename.java new file mode 100644 index 00000000..bff1cc35 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesComplianceInstanceospoliciescompliancename.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_instanceospoliciescompliancename_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesComplianceName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetInstanceOSPoliciesComplianceInstanceospoliciescompliancename { + + public static void main(String[] args) throws Exception { + syncGetInstanceOSPoliciesComplianceInstanceospoliciescompliancename(); + } + + public static void syncGetInstanceOSPoliciesComplianceInstanceospoliciescompliancename() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InstanceOSPoliciesComplianceName name = + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + InstanceOSPoliciesCompliance response = + osConfigZonalServiceClient.getInstanceOSPoliciesCompliance(name); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_instanceospoliciescompliancename_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesComplianceString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesComplianceString.java new file mode 100644 index 00000000..08148dde --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinstanceospoliciescompliance/SyncGetInstanceOSPoliciesComplianceString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_string_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesComplianceName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetInstanceOSPoliciesComplianceString { + + public static void main(String[] args) throws Exception { + syncGetInstanceOSPoliciesComplianceString(); + } + + public static void syncGetInstanceOSPoliciesComplianceString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + InstanceOSPoliciesComplianceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + InstanceOSPoliciesCompliance response = + osConfigZonalServiceClient.getInstanceOSPoliciesCompliance(name); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getinstanceospoliciescompliance_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/AsyncGetInventory.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/AsyncGetInventory.java new file mode 100644 index 00000000..ba16ee04 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/AsyncGetInventory.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.GetInventoryRequest; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.InventoryName; +import com.google.cloud.osconfig.v1alpha.InventoryView; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncGetInventory { + + public static void main(String[] args) throws Exception { + asyncGetInventory(); + } + + public static void asyncGetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetInventoryRequest request = + GetInventoryRequest.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setView(InventoryView.forNumber(0)) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getInventoryCallable().futureCall(request); + // Do something. + Inventory response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventory.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventory.java new file mode 100644 index 00000000..39437914 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventory.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_sync] +import com.google.cloud.osconfig.v1alpha.GetInventoryRequest; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.InventoryName; +import com.google.cloud.osconfig.v1alpha.InventoryView; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetInventory { + + public static void main(String[] args) throws Exception { + syncGetInventory(); + } + + public static void syncGetInventory() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetInventoryRequest request = + GetInventoryRequest.newBuilder() + .setName(InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setView(InventoryView.forNumber(0)) + .build(); + Inventory response = osConfigZonalServiceClient.getInventory(request); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventoryInventoryname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventoryInventoryname.java new file mode 100644 index 00000000..d99d53d4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventoryInventoryname.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_inventoryname_sync] +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.InventoryName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetInventoryInventoryname { + + public static void main(String[] args) throws Exception { + syncGetInventoryInventoryname(); + } + + public static void syncGetInventoryInventoryname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InventoryName name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + Inventory response = osConfigZonalServiceClient.getInventory(name); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_inventoryname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventoryString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventoryString.java new file mode 100644 index 00000000..c6d43ff8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getinventory/SyncGetInventoryString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_string_sync] +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.InventoryName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetInventoryString { + + public static void main(String[] args) throws Exception { + syncGetInventoryString(); + } + + public static void syncGetInventoryString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = InventoryName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + Inventory response = osConfigZonalServiceClient.getInventory(name); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getinventory_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/AsyncGetOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/AsyncGetOSPolicyAssignment.java new file mode 100644 index 00000000..6c786812 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/AsyncGetOSPolicyAssignment.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncGetOSPolicyAssignment(); + } + + public static void asyncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentRequest request = + GetOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getOSPolicyAssignmentCallable().futureCall(request); + // Do something. + OSPolicyAssignment response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignment.java new file mode 100644 index 00000000..e638df35 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_sync] +import com.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignment(); + } + + public static void syncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentRequest request = + GetOSPolicyAssignmentRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .build(); + OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(request); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentOspolicyassignmentname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentOspolicyassignmentname.java new file mode 100644 index 00000000..0aa6dc4f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentOspolicyassignmentname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_ospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentOspolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentOspolicyassignmentname(); + } + + public static void syncGetOSPolicyAssignmentOspolicyassignmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(name); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_ospolicyassignmentname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentString.java new file mode 100644 index 00000000..90d3d5d2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignment/SyncGetOSPolicyAssignmentString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_string_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentString { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentString(); + } + + public static void syncGetOSPolicyAssignmentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]").toString(); + OSPolicyAssignment response = osConfigZonalServiceClient.getOSPolicyAssignment(name); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignment_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/AsyncGetOSPolicyAssignmentReport.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/AsyncGetOSPolicyAssignmentReport.java new file mode 100644 index 00000000..b48602f2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/AsyncGetOSPolicyAssignmentReport.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncGetOSPolicyAssignmentReport { + + public static void main(String[] args) throws Exception { + asyncGetOSPolicyAssignmentReport(); + } + + public static void asyncGetOSPolicyAssignmentReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentReportRequest request = + GetOSPolicyAssignmentReportRequest.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getOSPolicyAssignmentReportCallable().futureCall(request); + // Do something. + OSPolicyAssignmentReport response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReport.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReport.java new file mode 100644 index 00000000..a13fe619 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReport.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_sync] +import com.google.cloud.osconfig.v1alpha.GetOSPolicyAssignmentReportRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentReport { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentReport(); + } + + public static void syncGetOSPolicyAssignmentReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetOSPolicyAssignmentReportRequest request = + GetOSPolicyAssignmentReportRequest.newBuilder() + .setName( + OSPolicyAssignmentReportName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .build(); + OSPolicyAssignmentReport response = + osConfigZonalServiceClient.getOSPolicyAssignmentReport(request); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname.java new file mode 100644 index 00000000..3ca283a3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_ospolicyassignmentreportname_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentReportOspolicyassignmentreportname { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentReportOspolicyassignmentreportname(); + } + + public static void syncGetOSPolicyAssignmentReportOspolicyassignmentreportname() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentReportName name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + OSPolicyAssignmentReport response = + osConfigZonalServiceClient.getOSPolicyAssignmentReport(name); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_ospolicyassignmentreportname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportString.java new file mode 100644 index 00000000..0fea7390 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getospolicyassignmentreport/SyncGetOSPolicyAssignmentReportString.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_string_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReportName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncGetOSPolicyAssignmentReportString { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignmentReportString(); + } + + public static void syncGetOSPolicyAssignmentReportString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString(); + OSPolicyAssignmentReport response = + osConfigZonalServiceClient.getOSPolicyAssignmentReport(name); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getospolicyassignmentreport_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/AsyncGetVulnerabilityReport.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/AsyncGetVulnerabilityReport.java new file mode 100644 index 00000000..84ffdda5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/AsyncGetVulnerabilityReport.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReportName; + +public class AsyncGetVulnerabilityReport { + + public static void main(String[] args) throws Exception { + asyncGetVulnerabilityReport(); + } + + public static void asyncGetVulnerabilityReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetVulnerabilityReportRequest request = + GetVulnerabilityReportRequest.newBuilder() + .setName( + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.getVulnerabilityReportCallable().futureCall(request); + // Do something. + VulnerabilityReport response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReport.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReport.java new file mode 100644 index 00000000..d5d4d759 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReport.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_sync] +import com.google.cloud.osconfig.v1alpha.GetVulnerabilityReportRequest; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReportName; + +public class SyncGetVulnerabilityReport { + + public static void main(String[] args) throws Exception { + syncGetVulnerabilityReport(); + } + + public static void syncGetVulnerabilityReport() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + GetVulnerabilityReportRequest request = + GetVulnerabilityReportRequest.newBuilder() + .setName( + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .build(); + VulnerabilityReport response = osConfigZonalServiceClient.getVulnerabilityReport(request); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportString.java new file mode 100644 index 00000000..35cb0ff0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportString.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_string_sync] +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReportName; + +public class SyncGetVulnerabilityReportString { + + public static void main(String[] args) throws Exception { + syncGetVulnerabilityReportString(); + } + + public static void syncGetVulnerabilityReportString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + VulnerabilityReport response = osConfigZonalServiceClient.getVulnerabilityReport(name); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportVulnerabilityreportname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportVulnerabilityreportname.java new file mode 100644 index 00000000..2cd0ce71 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/getvulnerabilityreport/SyncGetVulnerabilityReportVulnerabilityreportname.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_vulnerabilityreportname_sync] +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReportName; + +public class SyncGetVulnerabilityReportVulnerabilityreportname { + + public static void main(String[] args) throws Exception { + syncGetVulnerabilityReportVulnerabilityreportname(); + } + + public static void syncGetVulnerabilityReportVulnerabilityreportname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + VulnerabilityReportName name = + VulnerabilityReportName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + VulnerabilityReport response = osConfigZonalServiceClient.getVulnerabilityReport(name); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_getvulnerabilityreport_vulnerabilityreportname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/AsyncListInstanceOSPoliciesCompliances.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/AsyncListInstanceOSPoliciesCompliances.java new file mode 100644 index 00000000..f5d1822b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/AsyncListInstanceOSPoliciesCompliances.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncListInstanceOSPoliciesCompliances { + + public static void main(String[] args) throws Exception { + asyncListInstanceOSPoliciesCompliances(); + } + + public static void asyncListInstanceOSPoliciesCompliances() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInstanceOSPoliciesCompliancesRequest request = + ListInstanceOSPoliciesCompliancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigZonalServiceClient + .listInstanceOSPoliciesCompliancesPagedCallable() + .futureCall(request); + // Do something. + for (InstanceOSPoliciesCompliance element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/AsyncListInstanceOSPoliciesCompliancesPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/AsyncListInstanceOSPoliciesCompliancesPaged.java new file mode 100644 index 00000000..c13ba87f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/AsyncListInstanceOSPoliciesCompliancesPaged.java @@ -0,0 +1,62 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_paged_async] +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest; +import com.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesResponse; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListInstanceOSPoliciesCompliancesPaged { + + public static void main(String[] args) throws Exception { + asyncListInstanceOSPoliciesCompliancesPaged(); + } + + public static void asyncListInstanceOSPoliciesCompliancesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInstanceOSPoliciesCompliancesRequest request = + ListInstanceOSPoliciesCompliancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListInstanceOSPoliciesCompliancesResponse response = + osConfigZonalServiceClient.listInstanceOSPoliciesCompliancesCallable().call(request); + for (InstanceOSPoliciesCompliance element : + response.getInstanceOsPoliciesCompliancesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliances.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliances.java new file mode 100644 index 00000000..181dd853 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliances.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.ListInstanceOSPoliciesCompliancesRequest; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListInstanceOSPoliciesCompliances { + + public static void main(String[] args) throws Exception { + syncListInstanceOSPoliciesCompliances(); + } + + public static void syncListInstanceOSPoliciesCompliances() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInstanceOSPoliciesCompliancesRequest request = + ListInstanceOSPoliciesCompliancesRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (InstanceOSPoliciesCompliance element : + osConfigZonalServiceClient.listInstanceOSPoliciesCompliances(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliancesLocationname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliancesLocationname.java new file mode 100644 index 00000000..3740662e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliancesLocationname.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_locationname_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListInstanceOSPoliciesCompliancesLocationname { + + public static void main(String[] args) throws Exception { + syncListInstanceOSPoliciesCompliancesLocationname(); + } + + public static void syncListInstanceOSPoliciesCompliancesLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (InstanceOSPoliciesCompliance element : + osConfigZonalServiceClient.listInstanceOSPoliciesCompliances(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliancesString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliancesString.java new file mode 100644 index 00000000..9eda62d8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinstanceospoliciescompliances/SyncListInstanceOSPoliciesCompliancesString.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_string_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPoliciesCompliance; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListInstanceOSPoliciesCompliancesString { + + public static void main(String[] args) throws Exception { + syncListInstanceOSPoliciesCompliancesString(); + } + + public static void syncListInstanceOSPoliciesCompliancesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (InstanceOSPoliciesCompliance element : + osConfigZonalServiceClient.listInstanceOSPoliciesCompliances(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinstanceospoliciescompliances_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/AsyncListInventories.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/AsyncListInventories.java new file mode 100644 index 00000000..ba4d07f1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/AsyncListInventories.java @@ -0,0 +1,55 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.InventoryView; +import com.google.cloud.osconfig.v1alpha.ListInventoriesRequest; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncListInventories { + + public static void main(String[] args) throws Exception { + asyncListInventories(); + } + + public static void asyncListInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInventoriesRequest request = + ListInventoriesRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setView(InventoryView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigZonalServiceClient.listInventoriesPagedCallable().futureCall(request); + // Do something. + for (Inventory element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/AsyncListInventoriesPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/AsyncListInventoriesPaged.java new file mode 100644 index 00000000..dbb69423 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/AsyncListInventoriesPaged.java @@ -0,0 +1,63 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_paged_async] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.InventoryView; +import com.google.cloud.osconfig.v1alpha.ListInventoriesRequest; +import com.google.cloud.osconfig.v1alpha.ListInventoriesResponse; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListInventoriesPaged { + + public static void main(String[] args) throws Exception { + asyncListInventoriesPaged(); + } + + public static void asyncListInventoriesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInventoriesRequest request = + ListInventoriesRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setView(InventoryView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListInventoriesResponse response = + osConfigZonalServiceClient.listInventoriesCallable().call(request); + for (Inventory element : response.getInventoriesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventories.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventories.java new file mode 100644 index 00000000..d1f3a353 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventories.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_sync] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.InventoryView; +import com.google.cloud.osconfig.v1alpha.ListInventoriesRequest; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListInventories { + + public static void main(String[] args) throws Exception { + syncListInventories(); + } + + public static void syncListInventories() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListInventoriesRequest request = + ListInventoriesRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setView(InventoryView.forNumber(0)) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (Inventory element : osConfigZonalServiceClient.listInventories(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventoriesInstancename.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventoriesInstancename.java new file mode 100644 index 00000000..9740f76a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventoriesInstancename.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_instancename_sync] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListInventoriesInstancename { + + public static void main(String[] args) throws Exception { + syncListInventoriesInstancename(); + } + + public static void syncListInventoriesInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + for (Inventory element : osConfigZonalServiceClient.listInventories(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_instancename_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventoriesString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventoriesString.java new file mode 100644 index 00000000..6eec7290 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listinventories/SyncListInventoriesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_string_sync] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.Inventory; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListInventoriesString { + + public static void main(String[] args) throws Exception { + syncListInventoriesString(); + } + + public static void syncListInventoriesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + for (Inventory element : osConfigZonalServiceClient.listInventories(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listinventories_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReports.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReports.java new file mode 100644 index 00000000..7cfd7492 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReports.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncListOSPolicyAssignmentReports { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentReports(); + } + + public static void asyncListOSPolicyAssignmentReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentReportsRequest request = + ListOSPolicyAssignmentReportsRequest.newBuilder() + .setParent( + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigZonalServiceClient + .listOSPolicyAssignmentReportsPagedCallable() + .futureCall(request); + // Do something. + for (OSPolicyAssignmentReport element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReportsPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReportsPaged.java new file mode 100644 index 00000000..09a818b6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/AsyncListOSPolicyAssignmentReportsPaged.java @@ -0,0 +1,64 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_paged_async] +import com.google.cloud.osconfig.v1alpha.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsResponse; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListOSPolicyAssignmentReportsPaged { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentReportsPaged(); + } + + public static void asyncListOSPolicyAssignmentReportsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentReportsRequest request = + ListOSPolicyAssignmentReportsRequest.newBuilder() + .setParent( + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListOSPolicyAssignmentReportsResponse response = + osConfigZonalServiceClient.listOSPolicyAssignmentReportsCallable().call(request); + for (OSPolicyAssignmentReport element : response.getOsPolicyAssignmentReportsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReports.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReports.java new file mode 100644 index 00000000..905902a4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReports.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentReportsRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentReports { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentReports(); + } + + public static void syncListOSPolicyAssignmentReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentReportsRequest request = + ListOSPolicyAssignmentReportsRequest.newBuilder() + .setParent( + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setFilter("filter-1274492040") + .setPageToken("pageToken873572522") + .build(); + for (OSPolicyAssignmentReport element : + osConfigZonalServiceClient.listOSPolicyAssignmentReports(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname.java new file mode 100644 index 00000000..eee8135a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_instanceospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentReportsInstanceospolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentReportsInstanceospolicyassignmentname(); + } + + public static void syncListOSPolicyAssignmentReportsInstanceospolicyassignmentname() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InstanceOSPolicyAssignmentName parent = + InstanceOSPolicyAssignmentName.of( + "[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]"); + for (OSPolicyAssignmentReport element : + osConfigZonalServiceClient.listOSPolicyAssignmentReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_instanceospolicyassignmentname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsString.java new file mode 100644 index 00000000..5107710b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentreports/SyncListOSPolicyAssignmentReportsString.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_string_sync] +import com.google.cloud.osconfig.v1alpha.InstanceOSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentReport; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentReportsString { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentReportsString(); + } + + public static void syncListOSPolicyAssignmentReportsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = + InstanceOSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]", "[ASSIGNMENT]") + .toString(); + for (OSPolicyAssignmentReport element : + osConfigZonalServiceClient.listOSPolicyAssignmentReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentreports_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisions.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisions.java new file mode 100644 index 00000000..1a308cc9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisions.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncListOSPolicyAssignmentRevisions { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentRevisions(); + } + + public static void asyncListOSPolicyAssignmentRevisions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentRevisionsRequest request = + ListOSPolicyAssignmentRevisionsRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigZonalServiceClient + .listOSPolicyAssignmentRevisionsPagedCallable() + .futureCall(request); + // Do something. + for (OSPolicyAssignment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisionsPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisionsPaged.java new file mode 100644 index 00000000..1887db86 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/AsyncListOSPolicyAssignmentRevisionsPaged.java @@ -0,0 +1,62 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_paged_async] +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsResponse; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListOSPolicyAssignmentRevisionsPaged { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentRevisionsPaged(); + } + + public static void asyncListOSPolicyAssignmentRevisionsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentRevisionsRequest request = + ListOSPolicyAssignmentRevisionsRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListOSPolicyAssignmentRevisionsResponse response = + osConfigZonalServiceClient.listOSPolicyAssignmentRevisionsCallable().call(request); + for (OSPolicyAssignment element : response.getOsPolicyAssignmentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisions.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisions.java new file mode 100644 index 00000000..e3866107 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisions.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_sync] +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentRevisionsRequest; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentRevisions { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentRevisions(); + } + + public static void syncListOSPolicyAssignmentRevisions() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentRevisionsRequest request = + ListOSPolicyAssignmentRevisionsRequest.newBuilder() + .setName( + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]") + .toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignmentRevisions(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname.java new file mode 100644 index 00000000..d6b7fca9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_ospolicyassignmentname_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentRevisionsOspolicyassignmentname { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentRevisionsOspolicyassignmentname(); + } + + public static void syncListOSPolicyAssignmentRevisionsOspolicyassignmentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignmentName name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]"); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignmentRevisions(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_ospolicyassignmentname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsString.java new file mode 100644 index 00000000..752a45cb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignmentrevisions/SyncListOSPolicyAssignmentRevisionsString.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_string_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentRevisionsString { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentRevisionsString(); + } + + public static void syncListOSPolicyAssignmentRevisionsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String name = + OSPolicyAssignmentName.of("[PROJECT]", "[LOCATION]", "[OS_POLICY_ASSIGNMENT]").toString(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignmentRevisions(name).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignmentrevisions_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignments.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignments.java new file mode 100644 index 00000000..7266def9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignments.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class AsyncListOSPolicyAssignments { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignments(); + } + + public static void asyncListOSPolicyAssignments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentsRequest request = + ListOSPolicyAssignmentsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigZonalServiceClient.listOSPolicyAssignmentsPagedCallable().futureCall(request); + // Do something. + for (OSPolicyAssignment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignmentsPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignmentsPaged.java new file mode 100644 index 00000000..938c0173 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/AsyncListOSPolicyAssignmentsPaged.java @@ -0,0 +1,60 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_paged_async] +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsResponse; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.common.base.Strings; + +public class AsyncListOSPolicyAssignmentsPaged { + + public static void main(String[] args) throws Exception { + asyncListOSPolicyAssignmentsPaged(); + } + + public static void asyncListOSPolicyAssignmentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentsRequest request = + ListOSPolicyAssignmentsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListOSPolicyAssignmentsResponse response = + osConfigZonalServiceClient.listOSPolicyAssignmentsCallable().call(request); + for (OSPolicyAssignment element : response.getOsPolicyAssignmentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignments.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignments.java new file mode 100644 index 00000000..911e0511 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignments.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_sync] +import com.google.cloud.osconfig.v1alpha.ListOSPolicyAssignmentsRequest; +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignments { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignments(); + } + + public static void syncListOSPolicyAssignments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListOSPolicyAssignmentsRequest request = + ListOSPolicyAssignmentsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsLocationname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsLocationname.java new file mode 100644 index 00000000..8b57d55c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsLocationname.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_locationname_sync] +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentsLocationname { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentsLocationname(); + } + + public static void syncListOSPolicyAssignmentsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsString.java new file mode 100644 index 00000000..8e356bc3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listospolicyassignments/SyncListOSPolicyAssignmentsString.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_string_sync] +import com.google.cloud.osconfig.v1alpha.LocationName; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; + +public class SyncListOSPolicyAssignmentsString { + + public static void main(String[] args) throws Exception { + syncListOSPolicyAssignmentsString(); + } + + public static void syncListOSPolicyAssignmentsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (OSPolicyAssignment element : + osConfigZonalServiceClient.listOSPolicyAssignments(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listospolicyassignments_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReports.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReports.java new file mode 100644 index 00000000..c9500401 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReports.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; + +public class AsyncListVulnerabilityReports { + + public static void main(String[] args) throws Exception { + asyncListVulnerabilityReports(); + } + + public static void asyncListVulnerabilityReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListVulnerabilityReportsRequest request = + ListVulnerabilityReportsRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigZonalServiceClient.listVulnerabilityReportsPagedCallable().futureCall(request); + // Do something. + for (VulnerabilityReport element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReportsPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReportsPaged.java new file mode 100644 index 00000000..776310bb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/AsyncListVulnerabilityReportsPaged.java @@ -0,0 +1,61 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_paged_async] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsResponse; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; +import com.google.common.base.Strings; + +public class AsyncListVulnerabilityReportsPaged { + + public static void main(String[] args) throws Exception { + asyncListVulnerabilityReportsPaged(); + } + + public static void asyncListVulnerabilityReportsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListVulnerabilityReportsRequest request = + ListVulnerabilityReportsRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + ListVulnerabilityReportsResponse response = + osConfigZonalServiceClient.listVulnerabilityReportsCallable().call(request); + for (VulnerabilityReport element : response.getVulnerabilityReportsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReports.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReports.java new file mode 100644 index 00000000..0426d265 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReports.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_sync] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.ListVulnerabilityReportsRequest; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; + +public class SyncListVulnerabilityReports { + + public static void main(String[] args) throws Exception { + syncListVulnerabilityReports(); + } + + public static void syncListVulnerabilityReports() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + ListVulnerabilityReportsRequest request = + ListVulnerabilityReportsRequest.newBuilder() + .setParent(InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (VulnerabilityReport element : + osConfigZonalServiceClient.listVulnerabilityReports(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsInstancename.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsInstancename.java new file mode 100644 index 00000000..2342179f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsInstancename.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_instancename_sync] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; + +public class SyncListVulnerabilityReportsInstancename { + + public static void main(String[] args) throws Exception { + syncListVulnerabilityReportsInstancename(); + } + + public static void syncListVulnerabilityReportsInstancename() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + InstanceName parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]"); + for (VulnerabilityReport element : + osConfigZonalServiceClient.listVulnerabilityReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_instancename_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsString.java new file mode 100644 index 00000000..bc924da0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/listvulnerabilityreports/SyncListVulnerabilityReportsString.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_string_sync] +import com.google.cloud.osconfig.v1alpha.InstanceName; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.VulnerabilityReport; + +public class SyncListVulnerabilityReportsString { + + public static void main(String[] args) throws Exception { + syncListVulnerabilityReportsString(); + } + + public static void syncListVulnerabilityReportsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + String parent = InstanceName.of("[PROJECT]", "[LOCATION]", "[INSTANCE]").toString(); + for (VulnerabilityReport element : + osConfigZonalServiceClient.listVulnerabilityReports(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_listvulnerabilityreports_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignment.java new file mode 100644 index 00000000..bd66e5b5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignment.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest; +import com.google.longrunning.Operation; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + asyncUpdateOSPolicyAssignment(); + } + + public static void asyncUpdateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + UpdateOSPolicyAssignmentRequest request = + UpdateOSPolicyAssignmentRequest.newBuilder() + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + osConfigZonalServiceClient.updateOSPolicyAssignmentCallable().futureCall(request); + // Do something. + Operation response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignmentLRO.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignmentLRO.java new file mode 100644 index 00000000..b910f093 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/AsyncUpdateOSPolicyAssignmentLRO.java @@ -0,0 +1,52 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_lro_async] +import com.google.api.gax.longrunning.OperationFuture; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignmentOperationMetadata; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateOSPolicyAssignmentLRO { + + public static void main(String[] args) throws Exception { + asyncUpdateOSPolicyAssignmentLRO(); + } + + public static void asyncUpdateOSPolicyAssignmentLRO() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + UpdateOSPolicyAssignmentRequest request = + UpdateOSPolicyAssignmentRequest.newBuilder() + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OperationFuture future = + osConfigZonalServiceClient + .updateOSPolicyAssignmentOperationCallable() + .futureCall(request); + // Do something. + OSPolicyAssignment response = future.get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_lro_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignment.java new file mode 100644 index 00000000..bef50cac --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.cloud.osconfig.v1alpha.UpdateOSPolicyAssignmentRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncUpdateOSPolicyAssignment(); + } + + public static void syncUpdateOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + UpdateOSPolicyAssignmentRequest request = + UpdateOSPolicyAssignmentRequest.newBuilder() + .setOsPolicyAssignment(OSPolicyAssignment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + OSPolicyAssignment response = + osConfigZonalServiceClient.updateOSPolicyAssignmentAsync(request).get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask.java new file mode 100644 index 00000000..f0e2b61e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalserviceclient/updateospolicyassignment/SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask.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.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_ospolicyassignmentfieldmask_sync] +import com.google.cloud.osconfig.v1alpha.OSPolicyAssignment; +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask(); + } + + public static void syncUpdateOSPolicyAssignmentOspolicyassignmentFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigZonalServiceClient osConfigZonalServiceClient = + OsConfigZonalServiceClient.create()) { + OSPolicyAssignment osPolicyAssignment = OSPolicyAssignment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + OSPolicyAssignment response = + osConfigZonalServiceClient + .updateOSPolicyAssignmentAsync(osPolicyAssignment, updateMask) + .get(); + } + } +} +// [END osconfig_v1alpha_generated_osconfigzonalserviceclient_updateospolicyassignment_ospolicyassignmentfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalservicesettings/getospolicyassignment/SyncGetOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalservicesettings/getospolicyassignment/SyncGetOSPolicyAssignment.java new file mode 100644 index 00000000..8d9a8a6f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/osconfigzonalservicesettings/getospolicyassignment/SyncGetOSPolicyAssignment.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalservicesettings_getospolicyassignment_sync] +import com.google.cloud.osconfig.v1alpha.OsConfigZonalServiceSettings; +import java.time.Duration; + +public class SyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignment(); + } + + public static void syncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigZonalServiceSettings.Builder osConfigZonalServiceSettingsBuilder = + OsConfigZonalServiceSettings.newBuilder(); + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .setRetrySettings( + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigZonalServiceSettings osConfigZonalServiceSettings = + osConfigZonalServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1alpha_generated_osconfigzonalservicesettings_getospolicyassignment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/stub/osconfigzonalservicestubsettings/getospolicyassignment/SyncGetOSPolicyAssignment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/stub/osconfigzonalservicestubsettings/getospolicyassignment/SyncGetOSPolicyAssignment.java new file mode 100644 index 00000000..d4de76d3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1alpha/stub/osconfigzonalservicestubsettings/getospolicyassignment/SyncGetOSPolicyAssignment.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1alpha.stub.samples; + +// [START osconfig_v1alpha_generated_osconfigzonalservicestubsettings_getospolicyassignment_sync] +import com.google.cloud.osconfig.v1alpha.stub.OsConfigZonalServiceStubSettings; +import java.time.Duration; + +public class SyncGetOSPolicyAssignment { + + public static void main(String[] args) throws Exception { + syncGetOSPolicyAssignment(); + } + + public static void syncGetOSPolicyAssignment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigZonalServiceStubSettings.Builder osConfigZonalServiceSettingsBuilder = + OsConfigZonalServiceStubSettings.newBuilder(); + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .setRetrySettings( + osConfigZonalServiceSettingsBuilder + .getOSPolicyAssignmentSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigZonalServiceStubSettings osConfigZonalServiceSettings = + osConfigZonalServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1alpha_generated_osconfigzonalservicestubsettings_getospolicyassignment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/cancelpatchjob/AsyncCancelPatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/cancelpatchjob/AsyncCancelPatchJob.java new file mode 100644 index 00000000..bec62b74 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/cancelpatchjob/AsyncCancelPatchJob.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_cancelpatchjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class AsyncCancelPatchJob { + + public static void main(String[] args) throws Exception { + asyncCancelPatchJob(); + } + + public static void asyncCancelPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + osConfigServiceClient.cancelPatchJobCallable().futureCall(request); + // Do something. + PatchJobs.PatchJob response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_cancelpatchjob_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/cancelpatchjob/SyncCancelPatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/cancelpatchjob/SyncCancelPatchJob.java new file mode 100644 index 00000000..1e1218fa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/cancelpatchjob/SyncCancelPatchJob.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_cancelpatchjob_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class SyncCancelPatchJob { + + public static void main(String[] args) throws Exception { + syncCancelPatchJob(); + } + + public static void syncCancelPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.CancelPatchJobRequest request = + PatchJobs.CancelPatchJobRequest.newBuilder().setName("name3373707").build(); + PatchJobs.PatchJob response = osConfigServiceClient.cancelPatchJob(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_cancelpatchjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..e430d0df --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.OsConfigServiceSettings; +import com.google.cloud.osconfig.v1beta.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. + OsConfigServiceSettings osConfigServiceSettings = + OsConfigServiceSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + OsConfigServiceClient osConfigServiceClient = + OsConfigServiceClient.create(osConfigServiceSettings); + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..8ecb3b52 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_create_setcredentialsprovider1_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.OsConfigServiceSettings; + +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. + OsConfigServiceSettings osConfigServiceSettings = + OsConfigServiceSettings.newBuilder() + .setTransportChannelProvider( + OsConfigServiceSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + OsConfigServiceClient osConfigServiceClient = + OsConfigServiceClient.create(osConfigServiceSettings); + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..1de949aa --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_create_setendpoint_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.OsConfigServiceSettings; +import com.google.cloud.osconfig.v1beta.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. + OsConfigServiceSettings osConfigServiceSettings = + OsConfigServiceSettings.newBuilder().setEndpoint(myEndpoint).build(); + OsConfigServiceClient osConfigServiceClient = + OsConfigServiceClient.create(osConfigServiceSettings); + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/AsyncCreateGuestPolicy.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/AsyncCreateGuestPolicy.java new file mode 100644 index 00000000..5df1cec4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/AsyncCreateGuestPolicy.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class AsyncCreateGuestPolicy { + + public static void main(String[] args) throws Exception { + asyncCreateGuestPolicy(); + } + + public static void asyncCreateGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.CreateGuestPolicyRequest request = + GuestPolicies.CreateGuestPolicyRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setGuestPolicyId("guestPolicyId1234592741") + .setGuestPolicy(GuestPolicies.GuestPolicy.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.createGuestPolicyCallable().futureCall(request); + // Do something. + GuestPolicies.GuestPolicy response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicy.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicy.java new file mode 100644 index 00000000..77ee5cb4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicy.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class SyncCreateGuestPolicy { + + public static void main(String[] args) throws Exception { + syncCreateGuestPolicy(); + } + + public static void syncCreateGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.CreateGuestPolicyRequest request = + GuestPolicies.CreateGuestPolicyRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setGuestPolicyId("guestPolicyId1234592741") + .setGuestPolicy(GuestPolicies.GuestPolicy.newBuilder().build()) + .build(); + GuestPolicies.GuestPolicy response = osConfigServiceClient.createGuestPolicy(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicyProjectnameGuestpoliciesguestpolicy.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicyProjectnameGuestpoliciesguestpolicy.java new file mode 100644 index 00000000..2602868b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicyProjectnameGuestpoliciesguestpolicy.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_projectnameguestpoliciesguestpolicy_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class SyncCreateGuestPolicyProjectnameGuestpoliciesguestpolicy { + + public static void main(String[] args) throws Exception { + syncCreateGuestPolicyProjectnameGuestpoliciesguestpolicy(); + } + + public static void syncCreateGuestPolicyProjectnameGuestpoliciesguestpolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + GuestPolicies.GuestPolicy guestPolicy = GuestPolicies.GuestPolicy.newBuilder().build(); + GuestPolicies.GuestPolicy response = + osConfigServiceClient.createGuestPolicy(parent, guestPolicy); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_projectnameguestpoliciesguestpolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicyStringGuestpoliciesguestpolicy.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicyStringGuestpoliciesguestpolicy.java new file mode 100644 index 00000000..f9cce410 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createguestpolicy/SyncCreateGuestPolicyStringGuestpoliciesguestpolicy.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_stringguestpoliciesguestpolicy_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class SyncCreateGuestPolicyStringGuestpoliciesguestpolicy { + + public static void main(String[] args) throws Exception { + syncCreateGuestPolicyStringGuestpoliciesguestpolicy(); + } + + public static void syncCreateGuestPolicyStringGuestpoliciesguestpolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + GuestPolicies.GuestPolicy guestPolicy = GuestPolicies.GuestPolicy.newBuilder().build(); + GuestPolicies.GuestPolicy response = + osConfigServiceClient.createGuestPolicy(parent, guestPolicy); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_createguestpolicy_stringguestpoliciesguestpolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createpatchdeployment/AsyncCreatePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createpatchdeployment/AsyncCreatePatchDeployment.java new file mode 100644 index 00000000..6f170922 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createpatchdeployment/AsyncCreatePatchDeployment.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_createpatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class AsyncCreatePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncCreatePatchDeployment(); + } + + public static void asyncCreatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.CreatePatchDeploymentRequest request = + PatchDeployments.CreatePatchDeploymentRequest.newBuilder() + .setParent("parent-995424086") + .setPatchDeploymentId("patchDeploymentId-1180405976") + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.createPatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_createpatchdeployment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeployment.java new file mode 100644 index 00000000..ca711368 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/createpatchdeployment/SyncCreatePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_createpatchdeployment_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncCreatePatchDeployment { + + public static void main(String[] args) throws Exception { + syncCreatePatchDeployment(); + } + + public static void syncCreatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.CreatePatchDeploymentRequest request = + PatchDeployments.CreatePatchDeploymentRequest.newBuilder() + .setParent("parent-995424086") + .setPatchDeploymentId("patchDeploymentId-1180405976") + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.createPatchDeployment(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_createpatchdeployment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/AsyncDeleteGuestPolicy.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/AsyncDeleteGuestPolicy.java new file mode 100644 index 00000000..2cd9ccb2 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/AsyncDeleteGuestPolicy.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.protobuf.Empty; + +public class AsyncDeleteGuestPolicy { + + public static void main(String[] args) throws Exception { + asyncDeleteGuestPolicy(); + } + + public static void asyncDeleteGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.DeleteGuestPolicyRequest request = + GuestPolicies.DeleteGuestPolicyRequest.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.deleteGuestPolicyCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicy.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicy.java new file mode 100644 index 00000000..0573c4ee --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicy.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteGuestPolicy { + + public static void main(String[] args) throws Exception { + syncDeleteGuestPolicy(); + } + + public static void syncDeleteGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.DeleteGuestPolicyRequest request = + GuestPolicies.DeleteGuestPolicyRequest.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .build(); + osConfigServiceClient.deleteGuestPolicy(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicyGuestpolicyname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicyGuestpolicyname.java new file mode 100644 index 00000000..af7def0a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicyGuestpolicyname.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_guestpolicyname_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteGuestPolicyGuestpolicyname { + + public static void main(String[] args) throws Exception { + syncDeleteGuestPolicyGuestpolicyname(); + } + + public static void syncDeleteGuestPolicyGuestpolicyname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicyName name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]"); + osConfigServiceClient.deleteGuestPolicy(name); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_guestpolicyname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicyString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicyString.java new file mode 100644 index 00000000..d46e5b90 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deleteguestpolicy/SyncDeleteGuestPolicyString.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_string_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.protobuf.Empty; + +public class SyncDeleteGuestPolicyString { + + public static void main(String[] args) throws Exception { + syncDeleteGuestPolicyString(); + } + + public static void syncDeleteGuestPolicyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString(); + osConfigServiceClient.deleteGuestPolicy(name); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_deleteguestpolicy_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deletepatchdeployment/AsyncDeletePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deletepatchdeployment/AsyncDeletePatchDeployment.java new file mode 100644 index 00000000..13d59734 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deletepatchdeployment/AsyncDeletePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_deletepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; +import com.google.protobuf.Empty; + +public class AsyncDeletePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncDeletePatchDeployment(); + } + + public static void asyncDeletePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.DeletePatchDeploymentRequest request = + PatchDeployments.DeletePatchDeploymentRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + osConfigServiceClient.deletePatchDeploymentCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_deletepatchdeployment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeployment.java new file mode 100644 index 00000000..e4b3dd1b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/deletepatchdeployment/SyncDeletePatchDeployment.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_deletepatchdeployment_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; +import com.google.protobuf.Empty; + +public class SyncDeletePatchDeployment { + + public static void main(String[] args) throws Exception { + syncDeletePatchDeployment(); + } + + public static void syncDeletePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.DeletePatchDeploymentRequest request = + PatchDeployments.DeletePatchDeploymentRequest.newBuilder().setName("name3373707").build(); + osConfigServiceClient.deletePatchDeployment(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_deletepatchdeployment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/executepatchjob/AsyncExecutePatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/executepatchjob/AsyncExecutePatchJob.java new file mode 100644 index 00000000..71c0847b --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/executepatchjob/AsyncExecutePatchJob.java @@ -0,0 +1,53 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_executepatchjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; +import com.google.protobuf.Duration; + +public class AsyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + asyncExecutePatchJob(); + } + + public static void asyncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent("parent-995424086") + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.executePatchJobCallable().futureCall(request); + // Do something. + PatchJobs.PatchJob response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_executepatchjob_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/executepatchjob/SyncExecutePatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/executepatchjob/SyncExecutePatchJob.java new file mode 100644 index 00000000..fe3595a8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/executepatchjob/SyncExecutePatchJob.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_executepatchjob_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; +import com.google.protobuf.Duration; + +public class SyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + syncExecutePatchJob(); + } + + public static void syncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ExecutePatchJobRequest request = + PatchJobs.ExecutePatchJobRequest.newBuilder() + .setParent("parent-995424086") + .setDescription("description-1724546052") + .setInstanceFilter(PatchJobs.PatchInstanceFilter.newBuilder().build()) + .setPatchConfig(PatchJobs.PatchConfig.newBuilder().build()) + .setDuration(Duration.newBuilder().build()) + .setDryRun(true) + .setDisplayName("displayName1714148973") + .setRollout(PatchJobs.PatchRollout.newBuilder().build()) + .build(); + PatchJobs.PatchJob response = osConfigServiceClient.executePatchJob(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_executepatchjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/AsyncGetGuestPolicy.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/AsyncGetGuestPolicy.java new file mode 100644 index 00000000..be78c56a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/AsyncGetGuestPolicy.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class AsyncGetGuestPolicy { + + public static void main(String[] args) throws Exception { + asyncGetGuestPolicy(); + } + + public static void asyncGetGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.GetGuestPolicyRequest request = + GuestPolicies.GetGuestPolicyRequest.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.getGuestPolicyCallable().futureCall(request); + // Do something. + GuestPolicies.GuestPolicy response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicy.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicy.java new file mode 100644 index 00000000..9ff2e04d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicy.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class SyncGetGuestPolicy { + + public static void main(String[] args) throws Exception { + syncGetGuestPolicy(); + } + + public static void syncGetGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.GetGuestPolicyRequest request = + GuestPolicies.GetGuestPolicyRequest.newBuilder() + .setName(GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString()) + .build(); + GuestPolicies.GuestPolicy response = osConfigServiceClient.getGuestPolicy(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicyGuestpolicyname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicyGuestpolicyname.java new file mode 100644 index 00000000..8c633ddf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicyGuestpolicyname.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_guestpolicyname_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class SyncGetGuestPolicyGuestpolicyname { + + public static void main(String[] args) throws Exception { + syncGetGuestPolicyGuestpolicyname(); + } + + public static void syncGetGuestPolicyGuestpolicyname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicyName name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]"); + GuestPolicies.GuestPolicy response = osConfigServiceClient.getGuestPolicy(name); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_guestpolicyname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicyString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicyString.java new file mode 100644 index 00000000..592a7af8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getguestpolicy/SyncGetGuestPolicyString.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_string_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.GuestPolicyName; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class SyncGetGuestPolicyString { + + public static void main(String[] args) throws Exception { + syncGetGuestPolicyString(); + } + + public static void syncGetGuestPolicyString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = GuestPolicyName.of("[PROJECT]", "[GUEST_POLICY]").toString(); + GuestPolicies.GuestPolicy response = osConfigServiceClient.getGuestPolicy(name); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getguestpolicy_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchdeployment/AsyncGetPatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchdeployment/AsyncGetPatchDeployment.java new file mode 100644 index 00000000..5410a177 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchdeployment/AsyncGetPatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getpatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class AsyncGetPatchDeployment { + + public static void main(String[] args) throws Exception { + asyncGetPatchDeployment(); + } + + public static void asyncGetPatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.GetPatchDeploymentRequest request = + PatchDeployments.GetPatchDeploymentRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + osConfigServiceClient.getPatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getpatchdeployment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeployment.java new file mode 100644 index 00000000..b3e4e847 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchdeployment/SyncGetPatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getpatchdeployment_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncGetPatchDeployment { + + public static void main(String[] args) throws Exception { + syncGetPatchDeployment(); + } + + public static void syncGetPatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.GetPatchDeploymentRequest request = + PatchDeployments.GetPatchDeploymentRequest.newBuilder().setName("name3373707").build(); + PatchDeployments.PatchDeployment response = osConfigServiceClient.getPatchDeployment(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getpatchdeployment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchjob/AsyncGetPatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchjob/AsyncGetPatchJob.java new file mode 100644 index 00000000..9347d9ad --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchjob/AsyncGetPatchJob.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getpatchjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class AsyncGetPatchJob { + + public static void main(String[] args) throws Exception { + asyncGetPatchJob(); + } + + public static void asyncGetPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.GetPatchJobRequest request = + PatchJobs.GetPatchJobRequest.newBuilder().setName("name3373707").build(); + ApiFuture future = + osConfigServiceClient.getPatchJobCallable().futureCall(request); + // Do something. + PatchJobs.PatchJob response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getpatchjob_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchjob/SyncGetPatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchjob/SyncGetPatchJob.java new file mode 100644 index 00000000..fa515fa5 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/getpatchjob/SyncGetPatchJob.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_getpatchjob_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class SyncGetPatchJob { + + public static void main(String[] args) throws Exception { + syncGetPatchJob(); + } + + public static void syncGetPatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.GetPatchJobRequest request = + PatchJobs.GetPatchJobRequest.newBuilder().setName("name3373707").build(); + PatchJobs.PatchJob response = osConfigServiceClient.getPatchJob(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_getpatchjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/AsyncListGuestPolicies.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/AsyncListGuestPolicies.java new file mode 100644 index 00000000..c5bb356e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/AsyncListGuestPolicies.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class AsyncListGuestPolicies { + + public static void main(String[] args) throws Exception { + asyncListGuestPolicies(); + } + + public static void asyncListGuestPolicies() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.ListGuestPoliciesRequest request = + GuestPolicies.ListGuestPoliciesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigServiceClient.listGuestPoliciesPagedCallable().futureCall(request); + // Do something. + for (GuestPolicies.GuestPolicy element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/AsyncListGuestPoliciesPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/AsyncListGuestPoliciesPaged.java new file mode 100644 index 00000000..c04ac2ef --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/AsyncListGuestPoliciesPaged.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_paged_async] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; +import com.google.common.base.Strings; + +public class AsyncListGuestPoliciesPaged { + + public static void main(String[] args) throws Exception { + asyncListGuestPoliciesPaged(); + } + + public static void asyncListGuestPoliciesPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.ListGuestPoliciesRequest request = + GuestPolicies.ListGuestPoliciesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + GuestPolicies.ListGuestPoliciesResponse response = + osConfigServiceClient.listGuestPoliciesCallable().call(request); + for (GuestPolicies.GuestPolicy element : response.getGuestPoliciesList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPolicies.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPolicies.java new file mode 100644 index 00000000..cf093351 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPolicies.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class SyncListGuestPolicies { + + public static void main(String[] args) throws Exception { + syncListGuestPolicies(); + } + + public static void syncListGuestPolicies() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.ListGuestPoliciesRequest request = + GuestPolicies.ListGuestPoliciesRequest.newBuilder() + .setParent(ProjectName.of("[PROJECT]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (GuestPolicies.GuestPolicy element : + osConfigServiceClient.listGuestPolicies(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPoliciesProjectname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPoliciesProjectname.java new file mode 100644 index 00000000..8e7b830e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPoliciesProjectname.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_projectname_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class SyncListGuestPoliciesProjectname { + + public static void main(String[] args) throws Exception { + syncListGuestPoliciesProjectname(); + } + + public static void syncListGuestPoliciesProjectname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + ProjectName parent = ProjectName.of("[PROJECT]"); + for (GuestPolicies.GuestPolicy element : + osConfigServiceClient.listGuestPolicies(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_projectname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPoliciesString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPoliciesString.java new file mode 100644 index 00000000..b80c460c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listguestpolicies/SyncListGuestPoliciesString.java @@ -0,0 +1,42 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_string_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.ProjectName; + +public class SyncListGuestPoliciesString { + + public static void main(String[] args) throws Exception { + syncListGuestPoliciesString(); + } + + public static void syncListGuestPoliciesString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String parent = ProjectName.of("[PROJECT]").toString(); + for (GuestPolicies.GuestPolicy element : + osConfigServiceClient.listGuestPolicies(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listguestpolicies_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeployments.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeployments.java new file mode 100644 index 00000000..d2aeeea8 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeployments.java @@ -0,0 +1,49 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchdeployments_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class AsyncListPatchDeployments { + + public static void main(String[] args) throws Exception { + asyncListPatchDeployments(); + } + + public static void asyncListPatchDeployments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = + osConfigServiceClient.listPatchDeploymentsPagedCallable().futureCall(request); + // Do something. + for (PatchDeployments.PatchDeployment element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchdeployments_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeploymentsPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeploymentsPaged.java new file mode 100644 index 00000000..3d2dd00d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/AsyncListPatchDeploymentsPaged.java @@ -0,0 +1,56 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchdeployments_paged_async] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; +import com.google.common.base.Strings; + +public class AsyncListPatchDeploymentsPaged { + + public static void main(String[] args) throws Exception { + asyncListPatchDeploymentsPaged(); + } + + public static void asyncListPatchDeploymentsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + PatchDeployments.ListPatchDeploymentsResponse response = + osConfigServiceClient.listPatchDeploymentsCallable().call(request); + for (PatchDeployments.PatchDeployment element : response.getPatchDeploymentsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchdeployments_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/SyncListPatchDeployments.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/SyncListPatchDeployments.java new file mode 100644 index 00000000..80c87720 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchdeployments/SyncListPatchDeployments.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchdeployments_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncListPatchDeployments { + + public static void main(String[] args) throws Exception { + syncListPatchDeployments(); + } + + public static void syncListPatchDeployments() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ListPatchDeploymentsRequest request = + PatchDeployments.ListPatchDeploymentsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (PatchDeployments.PatchDeployment element : + osConfigServiceClient.listPatchDeployments(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchdeployments_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetails.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetails.java new file mode 100644 index 00000000..097fda43 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetails.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class AsyncListPatchJobInstanceDetails { + + public static void main(String[] args) throws Exception { + asyncListPatchJobInstanceDetails(); + } + + public static void asyncListPatchJobInstanceDetails() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobInstanceDetailsRequest request = + PatchJobs.ListPatchJobInstanceDetailsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigServiceClient.listPatchJobInstanceDetailsPagedCallable().futureCall(request); + // Do something. + for (PatchJobs.PatchJobInstanceDetails element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetailsPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetailsPaged.java new file mode 100644 index 00000000..e91249ef --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/AsyncListPatchJobInstanceDetailsPaged.java @@ -0,0 +1,58 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_paged_async] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; +import com.google.common.base.Strings; + +public class AsyncListPatchJobInstanceDetailsPaged { + + public static void main(String[] args) throws Exception { + asyncListPatchJobInstanceDetailsPaged(); + } + + public static void asyncListPatchJobInstanceDetailsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobInstanceDetailsRequest request = + PatchJobs.ListPatchJobInstanceDetailsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + PatchJobs.ListPatchJobInstanceDetailsResponse response = + osConfigServiceClient.listPatchJobInstanceDetailsCallable().call(request); + for (PatchJobs.PatchJobInstanceDetails element : + response.getPatchJobInstanceDetailsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetails.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetails.java new file mode 100644 index 00000000..64c77045 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetails.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class SyncListPatchJobInstanceDetails { + + public static void main(String[] args) throws Exception { + syncListPatchJobInstanceDetails(); + } + + public static void syncListPatchJobInstanceDetails() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobInstanceDetailsRequest request = + PatchJobs.ListPatchJobInstanceDetailsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (PatchJobs.PatchJobInstanceDetails element : + osConfigServiceClient.listPatchJobInstanceDetails(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsString.java new file mode 100644 index 00000000..4a743ed1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobinstancedetails/SyncListPatchJobInstanceDetailsString.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_string_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class SyncListPatchJobInstanceDetailsString { + + public static void main(String[] args) throws Exception { + syncListPatchJobInstanceDetailsString(); + } + + public static void syncListPatchJobInstanceDetailsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String parent = "parent-995424086"; + for (PatchJobs.PatchJobInstanceDetails element : + osConfigServiceClient.listPatchJobInstanceDetails(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchjobinstancedetails_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/AsyncListPatchJobs.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/AsyncListPatchJobs.java new file mode 100644 index 00000000..36e72be9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/AsyncListPatchJobs.java @@ -0,0 +1,50 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchjobs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class AsyncListPatchJobs { + + public static void main(String[] args) throws Exception { + asyncListPatchJobs(); + } + + public static void asyncListPatchJobs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + ApiFuture future = + osConfigServiceClient.listPatchJobsPagedCallable().futureCall(request); + // Do something. + for (PatchJobs.PatchJob element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchjobs_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/AsyncListPatchJobsPaged.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/AsyncListPatchJobsPaged.java new file mode 100644 index 00000000..b2309df3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/AsyncListPatchJobsPaged.java @@ -0,0 +1,57 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchjobs_paged_async] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; +import com.google.common.base.Strings; + +public class AsyncListPatchJobsPaged { + + public static void main(String[] args) throws Exception { + asyncListPatchJobsPaged(); + } + + public static void asyncListPatchJobsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + while (true) { + PatchJobs.ListPatchJobsResponse response = + osConfigServiceClient.listPatchJobsCallable().call(request); + for (PatchJobs.PatchJob element : response.getPatchJobsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchjobs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/SyncListPatchJobs.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/SyncListPatchJobs.java new file mode 100644 index 00000000..79d6d0c6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/listpatchjobs/SyncListPatchJobs.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_listpatchjobs_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchJobs; + +public class SyncListPatchJobs { + + public static void main(String[] args) throws Exception { + syncListPatchJobs(); + } + + public static void syncListPatchJobs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchJobs.ListPatchJobsRequest request = + PatchJobs.ListPatchJobsRequest.newBuilder() + .setParent("parent-995424086") + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .setFilter("filter-1274492040") + .build(); + for (PatchJobs.PatchJob element : osConfigServiceClient.listPatchJobs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_listpatchjobs_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/lookupeffectiveguestpolicy/AsyncLookupEffectiveGuestPolicy.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/lookupeffectiveguestpolicy/AsyncLookupEffectiveGuestPolicy.java new file mode 100644 index 00000000..5b0a5247 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/lookupeffectiveguestpolicy/AsyncLookupEffectiveGuestPolicy.java @@ -0,0 +1,48 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_lookupeffectiveguestpolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class AsyncLookupEffectiveGuestPolicy { + + public static void main(String[] args) throws Exception { + asyncLookupEffectiveGuestPolicy(); + } + + public static void asyncLookupEffectiveGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.LookupEffectiveGuestPolicyRequest request = + GuestPolicies.LookupEffectiveGuestPolicyRequest.newBuilder() + .setInstance("instance555127957") + .setOsShortName("osShortName1253394339") + .setOsVersion("osVersion1812004436") + .setOsArchitecture("osArchitecture1339954519") + .build(); + ApiFuture future = + osConfigServiceClient.lookupEffectiveGuestPolicyCallable().futureCall(request); + // Do something. + GuestPolicies.EffectiveGuestPolicy response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_lookupeffectiveguestpolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/lookupeffectiveguestpolicy/SyncLookupEffectiveGuestPolicy.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/lookupeffectiveguestpolicy/SyncLookupEffectiveGuestPolicy.java new file mode 100644 index 00000000..927792e3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/lookupeffectiveguestpolicy/SyncLookupEffectiveGuestPolicy.java @@ -0,0 +1,45 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_lookupeffectiveguestpolicy_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; + +public class SyncLookupEffectiveGuestPolicy { + + public static void main(String[] args) throws Exception { + syncLookupEffectiveGuestPolicy(); + } + + public static void syncLookupEffectiveGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.LookupEffectiveGuestPolicyRequest request = + GuestPolicies.LookupEffectiveGuestPolicyRequest.newBuilder() + .setInstance("instance555127957") + .setOsShortName("osShortName1253394339") + .setOsVersion("osVersion1812004436") + .setOsArchitecture("osArchitecture1339954519") + .build(); + GuestPolicies.EffectiveGuestPolicy response = + osConfigServiceClient.lookupEffectiveGuestPolicy(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_lookupeffectiveguestpolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/AsyncPausePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/AsyncPausePatchDeployment.java new file mode 100644 index 00000000..7e91a761 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/AsyncPausePatchDeployment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class AsyncPausePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncPausePatchDeployment(); + } + + public static void asyncPausePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.PausePatchDeploymentRequest request = + PatchDeployments.PausePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.pausePatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeployment.java new file mode 100644 index 00000000..16c7598e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncPausePatchDeployment { + + public static void main(String[] args) throws Exception { + syncPausePatchDeployment(); + } + + public static void syncPausePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.PausePatchDeploymentRequest request = + PatchDeployments.PausePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.pausePatchDeployment(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentPatchdeploymentname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentPatchdeploymentname.java new file mode 100644 index 00000000..b51f9992 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentPatchdeploymentname.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_patchdeploymentname_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncPausePatchDeploymentPatchdeploymentname { + + public static void main(String[] args) throws Exception { + syncPausePatchDeploymentPatchdeploymentname(); + } + + public static void syncPausePatchDeploymentPatchdeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + PatchDeployments.PatchDeployment response = osConfigServiceClient.pausePatchDeployment(name); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_patchdeploymentname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentString.java new file mode 100644 index 00000000..71c65f5c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/pausepatchdeployment/SyncPausePatchDeploymentString.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_string_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncPausePatchDeploymentString { + + public static void main(String[] args) throws Exception { + syncPausePatchDeploymentString(); + } + + public static void syncPausePatchDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString(); + PatchDeployments.PatchDeployment response = osConfigServiceClient.pausePatchDeployment(name); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_pausepatchdeployment_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/AsyncResumePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/AsyncResumePatchDeployment.java new file mode 100644 index 00000000..fc64908d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/AsyncResumePatchDeployment.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class AsyncResumePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncResumePatchDeployment(); + } + + public static void asyncResumePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ResumePatchDeploymentRequest request = + PatchDeployments.ResumePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + ApiFuture future = + osConfigServiceClient.resumePatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeployment.java new file mode 100644 index 00000000..f9bdeb8a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncResumePatchDeployment { + + public static void main(String[] args) throws Exception { + syncResumePatchDeployment(); + } + + public static void syncResumePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.ResumePatchDeploymentRequest request = + PatchDeployments.ResumePatchDeploymentRequest.newBuilder() + .setName(PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.resumePatchDeployment(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentPatchdeploymentname.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentPatchdeploymentname.java new file mode 100644 index 00000000..6d5d2487 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentPatchdeploymentname.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_patchdeploymentname_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncResumePatchDeploymentPatchdeploymentname { + + public static void main(String[] args) throws Exception { + syncResumePatchDeploymentPatchdeploymentname(); + } + + public static void syncResumePatchDeploymentPatchdeploymentname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeploymentName name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]"); + PatchDeployments.PatchDeployment response = osConfigServiceClient.resumePatchDeployment(name); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_patchdeploymentname_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentString.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentString.java new file mode 100644 index 00000000..6200b7f7 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/resumepatchdeployment/SyncResumePatchDeploymentString.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_string_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeploymentName; +import com.google.cloud.osconfig.v1beta.PatchDeployments; + +public class SyncResumePatchDeploymentString { + + public static void main(String[] args) throws Exception { + syncResumePatchDeploymentString(); + } + + public static void syncResumePatchDeploymentString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + String name = PatchDeploymentName.of("[PROJECT]", "[PATCH_DEPLOYMENT]").toString(); + PatchDeployments.PatchDeployment response = osConfigServiceClient.resumePatchDeployment(name); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_resumepatchdeployment_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/AsyncUpdateGuestPolicy.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/AsyncUpdateGuestPolicy.java new file mode 100644 index 00000000..9fe7573a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/AsyncUpdateGuestPolicy.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_updateguestpolicy_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateGuestPolicy { + + public static void main(String[] args) throws Exception { + asyncUpdateGuestPolicy(); + } + + public static void asyncUpdateGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.UpdateGuestPolicyRequest request = + GuestPolicies.UpdateGuestPolicyRequest.newBuilder() + .setGuestPolicy(GuestPolicies.GuestPolicy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.updateGuestPolicyCallable().futureCall(request); + // Do something. + GuestPolicies.GuestPolicy response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_updateguestpolicy_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/SyncUpdateGuestPolicy.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/SyncUpdateGuestPolicy.java new file mode 100644 index 00000000..14f5d73e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/SyncUpdateGuestPolicy.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_updateguestpolicy_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateGuestPolicy { + + public static void main(String[] args) throws Exception { + syncUpdateGuestPolicy(); + } + + public static void syncUpdateGuestPolicy() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.UpdateGuestPolicyRequest request = + GuestPolicies.UpdateGuestPolicyRequest.newBuilder() + .setGuestPolicy(GuestPolicies.GuestPolicy.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + GuestPolicies.GuestPolicy response = osConfigServiceClient.updateGuestPolicy(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_updateguestpolicy_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/SyncUpdateGuestPolicyGuestpoliciesguestpolicyFieldmask.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/SyncUpdateGuestPolicyGuestpoliciesguestpolicyFieldmask.java new file mode 100644 index 00000000..43d1946c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updateguestpolicy/SyncUpdateGuestPolicyGuestpoliciesguestpolicyFieldmask.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_updateguestpolicy_guestpoliciesguestpolicyfieldmask_sync] +import com.google.cloud.osconfig.v1beta.GuestPolicies; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.protobuf.FieldMask; + +public class SyncUpdateGuestPolicyGuestpoliciesguestpolicyFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateGuestPolicyGuestpoliciesguestpolicyFieldmask(); + } + + public static void syncUpdateGuestPolicyGuestpoliciesguestpolicyFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + GuestPolicies.GuestPolicy guestPolicy = GuestPolicies.GuestPolicy.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + GuestPolicies.GuestPolicy response = + osConfigServiceClient.updateGuestPolicy(guestPolicy, updateMask); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_updateguestpolicy_guestpoliciesguestpolicyfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/AsyncUpdatePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/AsyncUpdatePatchDeployment.java new file mode 100644 index 00000000..b81c1ea1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/AsyncUpdatePatchDeployment.java @@ -0,0 +1,47 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_updatepatchdeployment_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; +import com.google.protobuf.FieldMask; + +public class AsyncUpdatePatchDeployment { + + public static void main(String[] args) throws Exception { + asyncUpdatePatchDeployment(); + } + + public static void asyncUpdatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.UpdatePatchDeploymentRequest request = + PatchDeployments.UpdatePatchDeploymentRequest.newBuilder() + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = + osConfigServiceClient.updatePatchDeploymentCallable().futureCall(request); + // Do something. + PatchDeployments.PatchDeployment response = future.get(); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_updatepatchdeployment_async] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeployment.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeployment.java new file mode 100644 index 00000000..1661b7dc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeployment.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_updatepatchdeployment_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; +import com.google.protobuf.FieldMask; + +public class SyncUpdatePatchDeployment { + + public static void main(String[] args) throws Exception { + syncUpdatePatchDeployment(); + } + + public static void syncUpdatePatchDeployment() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.UpdatePatchDeploymentRequest request = + PatchDeployments.UpdatePatchDeploymentRequest.newBuilder() + .setPatchDeployment(PatchDeployments.PatchDeployment.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.updatePatchDeployment(request); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_updatepatchdeployment_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask.java new file mode 100644 index 00000000..083d297d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigserviceclient/updatepatchdeployment/SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask.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.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigserviceclient_updatepatchdeployment_patchdeploymentspatchdeploymentfieldmask_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceClient; +import com.google.cloud.osconfig.v1beta.PatchDeployments; +import com.google.protobuf.FieldMask; + +public class SyncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask(); + } + + public static void syncUpdatePatchDeploymentPatchdeploymentspatchdeploymentFieldmask() + throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (OsConfigServiceClient osConfigServiceClient = OsConfigServiceClient.create()) { + PatchDeployments.PatchDeployment patchDeployment = + PatchDeployments.PatchDeployment.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + PatchDeployments.PatchDeployment response = + osConfigServiceClient.updatePatchDeployment(patchDeployment, updateMask); + } + } +} +// [END osconfig_v1beta_generated_osconfigserviceclient_updatepatchdeployment_patchdeploymentspatchdeploymentfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigservicesettings/executepatchjob/SyncExecutePatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigservicesettings/executepatchjob/SyncExecutePatchJob.java new file mode 100644 index 00000000..2916e08e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/osconfigservicesettings/executepatchjob/SyncExecutePatchJob.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.samples; + +// [START osconfig_v1beta_generated_osconfigservicesettings_executepatchjob_sync] +import com.google.cloud.osconfig.v1beta.OsConfigServiceSettings; +import java.time.Duration; + +public class SyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + syncExecutePatchJob(); + } + + public static void syncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigServiceSettings.Builder osConfigServiceSettingsBuilder = + OsConfigServiceSettings.newBuilder(); + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .setRetrySettings( + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigServiceSettings osConfigServiceSettings = osConfigServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1beta_generated_osconfigservicesettings_executepatchjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/osconfig/v1beta/stub/osconfigservicestubsettings/executepatchjob/SyncExecutePatchJob.java b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/stub/osconfigservicestubsettings/executepatchjob/SyncExecutePatchJob.java new file mode 100644 index 00000000..2cf0e889 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/osconfig/v1beta/stub/osconfigservicestubsettings/executepatchjob/SyncExecutePatchJob.java @@ -0,0 +1,46 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.osconfig.v1beta.stub.samples; + +// [START osconfig_v1beta_generated_osconfigservicestubsettings_executepatchjob_sync] +import com.google.cloud.osconfig.v1beta.stub.OsConfigServiceStubSettings; +import java.time.Duration; + +public class SyncExecutePatchJob { + + public static void main(String[] args) throws Exception { + syncExecutePatchJob(); + } + + public static void syncExecutePatchJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + OsConfigServiceStubSettings.Builder osConfigServiceSettingsBuilder = + OsConfigServiceStubSettings.newBuilder(); + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .setRetrySettings( + osConfigServiceSettingsBuilder + .executePatchJobSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + OsConfigServiceStubSettings osConfigServiceSettings = osConfigServiceSettingsBuilder.build(); + } +} +// [END osconfig_v1beta_generated_osconfigservicestubsettings_executepatchjob_sync] diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 1a6cf0d1..983af3f6 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-os-config - 2.4.2 + 2.4.3 diff --git a/versions.txt b/versions.txt index b473bd93..d35d6ee2 100644 --- a/versions.txt +++ b/versions.txt @@ -1,10 +1,10 @@ # Format: # module:released-version:current-version -google-cloud-os-config:2.4.3:2.4.3 -grpc-google-cloud-os-config-v1:2.4.3:2.4.3 -grpc-google-cloud-os-config-v1beta:2.4.3:2.4.3 -grpc-google-cloud-os-config-v1alpha:2.4.3:2.4.3 -proto-google-cloud-os-config-v1:2.4.3:2.4.3 -proto-google-cloud-os-config-v1alpha:2.4.3:2.4.3 -proto-google-cloud-os-config-v1beta:2.4.3:2.4.3 +google-cloud-os-config:2.5.0:2.5.0 +grpc-google-cloud-os-config-v1:2.5.0:2.5.0 +grpc-google-cloud-os-config-v1beta:2.5.0:2.5.0 +grpc-google-cloud-os-config-v1alpha:2.5.0:2.5.0 +proto-google-cloud-os-config-v1:2.5.0:2.5.0 +proto-google-cloud-os-config-v1alpha:2.5.0:2.5.0 +proto-google-cloud-os-config-v1beta:2.5.0:2.5.0