diff --git a/.github/.OwlBot.lock.yaml b/.github/.OwlBot.lock.yaml index a79f0627..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:2567a120ce90fadb6201999b87d649d9f67459de28815ad239bce9ebfaa18a74 -# created: 2022-05-19T15:12:45.278246753Z + digest: sha256:6d4e3a15c62cfdcb823d60e16da7521e7c6fc00eba07c8ff12e4de9924a57d28 +# created: 2022-06-29T23:17:33.110417661Z diff --git a/.github/.OwlBot.yaml b/.github/.OwlBot.yaml index 519a25c2..2b3f0c68 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" @@ -32,3 +33,5 @@ deep-copy-regex: dest: "/owl-bot-staging/$1/grpc-google-cloud-scheduler-$1/src" - source: "/google/cloud/scheduler/(v.*)/.*-java/gapic-google-.*/src" dest: "/owl-bot-staging/$1/google-cloud-scheduler/src" +- source: "/google/cloud/scheduler/(v.*)/.*-java/samples/snippets/generated" + dest: "/owl-bot-staging/$1/samples/snippets/generated" diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 5f9903d5..21616d24 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -5,8 +5,7 @@ # https://help.github.com/en/github/creating-cloning-and-archiving-repositories/about-code-owners#codeowners-syntax # The @googleapis/aap-dpes is the default owner for changes in this repo -* @googleapis/yoshi-java @googleapis/aap-dpes -**/*.java @googleapis/aap-dpes +* @googleapis/yoshi-java # The java-samples-reviewers team is the default owner for samples changes -samples/**/*.java @googleapis/java-samples-reviewers +samples/**/*.java @googleapis/java-samples-reviewers @googleapis/aap-dpes 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/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/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/.repo-metadata.json b/.repo-metadata.json index 58864706..eb1e30c9 100644 --- a/.repo-metadata.json +++ b/.repo-metadata.json @@ -13,6 +13,5 @@ "transport": "grpc", "requires_billing": false, "api_description": "lets you set up scheduled units of work to be executed at defined times or regular intervals. These work units are commonly known as cron jobs. Typical use cases might include sending out a report email on a daily basis, updating some cached data every 10 minutes, or updating some summary information once an hour.", - "library_type": "GAPIC_AUTO", - "codeowner_team": "@googleapis/aap-dpes" + "library_type": "GAPIC_AUTO" } diff --git a/CHANGELOG.md b/CHANGELOG.md index 7ddfa1d0..4cf0c19b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,19 @@ # Changelog +## [2.3.0](https://github.com/googleapis/java-scheduler/compare/v2.2.0...v2.3.0) (2022-07-01) + + +### Features + +* Enable REST transport for most of Java and Go clients ([#773](https://github.com/googleapis/java-scheduler/issues/773)) ([499ea4c](https://github.com/googleapis/java-scheduler/commit/499ea4caf29fa8713e4468b34b323582ac7ebbb7)) + + +### Dependencies + +* update dependency com.google.cloud:google-cloud-pubsub-bom to v1.119.0 ([#766](https://github.com/googleapis/java-scheduler/issues/766)) ([f50e8cf](https://github.com/googleapis/java-scheduler/commit/f50e8cf230850297e9b219ac0a4736c99391325f)) +* update dependency com.google.cloud:google-cloud-pubsub-bom to v1.119.1 ([#769](https://github.com/googleapis/java-scheduler/issues/769)) ([c0a770e](https://github.com/googleapis/java-scheduler/commit/c0a770e65fe53b2eda747ca9e0dbc4ab494b19e2)) +* update dependency com.google.cloud:google-cloud-shared-dependencies to v2.13.0 ([#772](https://github.com/googleapis/java-scheduler/issues/772)) ([56819c7](https://github.com/googleapis/java-scheduler/commit/56819c7a5a7a5b59519b25a699251953992b91d9)) + ## [2.2.0](https://github.com/googleapis/java-scheduler/compare/v2.1.23...v2.2.0) (2022-05-23) diff --git a/README.md b/README.md index 48d46c26..ca5e2be7 100644 --- a/README.md +++ b/README.md @@ -19,7 +19,7 @@ If you are using Maven with [BOM][libraries-bom], add this to your pom.xml file com.google.cloud libraries-bom - 25.3.0 + 25.4.0 pom import @@ -41,7 +41,7 @@ If you are using Maven without BOM, add this to your dependencies: com.google.cloud google-cloud-scheduler - 2.1.23 + 2.2.0 ``` @@ -49,20 +49,20 @@ If you are using Maven without BOM, add this to your dependencies: If you are using Gradle 5.x or later, add this to your dependencies ```Groovy -implementation platform('com.google.cloud:libraries-bom:25.3.0') +implementation platform('com.google.cloud:libraries-bom:25.4.0') implementation 'com.google.cloud:google-cloud-scheduler' ``` If you are using Gradle without BOM, add this to your dependencies ```Groovy -implementation 'com.google.cloud:google-cloud-scheduler:2.1.23' +implementation 'com.google.cloud:google-cloud-scheduler:2.2.0' ``` If you are using SBT, add this to your dependencies ```Scala -libraryDependencies += "com.google.cloud" % "google-cloud-scheduler" % "2.1.23" +libraryDependencies += "com.google.cloud" % "google-cloud-scheduler" % "2.2.0" ``` ## Authentication diff --git a/google-cloud-scheduler-bom/pom.xml b/google-cloud-scheduler-bom/pom.xml index 4cccb893..167f0a58 100644 --- a/google-cloud-scheduler-bom/pom.xml +++ b/google-cloud-scheduler-bom/pom.xml @@ -3,12 +3,12 @@ 4.0.0 com.google.cloud google-cloud-scheduler-bom - 2.2.0 + 2.3.0 pom com.google.cloud google-cloud-shared-config - 1.4.0 + 1.5.0 Google Cloud scheduler BOM @@ -52,27 +52,27 @@ com.google.cloud google-cloud-scheduler - 2.2.0 + 2.3.0 com.google.api.grpc grpc-google-cloud-scheduler-v1beta1 - 0.87.0 + 0.88.0 com.google.api.grpc grpc-google-cloud-scheduler-v1 - 2.2.0 + 2.3.0 com.google.api.grpc proto-google-cloud-scheduler-v1beta1 - 0.87.0 + 0.88.0 com.google.api.grpc proto-google-cloud-scheduler-v1 - 2.2.0 + 2.3.0 diff --git a/google-cloud-scheduler/pom.xml b/google-cloud-scheduler/pom.xml index 6d0a7e04..cbc7c84c 100644 --- a/google-cloud-scheduler/pom.xml +++ b/google-cloud-scheduler/pom.xml @@ -3,7 +3,7 @@ 4.0.0 com.google.cloud google-cloud-scheduler - 2.2.0 + 2.3.0 jar Google Cloud Scheduler https://github.com/googleapis/java-scheduler @@ -11,7 +11,7 @@ com.google.cloud google-cloud-scheduler-parent - 2.2.0 + 2.3.0 google-cloud-scheduler @@ -62,6 +62,10 @@ com.google.api gax-grpc + + com.google.api + gax-httpjson + org.threeten threetenbp @@ -100,12 +104,24 @@ + + 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-scheduler/src/main/java/com/google/cloud/scheduler/v1/CloudSchedulerClient.java b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/CloudSchedulerClient.java index 8a9c4664..de39d76f 100644 --- a/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/CloudSchedulerClient.java +++ b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/CloudSchedulerClient.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; @@ -100,6 +99,20 @@ * CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings); * } * + *

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.
+ * CloudSchedulerSettings cloudSchedulerSettings =
+ *     CloudSchedulerSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CloudSchedulerSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @Generated("by gapic-generator-java") @@ -125,7 +138,6 @@ public static final CloudSchedulerClient create(CloudSchedulerSettings settings) * Constructs an instance of CloudSchedulerClient, using the given stub for making calls. This is * for advanced usage - prefer using create(CloudSchedulerSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final CloudSchedulerClient create(CloudSchedulerStub stub) { return new CloudSchedulerClient(stub); } @@ -140,7 +152,6 @@ protected CloudSchedulerClient(CloudSchedulerSettings settings) throws IOExcepti this.stub = ((CloudSchedulerStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected CloudSchedulerClient(CloudSchedulerStub stub) { this.settings = null; this.stub = stub; @@ -150,7 +161,6 @@ public final CloudSchedulerSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public CloudSchedulerStub getStub() { return stub; } @@ -283,7 +293,7 @@ public final UnaryCallable listJobsPaged * .build(); * while (true) { * ListJobsResponse response = cloudSchedulerClient.listJobsCallable().call(request); - * for (Job element : response.getResponsesList()) { + * for (Job element : response.getJobsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/CloudSchedulerSettings.java b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/CloudSchedulerSettings.java index 17938456..b065c107 100644 --- a/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/CloudSchedulerSettings.java +++ b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/CloudSchedulerSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -139,11 +140,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CloudSchedulerStubSettings.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 CloudSchedulerStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CloudSchedulerStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CloudSchedulerStubSettings.defaultTransportChannelProvider(); } @@ -153,11 +161,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CloudSchedulerStubSettings.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); @@ -195,6 +209,11 @@ private static Builder createDefault() { return new Builder(CloudSchedulerStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CloudSchedulerStubSettings.newHttpJsonBuilder()); + } + public CloudSchedulerStubSettings.Builder getStubSettingsBuilder() { return ((CloudSchedulerStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/stub/CloudSchedulerStubSettings.java b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/stub/CloudSchedulerStubSettings.java index 274db559..fa706a24 100644 --- a/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/stub/CloudSchedulerStubSettings.java +++ b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/stub/CloudSchedulerStubSettings.java @@ -27,6 +27,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; @@ -204,13 +207,17 @@ public UnaryCallSettings runJobSettings() { return runJobSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public CloudSchedulerStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCloudSchedulerStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCloudSchedulerStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -243,18 +250,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(CloudSchedulerStubSettings.class)) @@ -262,11 +276,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(CloudSchedulerStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CloudSchedulerStubSettings.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); @@ -412,6 +445,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 .listJobsSettings() diff --git a/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/stub/HttpJsonCloudSchedulerCallableFactory.java b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/stub/HttpJsonCloudSchedulerCallableFactory.java new file mode 100644 index 00000000..ed9f51aa --- /dev/null +++ b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/stub/HttpJsonCloudSchedulerCallableFactory.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.scheduler.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 CloudScheduler service API. + * + *

This class is for advanced usage. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCloudSchedulerCallableFactory + 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-scheduler/src/main/java/com/google/cloud/scheduler/v1/stub/HttpJsonCloudSchedulerStub.java b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/stub/HttpJsonCloudSchedulerStub.java new file mode 100644 index 00000000..7b1f796a --- /dev/null +++ b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1/stub/HttpJsonCloudSchedulerStub.java @@ -0,0 +1,554 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.scheduler.v1.stub; + +import static com.google.cloud.scheduler.v1.CloudSchedulerClient.ListJobsPagedResponse; + +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.scheduler.v1.CreateJobRequest; +import com.google.cloud.scheduler.v1.DeleteJobRequest; +import com.google.cloud.scheduler.v1.GetJobRequest; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.ListJobsRequest; +import com.google.cloud.scheduler.v1.ListJobsResponse; +import com.google.cloud.scheduler.v1.PauseJobRequest; +import com.google.cloud.scheduler.v1.ResumeJobRequest; +import com.google.cloud.scheduler.v1.RunJobRequest; +import com.google.cloud.scheduler.v1.UpdateJobRequest; +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 CloudScheduler service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@Generated("by gapic-generator-java") +@BetaApi +public class HttpJsonCloudSchedulerStub extends CloudSchedulerStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listJobsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1.CloudScheduler/ListJobs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/jobs", + 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(ListJobsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1.CloudScheduler/GetJob") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/jobs/*}", + 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(Job.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor createJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1.CloudScheduler/CreateJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{parent=projects/*/locations/*}/jobs", + 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("job", request.getJob())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Job.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor updateJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1.CloudScheduler/UpdateJob") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{job.name=projects/*/locations/*/jobs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "job.name", request.getJob().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("job", request.getJob())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Job.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor deleteJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1.CloudScheduler/DeleteJob") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/jobs/*}", + 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 pauseJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1.CloudScheduler/PauseJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/jobs/*}: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(Job.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor resumeJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1.CloudScheduler/ResumeJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/jobs/*}: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(Job.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor runJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1.CloudScheduler/RunJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1/{name=projects/*/locations/*/jobs/*}:run", + 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(Job.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listJobsCallable; + private final UnaryCallable listJobsPagedCallable; + private final UnaryCallable getJobCallable; + private final UnaryCallable createJobCallable; + private final UnaryCallable updateJobCallable; + private final UnaryCallable deleteJobCallable; + private final UnaryCallable pauseJobCallable; + private final UnaryCallable resumeJobCallable; + private final UnaryCallable runJobCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCloudSchedulerStub create(CloudSchedulerStubSettings settings) + throws IOException { + return new HttpJsonCloudSchedulerStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCloudSchedulerStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCloudSchedulerStub( + CloudSchedulerStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCloudSchedulerStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCloudSchedulerStub( + CloudSchedulerStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCloudSchedulerStub, 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 HttpJsonCloudSchedulerStub( + CloudSchedulerStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCloudSchedulerCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCloudSchedulerStub, 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 HttpJsonCloudSchedulerStub( + CloudSchedulerStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listJobsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listJobsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings pauseJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(pauseJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings resumeJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(resumeJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings runJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(runJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listJobsCallable = + callableFactory.createUnaryCallable( + listJobsTransportSettings, settings.listJobsSettings(), clientContext); + this.listJobsPagedCallable = + callableFactory.createPagedCallable( + listJobsTransportSettings, settings.listJobsSettings(), clientContext); + this.getJobCallable = + callableFactory.createUnaryCallable( + getJobTransportSettings, settings.getJobSettings(), clientContext); + this.createJobCallable = + callableFactory.createUnaryCallable( + createJobTransportSettings, settings.createJobSettings(), clientContext); + this.updateJobCallable = + callableFactory.createUnaryCallable( + updateJobTransportSettings, settings.updateJobSettings(), clientContext); + this.deleteJobCallable = + callableFactory.createUnaryCallable( + deleteJobTransportSettings, settings.deleteJobSettings(), clientContext); + this.pauseJobCallable = + callableFactory.createUnaryCallable( + pauseJobTransportSettings, settings.pauseJobSettings(), clientContext); + this.resumeJobCallable = + callableFactory.createUnaryCallable( + resumeJobTransportSettings, settings.resumeJobSettings(), clientContext); + this.runJobCallable = + callableFactory.createUnaryCallable( + runJobTransportSettings, settings.runJobSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listJobsMethodDescriptor); + methodDescriptors.add(getJobMethodDescriptor); + methodDescriptors.add(createJobMethodDescriptor); + methodDescriptors.add(updateJobMethodDescriptor); + methodDescriptors.add(deleteJobMethodDescriptor); + methodDescriptors.add(pauseJobMethodDescriptor); + methodDescriptors.add(resumeJobMethodDescriptor); + methodDescriptors.add(runJobMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listJobsCallable() { + return listJobsCallable; + } + + @Override + public UnaryCallable listJobsPagedCallable() { + return listJobsPagedCallable; + } + + @Override + public UnaryCallable getJobCallable() { + return getJobCallable; + } + + @Override + public UnaryCallable createJobCallable() { + return createJobCallable; + } + + @Override + public UnaryCallable updateJobCallable() { + return updateJobCallable; + } + + @Override + public UnaryCallable deleteJobCallable() { + return deleteJobCallable; + } + + @Override + public UnaryCallable pauseJobCallable() { + return pauseJobCallable; + } + + @Override + public UnaryCallable resumeJobCallable() { + return resumeJobCallable; + } + + @Override + public UnaryCallable runJobCallable() { + return runJobCallable; + } + + @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-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClient.java b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClient.java index 4c22b99a..5e9460a1 100644 --- a/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClient.java +++ b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClient.java @@ -100,6 +100,20 @@ * CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings); * } * + *

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.
+ * CloudSchedulerSettings cloudSchedulerSettings =
+ *     CloudSchedulerSettings.newBuilder()
+ *         .setTransportChannelProvider(
+ *             CloudSchedulerSettings.defaultHttpJsonTransportProviderBuilder().build())
+ *         .build();
+ * CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings);
+ * }
+ * *

Please refer to the GitHub repository's samples for more quickstart code snippets. */ @BetaApi @@ -126,7 +140,6 @@ public static final CloudSchedulerClient create(CloudSchedulerSettings settings) * Constructs an instance of CloudSchedulerClient, using the given stub for making calls. This is * for advanced usage - prefer using create(CloudSchedulerSettings). */ - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public static final CloudSchedulerClient create(CloudSchedulerStub stub) { return new CloudSchedulerClient(stub); } @@ -141,7 +154,6 @@ protected CloudSchedulerClient(CloudSchedulerSettings settings) throws IOExcepti this.stub = ((CloudSchedulerStubSettings) settings.getStubSettings()).createStub(); } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") protected CloudSchedulerClient(CloudSchedulerStub stub) { this.settings = null; this.stub = stub; @@ -151,7 +163,6 @@ public final CloudSchedulerSettings getSettings() { return settings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public CloudSchedulerStub getStub() { return stub; } @@ -284,7 +295,7 @@ public final UnaryCallable listJobsPaged * .build(); * while (true) { * ListJobsResponse response = cloudSchedulerClient.listJobsCallable().call(request); - * for (Job element : response.getResponsesList()) { + * for (Job element : response.getJobsList()) { * // doThingsWith(element); * } * String nextPageToken = response.getNextPageToken(); diff --git a/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerSettings.java b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerSettings.java index 5efcdb40..513da07e 100644 --- a/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerSettings.java +++ b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerSettings.java @@ -23,6 +23,7 @@ import com.google.api.gax.core.GoogleCredentialsProvider; import com.google.api.gax.core.InstantiatingExecutorProvider; import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider; +import com.google.api.gax.httpjson.InstantiatingHttpJsonChannelProvider; import com.google.api.gax.rpc.ApiClientHeaderProvider; import com.google.api.gax.rpc.ClientContext; import com.google.api.gax.rpc.ClientSettings; @@ -140,11 +141,18 @@ public static GoogleCredentialsProvider.Builder defaultCredentialsProviderBuilde return CloudSchedulerStubSettings.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 CloudSchedulerStubSettings.defaultGrpcTransportProviderBuilder(); } + /** Returns a builder for the default REST ChannelProvider for this service. */ + @BetaApi + public static InstantiatingHttpJsonChannelProvider.Builder + defaultHttpJsonTransportProviderBuilder() { + return CloudSchedulerStubSettings.defaultHttpJsonTransportProviderBuilder(); + } + public static TransportChannelProvider defaultTransportChannelProvider() { return CloudSchedulerStubSettings.defaultTransportChannelProvider(); } @@ -154,11 +162,17 @@ public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuil return CloudSchedulerStubSettings.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); @@ -196,6 +210,11 @@ private static Builder createDefault() { return new Builder(CloudSchedulerStubSettings.newBuilder()); } + @BetaApi + private static Builder createHttpJsonDefault() { + return new Builder(CloudSchedulerStubSettings.newHttpJsonBuilder()); + } + public CloudSchedulerStubSettings.Builder getStubSettingsBuilder() { return ((CloudSchedulerStubSettings.Builder) getStubSettings()); } diff --git a/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/stub/CloudSchedulerStubSettings.java b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/stub/CloudSchedulerStubSettings.java index bef18381..4e8aa498 100644 --- a/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/stub/CloudSchedulerStubSettings.java +++ b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/stub/CloudSchedulerStubSettings.java @@ -27,6 +27,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; @@ -205,13 +208,17 @@ public UnaryCallSettings runJobSettings() { return runJobSettings; } - @BetaApi("A restructuring of stub classes is planned, so this may break in the future") public CloudSchedulerStub createStub() throws IOException { if (getTransportChannelProvider() .getTransportName() .equals(GrpcTransportChannel.getGrpcTransportName())) { return GrpcCloudSchedulerStub.create(this); } + if (getTransportChannelProvider() + .getTransportName() + .equals(HttpJsonTransportChannel.getHttpJsonTransportName())) { + return HttpJsonCloudSchedulerStub.create(this); + } throw new UnsupportedOperationException( String.format( "Transport not supported: %s", getTransportChannelProvider().getTransportName())); @@ -244,18 +251,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(CloudSchedulerStubSettings.class)) @@ -263,11 +277,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(CloudSchedulerStubSettings.class)) + .setTransportToken( + GaxHttpJsonProperties.getHttpJsonTokenName(), + GaxHttpJsonProperties.getHttpJsonVersion()); + } + + public static ApiClientHeaderProvider.Builder defaultApiClientHeaderProviderBuilder() { + return CloudSchedulerStubSettings.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); @@ -413,6 +446,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 .listJobsSettings() diff --git a/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/stub/HttpJsonCloudSchedulerCallableFactory.java b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/stub/HttpJsonCloudSchedulerCallableFactory.java new file mode 100644 index 00000000..1e6b5fe2 --- /dev/null +++ b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/stub/HttpJsonCloudSchedulerCallableFactory.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.scheduler.v1beta1.stub; + +import com.google.api.core.BetaApi; +import com.google.api.gax.httpjson.HttpJsonCallSettings; +import com.google.api.gax.httpjson.HttpJsonCallableFactory; +import com.google.api.gax.httpjson.HttpJsonOperationSnapshotCallable; +import com.google.api.gax.httpjson.HttpJsonStubCallableFactory; +import com.google.api.gax.httpjson.longrunning.stub.OperationsStub; +import com.google.api.gax.rpc.BatchingCallSettings; +import com.google.api.gax.rpc.ClientContext; +import com.google.api.gax.rpc.OperationCallSettings; +import com.google.api.gax.rpc.OperationCallable; +import com.google.api.gax.rpc.PagedCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallSettings; +import com.google.api.gax.rpc.ServerStreamingCallable; +import com.google.api.gax.rpc.UnaryCallSettings; +import com.google.api.gax.rpc.UnaryCallable; +import com.google.longrunning.Operation; +import javax.annotation.Generated; + +// AUTO-GENERATED DOCUMENTATION AND CLASS. +/** + * REST callable factory implementation for the CloudScheduler service API. + * + *

This class is for advanced usage. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCloudSchedulerCallableFactory + 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-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/stub/HttpJsonCloudSchedulerStub.java b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/stub/HttpJsonCloudSchedulerStub.java new file mode 100644 index 00000000..f23fb043 --- /dev/null +++ b/google-cloud-scheduler/src/main/java/com/google/cloud/scheduler/v1beta1/stub/HttpJsonCloudSchedulerStub.java @@ -0,0 +1,554 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.scheduler.v1beta1.stub; + +import static com.google.cloud.scheduler.v1beta1.CloudSchedulerClient.ListJobsPagedResponse; + +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.scheduler.v1beta1.CreateJobRequest; +import com.google.cloud.scheduler.v1beta1.DeleteJobRequest; +import com.google.cloud.scheduler.v1beta1.GetJobRequest; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.ListJobsRequest; +import com.google.cloud.scheduler.v1beta1.ListJobsResponse; +import com.google.cloud.scheduler.v1beta1.PauseJobRequest; +import com.google.cloud.scheduler.v1beta1.ResumeJobRequest; +import com.google.cloud.scheduler.v1beta1.RunJobRequest; +import com.google.cloud.scheduler.v1beta1.UpdateJobRequest; +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 CloudScheduler service API. + * + *

This class is for advanced usage and reflects the underlying API directly. + */ +@BetaApi +@Generated("by gapic-generator-java") +public class HttpJsonCloudSchedulerStub extends CloudSchedulerStub { + private static final TypeRegistry typeRegistry = TypeRegistry.newBuilder().build(); + + private static final ApiMethodDescriptor + listJobsMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1beta1.CloudScheduler/ListJobs") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/jobs", + 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(ListJobsResponse.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor getJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1beta1.CloudScheduler/GetJob") + .setHttpMethod("GET") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/jobs/*}", + 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(Job.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor createJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1beta1.CloudScheduler/CreateJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{parent=projects/*/locations/*}/jobs", + 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("job", request.getJob())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Job.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor updateJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1beta1.CloudScheduler/UpdateJob") + .setHttpMethod("PATCH") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{job.name=projects/*/locations/*/jobs/*}", + request -> { + Map fields = new HashMap<>(); + ProtoRestSerializer serializer = + ProtoRestSerializer.create(); + serializer.putPathParam(fields, "job.name", request.getJob().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("job", request.getJob())) + .build()) + .setResponseParser( + ProtoMessageResponseParser.newBuilder() + .setDefaultInstance(Job.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor deleteJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1beta1.CloudScheduler/DeleteJob") + .setHttpMethod("DELETE") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/jobs/*}", + 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 pauseJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1beta1.CloudScheduler/PauseJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/jobs/*}: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(Job.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor resumeJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1beta1.CloudScheduler/ResumeJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/jobs/*}: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(Job.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private static final ApiMethodDescriptor runJobMethodDescriptor = + ApiMethodDescriptor.newBuilder() + .setFullMethodName("google.cloud.scheduler.v1beta1.CloudScheduler/RunJob") + .setHttpMethod("POST") + .setType(ApiMethodDescriptor.MethodType.UNARY) + .setRequestFormatter( + ProtoMessageRequestFormatter.newBuilder() + .setPath( + "/v1beta1/{name=projects/*/locations/*/jobs/*}:run", + 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(Job.getDefaultInstance()) + .setDefaultTypeRegistry(typeRegistry) + .build()) + .build(); + + private final UnaryCallable listJobsCallable; + private final UnaryCallable listJobsPagedCallable; + private final UnaryCallable getJobCallable; + private final UnaryCallable createJobCallable; + private final UnaryCallable updateJobCallable; + private final UnaryCallable deleteJobCallable; + private final UnaryCallable pauseJobCallable; + private final UnaryCallable resumeJobCallable; + private final UnaryCallable runJobCallable; + + private final BackgroundResource backgroundResources; + private final HttpJsonStubCallableFactory callableFactory; + + public static final HttpJsonCloudSchedulerStub create(CloudSchedulerStubSettings settings) + throws IOException { + return new HttpJsonCloudSchedulerStub(settings, ClientContext.create(settings)); + } + + public static final HttpJsonCloudSchedulerStub create(ClientContext clientContext) + throws IOException { + return new HttpJsonCloudSchedulerStub( + CloudSchedulerStubSettings.newHttpJsonBuilder().build(), clientContext); + } + + public static final HttpJsonCloudSchedulerStub create( + ClientContext clientContext, HttpJsonStubCallableFactory callableFactory) throws IOException { + return new HttpJsonCloudSchedulerStub( + CloudSchedulerStubSettings.newHttpJsonBuilder().build(), clientContext, callableFactory); + } + + /** + * Constructs an instance of HttpJsonCloudSchedulerStub, 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 HttpJsonCloudSchedulerStub( + CloudSchedulerStubSettings settings, ClientContext clientContext) throws IOException { + this(settings, clientContext, new HttpJsonCloudSchedulerCallableFactory()); + } + + /** + * Constructs an instance of HttpJsonCloudSchedulerStub, 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 HttpJsonCloudSchedulerStub( + CloudSchedulerStubSettings settings, + ClientContext clientContext, + HttpJsonStubCallableFactory callableFactory) + throws IOException { + this.callableFactory = callableFactory; + + HttpJsonCallSettings listJobsTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(listJobsMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings getJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(getJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings createJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(createJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings updateJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(updateJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings deleteJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(deleteJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings pauseJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(pauseJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings resumeJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(resumeJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + HttpJsonCallSettings runJobTransportSettings = + HttpJsonCallSettings.newBuilder() + .setMethodDescriptor(runJobMethodDescriptor) + .setTypeRegistry(typeRegistry) + .build(); + + this.listJobsCallable = + callableFactory.createUnaryCallable( + listJobsTransportSettings, settings.listJobsSettings(), clientContext); + this.listJobsPagedCallable = + callableFactory.createPagedCallable( + listJobsTransportSettings, settings.listJobsSettings(), clientContext); + this.getJobCallable = + callableFactory.createUnaryCallable( + getJobTransportSettings, settings.getJobSettings(), clientContext); + this.createJobCallable = + callableFactory.createUnaryCallable( + createJobTransportSettings, settings.createJobSettings(), clientContext); + this.updateJobCallable = + callableFactory.createUnaryCallable( + updateJobTransportSettings, settings.updateJobSettings(), clientContext); + this.deleteJobCallable = + callableFactory.createUnaryCallable( + deleteJobTransportSettings, settings.deleteJobSettings(), clientContext); + this.pauseJobCallable = + callableFactory.createUnaryCallable( + pauseJobTransportSettings, settings.pauseJobSettings(), clientContext); + this.resumeJobCallable = + callableFactory.createUnaryCallable( + resumeJobTransportSettings, settings.resumeJobSettings(), clientContext); + this.runJobCallable = + callableFactory.createUnaryCallable( + runJobTransportSettings, settings.runJobSettings(), clientContext); + + this.backgroundResources = + new BackgroundResourceAggregation(clientContext.getBackgroundResources()); + } + + @InternalApi + public static List getMethodDescriptors() { + List methodDescriptors = new ArrayList<>(); + methodDescriptors.add(listJobsMethodDescriptor); + methodDescriptors.add(getJobMethodDescriptor); + methodDescriptors.add(createJobMethodDescriptor); + methodDescriptors.add(updateJobMethodDescriptor); + methodDescriptors.add(deleteJobMethodDescriptor); + methodDescriptors.add(pauseJobMethodDescriptor); + methodDescriptors.add(resumeJobMethodDescriptor); + methodDescriptors.add(runJobMethodDescriptor); + return methodDescriptors; + } + + @Override + public UnaryCallable listJobsCallable() { + return listJobsCallable; + } + + @Override + public UnaryCallable listJobsPagedCallable() { + return listJobsPagedCallable; + } + + @Override + public UnaryCallable getJobCallable() { + return getJobCallable; + } + + @Override + public UnaryCallable createJobCallable() { + return createJobCallable; + } + + @Override + public UnaryCallable updateJobCallable() { + return updateJobCallable; + } + + @Override + public UnaryCallable deleteJobCallable() { + return deleteJobCallable; + } + + @Override + public UnaryCallable pauseJobCallable() { + return pauseJobCallable; + } + + @Override + public UnaryCallable resumeJobCallable() { + return resumeJobCallable; + } + + @Override + public UnaryCallable runJobCallable() { + return runJobCallable; + } + + @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-scheduler/src/test/java/com/google/cloud/scheduler/v1/CloudSchedulerClientHttpJsonTest.java b/google-cloud-scheduler/src/test/java/com/google/cloud/scheduler/v1/CloudSchedulerClientHttpJsonTest.java new file mode 100644 index 00000000..e7689f24 --- /dev/null +++ b/google-cloud-scheduler/src/test/java/com/google/cloud/scheduler/v1/CloudSchedulerClientHttpJsonTest.java @@ -0,0 +1,875 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.scheduler.v1; + +import static com.google.cloud.scheduler.v1.CloudSchedulerClient.ListJobsPagedResponse; + +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.scheduler.v1.stub.HttpJsonCloudSchedulerStub; +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 com.google.rpc.Status; +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 CloudSchedulerClientHttpJsonTest { + private static MockHttpService mockService; + private static CloudSchedulerClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCloudSchedulerStub.getMethodDescriptors(), + CloudSchedulerSettings.getDefaultEndpoint()); + CloudSchedulerSettings settings = + CloudSchedulerSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CloudSchedulerSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CloudSchedulerClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listJobsTest() throws Exception { + Job responsesElement = Job.newBuilder().build(); + ListJobsResponse expectedResponse = + ListJobsResponse.newBuilder() + .setNextPageToken("") + .addAllJobs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListJobsPagedResponse pagedListResponse = client.listJobs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getJobsList().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 listJobsExceptionTest() 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.listJobs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listJobsTest2() throws Exception { + Job responsesElement = Job.newBuilder().build(); + ListJobsResponse expectedResponse = + ListJobsResponse.newBuilder() + .setNextPageToken("") + .addAllJobs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListJobsPagedResponse pagedListResponse = client.listJobs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getJobsList().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 listJobsExceptionTest2() 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.listJobs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getJobTest() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + + Job actualResponse = client.getJob(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 getJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + client.getJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getJobTest2() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + + Job actualResponse = client.getJob(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 getJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + client.getJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createJobTest() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Job job = Job.newBuilder().build(); + + Job actualResponse = client.createJob(parent, job); + 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 createJobExceptionTest() 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]"); + Job job = Job.newBuilder().build(); + client.createJob(parent, job); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createJobTest2() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + Job job = Job.newBuilder().build(); + + Job actualResponse = client.createJob(parent, job); + 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 createJobExceptionTest2() 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"; + Job job = Job.newBuilder().build(); + client.createJob(parent, job); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateJobTest() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Job job = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Job actualResponse = client.updateJob(job, 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 updateJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Job job = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateJob(job, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteJobTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + + client.deleteJob(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 deleteJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + client.deleteJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteJobTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + + client.deleteJob(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 deleteJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + client.deleteJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pauseJobTest() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + + Job actualResponse = client.pauseJob(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 pauseJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + client.pauseJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pauseJobTest2() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + + Job actualResponse = client.pauseJob(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 pauseJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + client.pauseJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resumeJobTest() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + + Job actualResponse = client.resumeJob(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 resumeJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + client.resumeJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resumeJobTest2() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + + Job actualResponse = client.resumeJob(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 resumeJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + client.resumeJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void runJobTest() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + + Job actualResponse = client.runJob(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 runJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + client.runJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void runJobTest2() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + + Job actualResponse = client.runJob(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 runJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + client.runJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/google-cloud-scheduler/src/test/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClientHttpJsonTest.java b/google-cloud-scheduler/src/test/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClientHttpJsonTest.java new file mode 100644 index 00000000..a336c188 --- /dev/null +++ b/google-cloud-scheduler/src/test/java/com/google/cloud/scheduler/v1beta1/CloudSchedulerClientHttpJsonTest.java @@ -0,0 +1,875 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.scheduler.v1beta1; + +import static com.google.cloud.scheduler.v1beta1.CloudSchedulerClient.ListJobsPagedResponse; + +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.scheduler.v1beta1.stub.HttpJsonCloudSchedulerStub; +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 com.google.rpc.Status; +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 CloudSchedulerClientHttpJsonTest { + private static MockHttpService mockService; + private static CloudSchedulerClient client; + + @BeforeClass + public static void startStaticServer() throws IOException { + mockService = + new MockHttpService( + HttpJsonCloudSchedulerStub.getMethodDescriptors(), + CloudSchedulerSettings.getDefaultEndpoint()); + CloudSchedulerSettings settings = + CloudSchedulerSettings.newHttpJsonBuilder() + .setTransportChannelProvider( + CloudSchedulerSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(mockService) + .build()) + .setCredentialsProvider(NoCredentialsProvider.create()) + .build(); + client = CloudSchedulerClient.create(settings); + } + + @AfterClass + public static void stopServer() { + client.close(); + } + + @Before + public void setUp() {} + + @After + public void tearDown() throws Exception { + mockService.reset(); + } + + @Test + public void listJobsTest() throws Exception { + Job responsesElement = Job.newBuilder().build(); + ListJobsResponse expectedResponse = + ListJobsResponse.newBuilder() + .setNextPageToken("") + .addAllJobs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + + ListJobsPagedResponse pagedListResponse = client.listJobs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getJobsList().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 listJobsExceptionTest() 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.listJobs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void listJobsTest2() throws Exception { + Job responsesElement = Job.newBuilder().build(); + ListJobsResponse expectedResponse = + ListJobsResponse.newBuilder() + .setNextPageToken("") + .addAllJobs(Arrays.asList(responsesElement)) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + + ListJobsPagedResponse pagedListResponse = client.listJobs(parent); + + List resources = Lists.newArrayList(pagedListResponse.iterateAll()); + + Assert.assertEquals(1, resources.size()); + Assert.assertEquals(expectedResponse.getJobsList().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 listJobsExceptionTest2() 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.listJobs(parent); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getJobTest() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + + Job actualResponse = client.getJob(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 getJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + client.getJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void getJobTest2() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + + Job actualResponse = client.getJob(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 getJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + client.getJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createJobTest() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Job job = Job.newBuilder().build(); + + Job actualResponse = client.createJob(parent, job); + 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 createJobExceptionTest() 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]"); + Job job = Job.newBuilder().build(); + client.createJob(parent, job); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void createJobTest2() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String parent = "projects/project-5833/locations/location-5833"; + Job job = Job.newBuilder().build(); + + Job actualResponse = client.createJob(parent, job); + 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 createJobExceptionTest2() 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"; + Job job = Job.newBuilder().build(); + client.createJob(parent, job); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void updateJobTest() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + Job job = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + + Job actualResponse = client.updateJob(job, 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 updateJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + Job job = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + client.updateJob(job, updateMask); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteJobTest() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + + client.deleteJob(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 deleteJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + client.deleteJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void deleteJobTest2() throws Exception { + Empty expectedResponse = Empty.newBuilder().build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + + client.deleteJob(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 deleteJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + client.deleteJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pauseJobTest() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + + Job actualResponse = client.pauseJob(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 pauseJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + client.pauseJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void pauseJobTest2() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + + Job actualResponse = client.pauseJob(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 pauseJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + client.pauseJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resumeJobTest() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + + Job actualResponse = client.resumeJob(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 resumeJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + client.resumeJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void resumeJobTest2() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + + Job actualResponse = client.resumeJob(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 resumeJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + client.resumeJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void runJobTest() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + + Job actualResponse = client.runJob(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 runJobExceptionTest() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + client.runJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } + + @Test + public void runJobTest2() throws Exception { + Job expectedResponse = + Job.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .setDescription("description-1724546052") + .setSchedule("schedule-697920873") + .setTimeZone("timeZone-2077180903") + .setUserUpdateTime(Timestamp.newBuilder().build()) + .setStatus(Status.newBuilder().build()) + .setScheduleTime(Timestamp.newBuilder().build()) + .setLastAttemptTime(Timestamp.newBuilder().build()) + .setRetryConfig(RetryConfig.newBuilder().build()) + .setAttemptDeadline(Duration.newBuilder().build()) + .build(); + mockService.addResponse(expectedResponse); + + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + + Job actualResponse = client.runJob(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 runJobExceptionTest2() throws Exception { + ApiException exception = + ApiExceptionFactory.createException( + new Exception(), FakeStatusCode.of(StatusCode.Code.INVALID_ARGUMENT), false); + mockService.addException(exception); + + try { + String name = "projects/project-3306/locations/location-3306/jobs/job-3306"; + client.runJob(name); + Assert.fail("No exception raised"); + } catch (InvalidArgumentException e) { + // Expected exception. + } + } +} diff --git a/grpc-google-cloud-scheduler-v1/pom.xml b/grpc-google-cloud-scheduler-v1/pom.xml index fbc00cb7..17c13564 100644 --- a/grpc-google-cloud-scheduler-v1/pom.xml +++ b/grpc-google-cloud-scheduler-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-scheduler-v1 - 2.2.0 + 2.3.0 grpc-google-cloud-scheduler-v1 GRPC library for grpc-google-cloud-scheduler-v1 com.google.cloud google-cloud-scheduler-parent - 2.2.0 + 2.3.0 diff --git a/grpc-google-cloud-scheduler-v1beta1/pom.xml b/grpc-google-cloud-scheduler-v1beta1/pom.xml index e72bb970..dabe8c90 100644 --- a/grpc-google-cloud-scheduler-v1beta1/pom.xml +++ b/grpc-google-cloud-scheduler-v1beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc grpc-google-cloud-scheduler-v1beta1 - 0.87.0 + 0.88.0 grpc-google-cloud-scheduler-v1beta1 GRPC library for grpc-google-cloud-scheduler-v1beta1 com.google.cloud google-cloud-scheduler-parent - 2.2.0 + 2.3.0 diff --git a/owlbot.py b/owlbot.py index 74b6f52f..ab119b1b 100644 --- a/owlbot.py +++ b/owlbot.py @@ -21,4 +21,7 @@ s.move(library) s.remove_staging_dirs() -java.common_templates(excludes=[".kokoro/dependencies.sh"]) +java.common_templates(excludes=[ + ".kokoro/dependencies.sh", + ".github/CODEOWNERS" +]) diff --git a/pom.xml b/pom.xml index 32d6f52e..13655e62 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.google.cloud google-cloud-scheduler-parent pom - 2.2.0 + 2.3.0 Google Cloud Scheduler Parent https://github.com/googleapis/java-scheduler @@ -14,7 +14,7 @@ com.google.cloud google-cloud-shared-config - 1.4.0 + 1.5.0 @@ -61,33 +61,33 @@ com.google.api.grpc proto-google-cloud-scheduler-v1beta1 - 0.87.0 + 0.88.0 com.google.api.grpc proto-google-cloud-scheduler-v1 - 2.2.0 + 2.3.0 com.google.api.grpc grpc-google-cloud-scheduler-v1beta1 - 0.87.0 + 0.88.0 com.google.api.grpc grpc-google-cloud-scheduler-v1 - 2.2.0 + 2.3.0 com.google.cloud google-cloud-scheduler - 2.2.0 + 2.3.0 com.google.cloud google-cloud-shared-dependencies - 2.12.0 + 2.13.0 pom import @@ -106,7 +106,7 @@ com.google.cloud google-cloud-pubsub-bom - 1.118.0 + 1.119.1 pom import diff --git a/proto-google-cloud-scheduler-v1/pom.xml b/proto-google-cloud-scheduler-v1/pom.xml index 406a8f21..697dcf5e 100644 --- a/proto-google-cloud-scheduler-v1/pom.xml +++ b/proto-google-cloud-scheduler-v1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-scheduler-v1 - 2.2.0 + 2.3.0 proto-google-cloud-scheduler-v1 PROTO library for proto-google-cloud-scheduler-v1 com.google.cloud google-cloud-scheduler-parent - 2.2.0 + 2.3.0 diff --git a/proto-google-cloud-scheduler-v1beta1/pom.xml b/proto-google-cloud-scheduler-v1beta1/pom.xml index b287b5fa..c1028d81 100644 --- a/proto-google-cloud-scheduler-v1beta1/pom.xml +++ b/proto-google-cloud-scheduler-v1beta1/pom.xml @@ -4,13 +4,13 @@ 4.0.0 com.google.api.grpc proto-google-cloud-scheduler-v1beta1 - 0.87.0 + 0.88.0 proto-google-cloud-scheduler-v1beta1 PROTO library for proto-google-cloud-scheduler-v1beta1 com.google.cloud google-cloud-scheduler-parent - 2.2.0 + 2.3.0 diff --git a/samples/install-without-bom/pom.xml b/samples/install-without-bom/pom.xml index 1d6f4fef..e4d73b5e 100644 --- a/samples/install-without-bom/pom.xml +++ b/samples/install-without-bom/pom.xml @@ -29,7 +29,7 @@ com.google.cloud google-cloud-scheduler - 2.1.23 + 2.2.0 diff --git a/samples/snapshot/pom.xml b/samples/snapshot/pom.xml index be26f126..d323eacd 100644 --- a/samples/snapshot/pom.xml +++ b/samples/snapshot/pom.xml @@ -28,7 +28,7 @@ com.google.cloud google-cloud-scheduler - 2.1.23 + 2.2.0 diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..a4af734c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.CloudSchedulerSettings; +import com.google.cloud.scheduler.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. + CloudSchedulerSettings cloudSchedulerSettings = + CloudSchedulerSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings); + } +} +// [END scheduler_v1_generated_cloudschedulerclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..c9b0b2c6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_create_setcredentialsprovider1_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.CloudSchedulerSettings; + +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. + CloudSchedulerSettings cloudSchedulerSettings = + CloudSchedulerSettings.newBuilder() + .setTransportChannelProvider( + CloudSchedulerSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings); + } +} +// [END scheduler_v1_generated_cloudschedulerclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..c9c07d49 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_create_setendpoint_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.CloudSchedulerSettings; +import com.google.cloud.scheduler.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. + CloudSchedulerSettings cloudSchedulerSettings = + CloudSchedulerSettings.newBuilder().setEndpoint(myEndpoint).build(); + CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings); + } +} +// [END scheduler_v1_generated_cloudschedulerclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/createjob/AsyncCreateJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/createjob/AsyncCreateJob.java new file mode 100644 index 00000000..8f87b838 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/createjob/AsyncCreateJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_createjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.CreateJobRequest; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.LocationName; + +public class AsyncCreateJob { + + public static void main(String[] args) throws Exception { + asyncCreateJob(); + } + + public static void asyncCreateJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + CreateJobRequest request = + CreateJobRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setJob(Job.newBuilder().build()) + .build(); + ApiFuture future = cloudSchedulerClient.createJobCallable().futureCall(request); + // Do something. + Job response = future.get(); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_createjob_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/createjob/SyncCreateJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/createjob/SyncCreateJob.java new file mode 100644 index 00000000..e64236a0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/createjob/SyncCreateJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_createjob_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.CreateJobRequest; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.LocationName; + +public class SyncCreateJob { + + public static void main(String[] args) throws Exception { + syncCreateJob(); + } + + public static void syncCreateJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + CreateJobRequest request = + CreateJobRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setJob(Job.newBuilder().build()) + .build(); + Job response = cloudSchedulerClient.createJob(request); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_createjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/createjob/SyncCreateJobLocationnameJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/createjob/SyncCreateJobLocationnameJob.java new file mode 100644 index 00000000..195c8ac9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/createjob/SyncCreateJobLocationnameJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_createjob_locationnamejob_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.LocationName; + +public class SyncCreateJobLocationnameJob { + + public static void main(String[] args) throws Exception { + syncCreateJobLocationnameJob(); + } + + public static void syncCreateJobLocationnameJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Job job = Job.newBuilder().build(); + Job response = cloudSchedulerClient.createJob(parent, job); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_createjob_locationnamejob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/createjob/SyncCreateJobStringJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/createjob/SyncCreateJobStringJob.java new file mode 100644 index 00000000..e0b5795e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/createjob/SyncCreateJobStringJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_createjob_stringjob_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.LocationName; + +public class SyncCreateJobStringJob { + + public static void main(String[] args) throws Exception { + syncCreateJobStringJob(); + } + + public static void syncCreateJobStringJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Job job = Job.newBuilder().build(); + Job response = cloudSchedulerClient.createJob(parent, job); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_createjob_stringjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/deletejob/AsyncDeleteJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/deletejob/AsyncDeleteJob.java new file mode 100644 index 00000000..18abb40f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/deletejob/AsyncDeleteJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_deletejob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.DeleteJobRequest; +import com.google.cloud.scheduler.v1.JobName; +import com.google.protobuf.Empty; + +public class AsyncDeleteJob { + + public static void main(String[] args) throws Exception { + asyncDeleteJob(); + } + + public static void asyncDeleteJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + DeleteJobRequest request = + DeleteJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + ApiFuture future = cloudSchedulerClient.deleteJobCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_deletejob_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/deletejob/SyncDeleteJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/deletejob/SyncDeleteJob.java new file mode 100644 index 00000000..45995ffc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/deletejob/SyncDeleteJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_deletejob_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.DeleteJobRequest; +import com.google.cloud.scheduler.v1.JobName; + +public class SyncDeleteJob { + + public static void main(String[] args) throws Exception { + syncDeleteJob(); + } + + public static void syncDeleteJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + DeleteJobRequest request = + DeleteJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + cloudSchedulerClient.deleteJob(request); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_deletejob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/deletejob/SyncDeleteJobJobname.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/deletejob/SyncDeleteJobJobname.java new file mode 100644 index 00000000..97e14c2d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/deletejob/SyncDeleteJobJobname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_deletejob_jobname_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.JobName; + +public class SyncDeleteJobJobname { + + public static void main(String[] args) throws Exception { + syncDeleteJobJobname(); + } + + public static void syncDeleteJobJobname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + cloudSchedulerClient.deleteJob(name); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_deletejob_jobname_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/deletejob/SyncDeleteJobString.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/deletejob/SyncDeleteJobString.java new file mode 100644 index 00000000..d84aebbe --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/deletejob/SyncDeleteJobString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_deletejob_string_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.JobName; + +public class SyncDeleteJobString { + + public static void main(String[] args) throws Exception { + syncDeleteJobString(); + } + + public static void syncDeleteJobString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); + cloudSchedulerClient.deleteJob(name); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_deletejob_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/getjob/AsyncGetJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/getjob/AsyncGetJob.java new file mode 100644 index 00000000..4bba66b0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/getjob/AsyncGetJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_getjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.GetJobRequest; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; + +public class AsyncGetJob { + + public static void main(String[] args) throws Exception { + asyncGetJob(); + } + + public static void asyncGetJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + GetJobRequest request = + GetJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + ApiFuture future = cloudSchedulerClient.getJobCallable().futureCall(request); + // Do something. + Job response = future.get(); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_getjob_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/getjob/SyncGetJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/getjob/SyncGetJob.java new file mode 100644 index 00000000..252599db --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/getjob/SyncGetJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_getjob_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.GetJobRequest; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; + +public class SyncGetJob { + + public static void main(String[] args) throws Exception { + syncGetJob(); + } + + public static void syncGetJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + GetJobRequest request = + GetJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + Job response = cloudSchedulerClient.getJob(request); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_getjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/getjob/SyncGetJobJobname.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/getjob/SyncGetJobJobname.java new file mode 100644 index 00000000..b9f31172 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/getjob/SyncGetJobJobname.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_getjob_jobname_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; + +public class SyncGetJobJobname { + + public static void main(String[] args) throws Exception { + syncGetJobJobname(); + } + + public static void syncGetJobJobname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + Job response = cloudSchedulerClient.getJob(name); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_getjob_jobname_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/getjob/SyncGetJobString.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/getjob/SyncGetJobString.java new file mode 100644 index 00000000..afacfa88 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/getjob/SyncGetJobString.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_getjob_string_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; + +public class SyncGetJobString { + + public static void main(String[] args) throws Exception { + syncGetJobString(); + } + + public static void syncGetJobString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); + Job response = cloudSchedulerClient.getJob(name); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_getjob_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/AsyncListJobs.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/AsyncListJobs.java new file mode 100644 index 00000000..589e7cbf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/AsyncListJobs.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_listjobs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.ListJobsRequest; +import com.google.cloud.scheduler.v1.LocationName; + +public class AsyncListJobs { + + public static void main(String[] args) throws Exception { + asyncListJobs(); + } + + public static void asyncListJobs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + ListJobsRequest request = + ListJobsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = cloudSchedulerClient.listJobsPagedCallable().futureCall(request); + // Do something. + for (Job element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_listjobs_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/AsyncListJobsPaged.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/AsyncListJobsPaged.java new file mode 100644 index 00000000..947a54f3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/AsyncListJobsPaged.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_listjobs_paged_async] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.ListJobsRequest; +import com.google.cloud.scheduler.v1.ListJobsResponse; +import com.google.cloud.scheduler.v1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListJobsPaged { + + public static void main(String[] args) throws Exception { + asyncListJobsPaged(); + } + + public static void asyncListJobsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + ListJobsRequest request = + ListJobsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListJobsResponse response = cloudSchedulerClient.listJobsCallable().call(request); + for (Job element : response.getJobsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_listjobs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/SyncListJobs.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/SyncListJobs.java new file mode 100644 index 00000000..d9c021c6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/SyncListJobs.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_listjobs_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.ListJobsRequest; +import com.google.cloud.scheduler.v1.LocationName; + +public class SyncListJobs { + + public static void main(String[] args) throws Exception { + syncListJobs(); + } + + public static void syncListJobs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + ListJobsRequest request = + ListJobsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Job element : cloudSchedulerClient.listJobs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_listjobs_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/SyncListJobsLocationname.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/SyncListJobsLocationname.java new file mode 100644 index 00000000..a1f499eb --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/SyncListJobsLocationname.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_listjobs_locationname_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.LocationName; + +public class SyncListJobsLocationname { + + public static void main(String[] args) throws Exception { + syncListJobsLocationname(); + } + + public static void syncListJobsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Job element : cloudSchedulerClient.listJobs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_listjobs_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/SyncListJobsString.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/SyncListJobsString.java new file mode 100644 index 00000000..9c0ed249 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/listjobs/SyncListJobsString.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_listjobs_string_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.LocationName; + +public class SyncListJobsString { + + public static void main(String[] args) throws Exception { + syncListJobsString(); + } + + public static void syncListJobsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Job element : cloudSchedulerClient.listJobs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_listjobs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/pausejob/AsyncPauseJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/pausejob/AsyncPauseJob.java new file mode 100644 index 00000000..58daeda4 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/pausejob/AsyncPauseJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_pausejob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; +import com.google.cloud.scheduler.v1.PauseJobRequest; + +public class AsyncPauseJob { + + public static void main(String[] args) throws Exception { + asyncPauseJob(); + } + + public static void asyncPauseJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + PauseJobRequest request = + PauseJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + ApiFuture future = cloudSchedulerClient.pauseJobCallable().futureCall(request); + // Do something. + Job response = future.get(); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_pausejob_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/pausejob/SyncPauseJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/pausejob/SyncPauseJob.java new file mode 100644 index 00000000..7990b740 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/pausejob/SyncPauseJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_pausejob_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; +import com.google.cloud.scheduler.v1.PauseJobRequest; + +public class SyncPauseJob { + + public static void main(String[] args) throws Exception { + syncPauseJob(); + } + + public static void syncPauseJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + PauseJobRequest request = + PauseJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + Job response = cloudSchedulerClient.pauseJob(request); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_pausejob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/pausejob/SyncPauseJobJobname.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/pausejob/SyncPauseJobJobname.java new file mode 100644 index 00000000..0a917b56 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/pausejob/SyncPauseJobJobname.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_pausejob_jobname_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; + +public class SyncPauseJobJobname { + + public static void main(String[] args) throws Exception { + syncPauseJobJobname(); + } + + public static void syncPauseJobJobname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + Job response = cloudSchedulerClient.pauseJob(name); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_pausejob_jobname_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/pausejob/SyncPauseJobString.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/pausejob/SyncPauseJobString.java new file mode 100644 index 00000000..d769eac9 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/pausejob/SyncPauseJobString.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_pausejob_string_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; + +public class SyncPauseJobString { + + public static void main(String[] args) throws Exception { + syncPauseJobString(); + } + + public static void syncPauseJobString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); + Job response = cloudSchedulerClient.pauseJob(name); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_pausejob_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/resumejob/AsyncResumeJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/resumejob/AsyncResumeJob.java new file mode 100644 index 00000000..f5613616 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/resumejob/AsyncResumeJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_resumejob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; +import com.google.cloud.scheduler.v1.ResumeJobRequest; + +public class AsyncResumeJob { + + public static void main(String[] args) throws Exception { + asyncResumeJob(); + } + + public static void asyncResumeJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + ResumeJobRequest request = + ResumeJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + ApiFuture future = cloudSchedulerClient.resumeJobCallable().futureCall(request); + // Do something. + Job response = future.get(); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_resumejob_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/resumejob/SyncResumeJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/resumejob/SyncResumeJob.java new file mode 100644 index 00000000..95a3d43d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/resumejob/SyncResumeJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_resumejob_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; +import com.google.cloud.scheduler.v1.ResumeJobRequest; + +public class SyncResumeJob { + + public static void main(String[] args) throws Exception { + syncResumeJob(); + } + + public static void syncResumeJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + ResumeJobRequest request = + ResumeJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + Job response = cloudSchedulerClient.resumeJob(request); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_resumejob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/resumejob/SyncResumeJobJobname.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/resumejob/SyncResumeJobJobname.java new file mode 100644 index 00000000..ce1b7b19 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/resumejob/SyncResumeJobJobname.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_resumejob_jobname_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; + +public class SyncResumeJobJobname { + + public static void main(String[] args) throws Exception { + syncResumeJobJobname(); + } + + public static void syncResumeJobJobname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + Job response = cloudSchedulerClient.resumeJob(name); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_resumejob_jobname_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/resumejob/SyncResumeJobString.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/resumejob/SyncResumeJobString.java new file mode 100644 index 00000000..28f1e4ef --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/resumejob/SyncResumeJobString.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_resumejob_string_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; + +public class SyncResumeJobString { + + public static void main(String[] args) throws Exception { + syncResumeJobString(); + } + + public static void syncResumeJobString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); + Job response = cloudSchedulerClient.resumeJob(name); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_resumejob_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/runjob/AsyncRunJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/runjob/AsyncRunJob.java new file mode 100644 index 00000000..14620fe3 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/runjob/AsyncRunJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_runjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; +import com.google.cloud.scheduler.v1.RunJobRequest; + +public class AsyncRunJob { + + public static void main(String[] args) throws Exception { + asyncRunJob(); + } + + public static void asyncRunJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + RunJobRequest request = + RunJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + ApiFuture future = cloudSchedulerClient.runJobCallable().futureCall(request); + // Do something. + Job response = future.get(); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_runjob_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/runjob/SyncRunJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/runjob/SyncRunJob.java new file mode 100644 index 00000000..01b89f64 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/runjob/SyncRunJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_runjob_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; +import com.google.cloud.scheduler.v1.RunJobRequest; + +public class SyncRunJob { + + public static void main(String[] args) throws Exception { + syncRunJob(); + } + + public static void syncRunJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + RunJobRequest request = + RunJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + Job response = cloudSchedulerClient.runJob(request); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_runjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/runjob/SyncRunJobJobname.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/runjob/SyncRunJobJobname.java new file mode 100644 index 00000000..04d06d48 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/runjob/SyncRunJobJobname.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_runjob_jobname_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; + +public class SyncRunJobJobname { + + public static void main(String[] args) throws Exception { + syncRunJobJobname(); + } + + public static void syncRunJobJobname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + Job response = cloudSchedulerClient.runJob(name); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_runjob_jobname_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/runjob/SyncRunJobString.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/runjob/SyncRunJobString.java new file mode 100644 index 00000000..19f2a4df --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/runjob/SyncRunJobString.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_runjob_string_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.JobName; + +public class SyncRunJobString { + + public static void main(String[] args) throws Exception { + syncRunJobString(); + } + + public static void syncRunJobString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); + Job response = cloudSchedulerClient.runJob(name); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_runjob_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/updatejob/AsyncUpdateJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/updatejob/AsyncUpdateJob.java new file mode 100644 index 00000000..22d735bf --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/updatejob/AsyncUpdateJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_updatejob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.UpdateJobRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateJob { + + public static void main(String[] args) throws Exception { + asyncUpdateJob(); + } + + public static void asyncUpdateJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + UpdateJobRequest request = + UpdateJobRequest.newBuilder() + .setJob(Job.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = cloudSchedulerClient.updateJobCallable().futureCall(request); + // Do something. + Job response = future.get(); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_updatejob_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/updatejob/SyncUpdateJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/updatejob/SyncUpdateJob.java new file mode 100644 index 00000000..a8c9484e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/updatejob/SyncUpdateJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_updatejob_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.cloud.scheduler.v1.UpdateJobRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateJob { + + public static void main(String[] args) throws Exception { + syncUpdateJob(); + } + + public static void syncUpdateJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + UpdateJobRequest request = + UpdateJobRequest.newBuilder() + .setJob(Job.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Job response = cloudSchedulerClient.updateJob(request); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_updatejob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/updatejob/SyncUpdateJobJobFieldmask.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/updatejob/SyncUpdateJobJobFieldmask.java new file mode 100644 index 00000000..f84b4663 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulerclient/updatejob/SyncUpdateJobJobFieldmask.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulerclient_updatejob_jobfieldmask_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1.Job; +import com.google.protobuf.FieldMask; + +public class SyncUpdateJobJobFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateJobJobFieldmask(); + } + + public static void syncUpdateJobJobFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + Job job = Job.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Job response = cloudSchedulerClient.updateJob(job, updateMask); + } + } +} +// [END scheduler_v1_generated_cloudschedulerclient_updatejob_jobfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulersettings/getjob/SyncGetJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulersettings/getjob/SyncGetJob.java new file mode 100644 index 00000000..ee4ff1f1 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/cloudschedulersettings/getjob/SyncGetJob.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.scheduler.v1.samples; + +// [START scheduler_v1_generated_cloudschedulersettings_getjob_sync] +import com.google.cloud.scheduler.v1.CloudSchedulerSettings; +import java.time.Duration; + +public class SyncGetJob { + + public static void main(String[] args) throws Exception { + syncGetJob(); + } + + public static void syncGetJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CloudSchedulerSettings.Builder cloudSchedulerSettingsBuilder = + CloudSchedulerSettings.newBuilder(); + cloudSchedulerSettingsBuilder + .getJobSettings() + .setRetrySettings( + cloudSchedulerSettingsBuilder + .getJobSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CloudSchedulerSettings cloudSchedulerSettings = cloudSchedulerSettingsBuilder.build(); + } +} +// [END scheduler_v1_generated_cloudschedulersettings_getjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1/stub/cloudschedulerstubsettings/getjob/SyncGetJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1/stub/cloudschedulerstubsettings/getjob/SyncGetJob.java new file mode 100644 index 00000000..7a3b7e18 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1/stub/cloudschedulerstubsettings/getjob/SyncGetJob.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.scheduler.v1.stub.samples; + +// [START scheduler_v1_generated_cloudschedulerstubsettings_getjob_sync] +import com.google.cloud.scheduler.v1.stub.CloudSchedulerStubSettings; +import java.time.Duration; + +public class SyncGetJob { + + public static void main(String[] args) throws Exception { + syncGetJob(); + } + + public static void syncGetJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CloudSchedulerStubSettings.Builder cloudSchedulerSettingsBuilder = + CloudSchedulerStubSettings.newBuilder(); + cloudSchedulerSettingsBuilder + .getJobSettings() + .setRetrySettings( + cloudSchedulerSettingsBuilder + .getJobSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CloudSchedulerStubSettings cloudSchedulerSettings = cloudSchedulerSettingsBuilder.build(); + } +} +// [END scheduler_v1_generated_cloudschedulerstubsettings_getjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/create/SyncCreateSetCredentialsProvider.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/create/SyncCreateSetCredentialsProvider.java new file mode 100644 index 00000000..2d2f4bd0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/create/SyncCreateSetCredentialsProvider.java @@ -0,0 +1,41 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_create_setcredentialsprovider_sync] +import com.google.api.gax.core.FixedCredentialsProvider; +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.CloudSchedulerSettings; +import com.google.cloud.scheduler.v1beta1.myCredentials; + +public class SyncCreateSetCredentialsProvider { + + public static void main(String[] args) throws Exception { + syncCreateSetCredentialsProvider(); + } + + public static void syncCreateSetCredentialsProvider() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CloudSchedulerSettings cloudSchedulerSettings = + CloudSchedulerSettings.newBuilder() + .setCredentialsProvider(FixedCredentialsProvider.create(myCredentials)) + .build(); + CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings); + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_create_setcredentialsprovider_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/create/SyncCreateSetCredentialsProvider1.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/create/SyncCreateSetCredentialsProvider1.java new file mode 100644 index 00000000..57a5e157 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/create/SyncCreateSetCredentialsProvider1.java @@ -0,0 +1,40 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_create_setcredentialsprovider1_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.CloudSchedulerSettings; + +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. + CloudSchedulerSettings cloudSchedulerSettings = + CloudSchedulerSettings.newBuilder() + .setTransportChannelProvider( + CloudSchedulerSettings.defaultHttpJsonTransportProviderBuilder().build()) + .build(); + CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings); + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_create_setcredentialsprovider1_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/create/SyncCreateSetEndpoint.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/create/SyncCreateSetEndpoint.java new file mode 100644 index 00000000..2d9d001d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/create/SyncCreateSetEndpoint.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_create_setendpoint_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.CloudSchedulerSettings; +import com.google.cloud.scheduler.v1beta1.myEndpoint; + +public class SyncCreateSetEndpoint { + + public static void main(String[] args) throws Exception { + syncCreateSetEndpoint(); + } + + public static void syncCreateSetEndpoint() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CloudSchedulerSettings cloudSchedulerSettings = + CloudSchedulerSettings.newBuilder().setEndpoint(myEndpoint).build(); + CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create(cloudSchedulerSettings); + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_create_setendpoint_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/createjob/AsyncCreateJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/createjob/AsyncCreateJob.java new file mode 100644 index 00000000..6ff39df6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/createjob/AsyncCreateJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_createjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.CreateJobRequest; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.LocationName; + +public class AsyncCreateJob { + + public static void main(String[] args) throws Exception { + asyncCreateJob(); + } + + public static void asyncCreateJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + CreateJobRequest request = + CreateJobRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setJob(Job.newBuilder().build()) + .build(); + ApiFuture future = cloudSchedulerClient.createJobCallable().futureCall(request); + // Do something. + Job response = future.get(); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_createjob_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/createjob/SyncCreateJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/createjob/SyncCreateJob.java new file mode 100644 index 00000000..de761e19 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/createjob/SyncCreateJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_createjob_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.CreateJobRequest; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.LocationName; + +public class SyncCreateJob { + + public static void main(String[] args) throws Exception { + syncCreateJob(); + } + + public static void syncCreateJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + CreateJobRequest request = + CreateJobRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setJob(Job.newBuilder().build()) + .build(); + Job response = cloudSchedulerClient.createJob(request); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_createjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/createjob/SyncCreateJobLocationnameJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/createjob/SyncCreateJobLocationnameJob.java new file mode 100644 index 00000000..dd28bfa0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/createjob/SyncCreateJobLocationnameJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_createjob_locationnamejob_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.LocationName; + +public class SyncCreateJobLocationnameJob { + + public static void main(String[] args) throws Exception { + syncCreateJobLocationnameJob(); + } + + public static void syncCreateJobLocationnameJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + Job job = Job.newBuilder().build(); + Job response = cloudSchedulerClient.createJob(parent, job); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_createjob_locationnamejob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/createjob/SyncCreateJobStringJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/createjob/SyncCreateJobStringJob.java new file mode 100644 index 00000000..06e80608 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/createjob/SyncCreateJobStringJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_createjob_stringjob_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.LocationName; + +public class SyncCreateJobStringJob { + + public static void main(String[] args) throws Exception { + syncCreateJobStringJob(); + } + + public static void syncCreateJobStringJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + Job job = Job.newBuilder().build(); + Job response = cloudSchedulerClient.createJob(parent, job); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_createjob_stringjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/deletejob/AsyncDeleteJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/deletejob/AsyncDeleteJob.java new file mode 100644 index 00000000..a524acfc --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/deletejob/AsyncDeleteJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_deletejob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.DeleteJobRequest; +import com.google.cloud.scheduler.v1beta1.JobName; +import com.google.protobuf.Empty; + +public class AsyncDeleteJob { + + public static void main(String[] args) throws Exception { + asyncDeleteJob(); + } + + public static void asyncDeleteJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + DeleteJobRequest request = + DeleteJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + ApiFuture future = cloudSchedulerClient.deleteJobCallable().futureCall(request); + // Do something. + future.get(); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_deletejob_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/deletejob/SyncDeleteJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/deletejob/SyncDeleteJob.java new file mode 100644 index 00000000..1faee972 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/deletejob/SyncDeleteJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_deletejob_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.DeleteJobRequest; +import com.google.cloud.scheduler.v1beta1.JobName; + +public class SyncDeleteJob { + + public static void main(String[] args) throws Exception { + syncDeleteJob(); + } + + public static void syncDeleteJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + DeleteJobRequest request = + DeleteJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + cloudSchedulerClient.deleteJob(request); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_deletejob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/deletejob/SyncDeleteJobJobname.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/deletejob/SyncDeleteJobJobname.java new file mode 100644 index 00000000..2503b646 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/deletejob/SyncDeleteJobJobname.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_deletejob_jobname_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.JobName; + +public class SyncDeleteJobJobname { + + public static void main(String[] args) throws Exception { + syncDeleteJobJobname(); + } + + public static void syncDeleteJobJobname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + cloudSchedulerClient.deleteJob(name); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_deletejob_jobname_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/deletejob/SyncDeleteJobString.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/deletejob/SyncDeleteJobString.java new file mode 100644 index 00000000..bfa1952a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/deletejob/SyncDeleteJobString.java @@ -0,0 +1,38 @@ +/* + * Copyright 2022 Google LLC + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.google.cloud.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_deletejob_string_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.JobName; + +public class SyncDeleteJobString { + + public static void main(String[] args) throws Exception { + syncDeleteJobString(); + } + + public static void syncDeleteJobString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); + cloudSchedulerClient.deleteJob(name); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_deletejob_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/getjob/AsyncGetJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/getjob/AsyncGetJob.java new file mode 100644 index 00000000..9444ca00 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/getjob/AsyncGetJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_getjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.GetJobRequest; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; + +public class AsyncGetJob { + + public static void main(String[] args) throws Exception { + asyncGetJob(); + } + + public static void asyncGetJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + GetJobRequest request = + GetJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + ApiFuture future = cloudSchedulerClient.getJobCallable().futureCall(request); + // Do something. + Job response = future.get(); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_getjob_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/getjob/SyncGetJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/getjob/SyncGetJob.java new file mode 100644 index 00000000..036ffd35 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/getjob/SyncGetJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_getjob_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.GetJobRequest; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; + +public class SyncGetJob { + + public static void main(String[] args) throws Exception { + syncGetJob(); + } + + public static void syncGetJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + GetJobRequest request = + GetJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + Job response = cloudSchedulerClient.getJob(request); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_getjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/getjob/SyncGetJobJobname.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/getjob/SyncGetJobJobname.java new file mode 100644 index 00000000..0769975f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/getjob/SyncGetJobJobname.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_getjob_jobname_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; + +public class SyncGetJobJobname { + + public static void main(String[] args) throws Exception { + syncGetJobJobname(); + } + + public static void syncGetJobJobname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + Job response = cloudSchedulerClient.getJob(name); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_getjob_jobname_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/getjob/SyncGetJobString.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/getjob/SyncGetJobString.java new file mode 100644 index 00000000..67b2e02a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/getjob/SyncGetJobString.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_getjob_string_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; + +public class SyncGetJobString { + + public static void main(String[] args) throws Exception { + syncGetJobString(); + } + + public static void syncGetJobString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); + Job response = cloudSchedulerClient.getJob(name); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_getjob_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/AsyncListJobs.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/AsyncListJobs.java new file mode 100644 index 00000000..70baf341 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/AsyncListJobs.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_listjobs_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.ListJobsRequest; +import com.google.cloud.scheduler.v1beta1.LocationName; + +public class AsyncListJobs { + + public static void main(String[] args) throws Exception { + asyncListJobs(); + } + + public static void asyncListJobs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + ListJobsRequest request = + ListJobsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + ApiFuture future = cloudSchedulerClient.listJobsPagedCallable().futureCall(request); + // Do something. + for (Job element : future.get().iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_listjobs_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/AsyncListJobsPaged.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/AsyncListJobsPaged.java new file mode 100644 index 00000000..cdb253e0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/AsyncListJobsPaged.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_listjobs_paged_async] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.ListJobsRequest; +import com.google.cloud.scheduler.v1beta1.ListJobsResponse; +import com.google.cloud.scheduler.v1beta1.LocationName; +import com.google.common.base.Strings; + +public class AsyncListJobsPaged { + + public static void main(String[] args) throws Exception { + asyncListJobsPaged(); + } + + public static void asyncListJobsPaged() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + ListJobsRequest request = + ListJobsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + while (true) { + ListJobsResponse response = cloudSchedulerClient.listJobsCallable().call(request); + for (Job element : response.getJobsList()) { + // doThingsWith(element); + } + String nextPageToken = response.getNextPageToken(); + if (!Strings.isNullOrEmpty(nextPageToken)) { + request = request.toBuilder().setPageToken(nextPageToken).build(); + } else { + break; + } + } + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_listjobs_paged_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/SyncListJobs.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/SyncListJobs.java new file mode 100644 index 00000000..7869a56a --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/SyncListJobs.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_listjobs_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.ListJobsRequest; +import com.google.cloud.scheduler.v1beta1.LocationName; + +public class SyncListJobs { + + public static void main(String[] args) throws Exception { + syncListJobs(); + } + + public static void syncListJobs() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + ListJobsRequest request = + ListJobsRequest.newBuilder() + .setParent(LocationName.of("[PROJECT]", "[LOCATION]").toString()) + .setPageSize(883849137) + .setPageToken("pageToken873572522") + .build(); + for (Job element : cloudSchedulerClient.listJobs(request).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_listjobs_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/SyncListJobsLocationname.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/SyncListJobsLocationname.java new file mode 100644 index 00000000..585ba77c --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/SyncListJobsLocationname.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_listjobs_locationname_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.LocationName; + +public class SyncListJobsLocationname { + + public static void main(String[] args) throws Exception { + syncListJobsLocationname(); + } + + public static void syncListJobsLocationname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + LocationName parent = LocationName.of("[PROJECT]", "[LOCATION]"); + for (Job element : cloudSchedulerClient.listJobs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_listjobs_locationname_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/SyncListJobsString.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/SyncListJobsString.java new file mode 100644 index 00000000..0de2f5f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/listjobs/SyncListJobsString.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_listjobs_string_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.LocationName; + +public class SyncListJobsString { + + public static void main(String[] args) throws Exception { + syncListJobsString(); + } + + public static void syncListJobsString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + String parent = LocationName.of("[PROJECT]", "[LOCATION]").toString(); + for (Job element : cloudSchedulerClient.listJobs(parent).iterateAll()) { + // doThingsWith(element); + } + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_listjobs_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/pausejob/AsyncPauseJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/pausejob/AsyncPauseJob.java new file mode 100644 index 00000000..f9ef47f0 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/pausejob/AsyncPauseJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_pausejob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; +import com.google.cloud.scheduler.v1beta1.PauseJobRequest; + +public class AsyncPauseJob { + + public static void main(String[] args) throws Exception { + asyncPauseJob(); + } + + public static void asyncPauseJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + PauseJobRequest request = + PauseJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + ApiFuture future = cloudSchedulerClient.pauseJobCallable().futureCall(request); + // Do something. + Job response = future.get(); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_pausejob_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/pausejob/SyncPauseJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/pausejob/SyncPauseJob.java new file mode 100644 index 00000000..47d90b01 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/pausejob/SyncPauseJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_pausejob_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; +import com.google.cloud.scheduler.v1beta1.PauseJobRequest; + +public class SyncPauseJob { + + public static void main(String[] args) throws Exception { + syncPauseJob(); + } + + public static void syncPauseJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + PauseJobRequest request = + PauseJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + Job response = cloudSchedulerClient.pauseJob(request); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_pausejob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/pausejob/SyncPauseJobJobname.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/pausejob/SyncPauseJobJobname.java new file mode 100644 index 00000000..23c41e7e --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/pausejob/SyncPauseJobJobname.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_pausejob_jobname_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; + +public class SyncPauseJobJobname { + + public static void main(String[] args) throws Exception { + syncPauseJobJobname(); + } + + public static void syncPauseJobJobname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + Job response = cloudSchedulerClient.pauseJob(name); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_pausejob_jobname_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/pausejob/SyncPauseJobString.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/pausejob/SyncPauseJobString.java new file mode 100644 index 00000000..57e4896f --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/pausejob/SyncPauseJobString.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_pausejob_string_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; + +public class SyncPauseJobString { + + public static void main(String[] args) throws Exception { + syncPauseJobString(); + } + + public static void syncPauseJobString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); + Job response = cloudSchedulerClient.pauseJob(name); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_pausejob_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/resumejob/AsyncResumeJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/resumejob/AsyncResumeJob.java new file mode 100644 index 00000000..2665117d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/resumejob/AsyncResumeJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_resumejob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; +import com.google.cloud.scheduler.v1beta1.ResumeJobRequest; + +public class AsyncResumeJob { + + public static void main(String[] args) throws Exception { + asyncResumeJob(); + } + + public static void asyncResumeJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + ResumeJobRequest request = + ResumeJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + ApiFuture future = cloudSchedulerClient.resumeJobCallable().futureCall(request); + // Do something. + Job response = future.get(); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_resumejob_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/resumejob/SyncResumeJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/resumejob/SyncResumeJob.java new file mode 100644 index 00000000..e9bcf78d --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/resumejob/SyncResumeJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_resumejob_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; +import com.google.cloud.scheduler.v1beta1.ResumeJobRequest; + +public class SyncResumeJob { + + public static void main(String[] args) throws Exception { + syncResumeJob(); + } + + public static void syncResumeJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + ResumeJobRequest request = + ResumeJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + Job response = cloudSchedulerClient.resumeJob(request); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_resumejob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/resumejob/SyncResumeJobJobname.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/resumejob/SyncResumeJobJobname.java new file mode 100644 index 00000000..5f047635 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/resumejob/SyncResumeJobJobname.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_resumejob_jobname_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; + +public class SyncResumeJobJobname { + + public static void main(String[] args) throws Exception { + syncResumeJobJobname(); + } + + public static void syncResumeJobJobname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + Job response = cloudSchedulerClient.resumeJob(name); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_resumejob_jobname_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/resumejob/SyncResumeJobString.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/resumejob/SyncResumeJobString.java new file mode 100644 index 00000000..cb009861 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/resumejob/SyncResumeJobString.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_resumejob_string_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; + +public class SyncResumeJobString { + + public static void main(String[] args) throws Exception { + syncResumeJobString(); + } + + public static void syncResumeJobString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); + Job response = cloudSchedulerClient.resumeJob(name); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_resumejob_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/runjob/AsyncRunJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/runjob/AsyncRunJob.java new file mode 100644 index 00000000..19ce12c6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/runjob/AsyncRunJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_runjob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; +import com.google.cloud.scheduler.v1beta1.RunJobRequest; + +public class AsyncRunJob { + + public static void main(String[] args) throws Exception { + asyncRunJob(); + } + + public static void asyncRunJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + RunJobRequest request = + RunJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + ApiFuture future = cloudSchedulerClient.runJobCallable().futureCall(request); + // Do something. + Job response = future.get(); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_runjob_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/runjob/SyncRunJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/runjob/SyncRunJob.java new file mode 100644 index 00000000..3a9959fe --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/runjob/SyncRunJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_runjob_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; +import com.google.cloud.scheduler.v1beta1.RunJobRequest; + +public class SyncRunJob { + + public static void main(String[] args) throws Exception { + syncRunJob(); + } + + public static void syncRunJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + RunJobRequest request = + RunJobRequest.newBuilder() + .setName(JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString()) + .build(); + Job response = cloudSchedulerClient.runJob(request); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_runjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/runjob/SyncRunJobJobname.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/runjob/SyncRunJobJobname.java new file mode 100644 index 00000000..bcaed621 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/runjob/SyncRunJobJobname.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_runjob_jobname_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; + +public class SyncRunJobJobname { + + public static void main(String[] args) throws Exception { + syncRunJobJobname(); + } + + public static void syncRunJobJobname() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + JobName name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]"); + Job response = cloudSchedulerClient.runJob(name); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_runjob_jobname_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/runjob/SyncRunJobString.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/runjob/SyncRunJobString.java new file mode 100644 index 00000000..fbbe6631 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/runjob/SyncRunJobString.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_runjob_string_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.JobName; + +public class SyncRunJobString { + + public static void main(String[] args) throws Exception { + syncRunJobString(); + } + + public static void syncRunJobString() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + String name = JobName.of("[PROJECT]", "[LOCATION]", "[JOB]").toString(); + Job response = cloudSchedulerClient.runJob(name); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_runjob_string_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/updatejob/AsyncUpdateJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/updatejob/AsyncUpdateJob.java new file mode 100644 index 00000000..6f9c4c14 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/updatejob/AsyncUpdateJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_updatejob_async] +import com.google.api.core.ApiFuture; +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.UpdateJobRequest; +import com.google.protobuf.FieldMask; + +public class AsyncUpdateJob { + + public static void main(String[] args) throws Exception { + asyncUpdateJob(); + } + + public static void asyncUpdateJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + UpdateJobRequest request = + UpdateJobRequest.newBuilder() + .setJob(Job.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + ApiFuture future = cloudSchedulerClient.updateJobCallable().futureCall(request); + // Do something. + Job response = future.get(); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_updatejob_async] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/updatejob/SyncUpdateJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/updatejob/SyncUpdateJob.java new file mode 100644 index 00000000..fd3aeefd --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/updatejob/SyncUpdateJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_updatejob_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.cloud.scheduler.v1beta1.UpdateJobRequest; +import com.google.protobuf.FieldMask; + +public class SyncUpdateJob { + + public static void main(String[] args) throws Exception { + syncUpdateJob(); + } + + public static void syncUpdateJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + UpdateJobRequest request = + UpdateJobRequest.newBuilder() + .setJob(Job.newBuilder().build()) + .setUpdateMask(FieldMask.newBuilder().build()) + .build(); + Job response = cloudSchedulerClient.updateJob(request); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_updatejob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/updatejob/SyncUpdateJobJobFieldmask.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/updatejob/SyncUpdateJobJobFieldmask.java new file mode 100644 index 00000000..f86e5594 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulerclient/updatejob/SyncUpdateJobJobFieldmask.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerclient_updatejob_jobfieldmask_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerClient; +import com.google.cloud.scheduler.v1beta1.Job; +import com.google.protobuf.FieldMask; + +public class SyncUpdateJobJobFieldmask { + + public static void main(String[] args) throws Exception { + syncUpdateJobJobFieldmask(); + } + + public static void syncUpdateJobJobFieldmask() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + try (CloudSchedulerClient cloudSchedulerClient = CloudSchedulerClient.create()) { + Job job = Job.newBuilder().build(); + FieldMask updateMask = FieldMask.newBuilder().build(); + Job response = cloudSchedulerClient.updateJob(job, updateMask); + } + } +} +// [END scheduler_v1beta1_generated_cloudschedulerclient_updatejob_jobfieldmask_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulersettings/getjob/SyncGetJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulersettings/getjob/SyncGetJob.java new file mode 100644 index 00000000..f3efe758 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/cloudschedulersettings/getjob/SyncGetJob.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.scheduler.v1beta1.samples; + +// [START scheduler_v1beta1_generated_cloudschedulersettings_getjob_sync] +import com.google.cloud.scheduler.v1beta1.CloudSchedulerSettings; +import java.time.Duration; + +public class SyncGetJob { + + public static void main(String[] args) throws Exception { + syncGetJob(); + } + + public static void syncGetJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CloudSchedulerSettings.Builder cloudSchedulerSettingsBuilder = + CloudSchedulerSettings.newBuilder(); + cloudSchedulerSettingsBuilder + .getJobSettings() + .setRetrySettings( + cloudSchedulerSettingsBuilder + .getJobSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CloudSchedulerSettings cloudSchedulerSettings = cloudSchedulerSettingsBuilder.build(); + } +} +// [END scheduler_v1beta1_generated_cloudschedulersettings_getjob_sync] diff --git a/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/stub/cloudschedulerstubsettings/getjob/SyncGetJob.java b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/stub/cloudschedulerstubsettings/getjob/SyncGetJob.java new file mode 100644 index 00000000..7303e1a6 --- /dev/null +++ b/samples/snippets/generated/com/google/cloud/scheduler/v1beta1/stub/cloudschedulerstubsettings/getjob/SyncGetJob.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.scheduler.v1beta1.stub.samples; + +// [START scheduler_v1beta1_generated_cloudschedulerstubsettings_getjob_sync] +import com.google.cloud.scheduler.v1beta1.stub.CloudSchedulerStubSettings; +import java.time.Duration; + +public class SyncGetJob { + + public static void main(String[] args) throws Exception { + syncGetJob(); + } + + public static void syncGetJob() throws Exception { + // This snippet has been automatically generated for illustrative purposes only. + // It may require modifications to work in your environment. + CloudSchedulerStubSettings.Builder cloudSchedulerSettingsBuilder = + CloudSchedulerStubSettings.newBuilder(); + cloudSchedulerSettingsBuilder + .getJobSettings() + .setRetrySettings( + cloudSchedulerSettingsBuilder + .getJobSettings() + .getRetrySettings() + .toBuilder() + .setTotalTimeout(Duration.ofSeconds(30)) + .build()); + CloudSchedulerStubSettings cloudSchedulerSettings = cloudSchedulerSettingsBuilder.build(); + } +} +// [END scheduler_v1beta1_generated_cloudschedulerstubsettings_getjob_sync] diff --git a/samples/snippets/pom.xml b/samples/snippets/pom.xml index 7b49dbd8..3ad1061d 100644 --- a/samples/snippets/pom.xml +++ b/samples/snippets/pom.xml @@ -30,7 +30,7 @@ com.google.cloud libraries-bom - 25.3.0 + 25.4.0 pom import diff --git a/versions.txt b/versions.txt index 50a710d0..5cbc0457 100644 --- a/versions.txt +++ b/versions.txt @@ -1,8 +1,8 @@ # Format: # module:released-version:current-version -google-cloud-scheduler:2.2.0:2.2.0 -grpc-google-cloud-scheduler-v1beta1:0.87.0:0.87.0 -grpc-google-cloud-scheduler-v1:2.2.0:2.2.0 -proto-google-cloud-scheduler-v1beta1:0.87.0:0.87.0 -proto-google-cloud-scheduler-v1:2.2.0:2.2.0 +google-cloud-scheduler:2.3.0:2.3.0 +grpc-google-cloud-scheduler-v1beta1:0.88.0:0.88.0 +grpc-google-cloud-scheduler-v1:2.3.0:2.3.0 +proto-google-cloud-scheduler-v1beta1:0.88.0:0.88.0 +proto-google-cloud-scheduler-v1:2.3.0:2.3.0