google-cloud-scheduler 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/google/cloud/scheduler.rb +3 -3
- data/lib/google/cloud/scheduler/v1.rb +139 -0
- data/lib/google/cloud/scheduler/v1/cloud_scheduler_client.rb +612 -0
- data/lib/google/cloud/scheduler/v1/cloud_scheduler_client_config.json +66 -0
- data/lib/google/cloud/scheduler/v1/cloudscheduler_pb.rb +62 -0
- data/lib/google/cloud/scheduler/v1/cloudscheduler_services_pb.rb +84 -0
- data/lib/google/cloud/scheduler/v1/credentials.rb +41 -0
- data/lib/google/cloud/scheduler/v1/doc/google/cloud/scheduler/v1/cloudscheduler.rb +142 -0
- data/lib/google/cloud/scheduler/v1/doc/google/cloud/scheduler/v1/job.rb +207 -0
- data/lib/google/cloud/scheduler/v1/doc/google/cloud/scheduler/v1/target.rb +286 -0
- data/lib/google/cloud/scheduler/v1/doc/google/protobuf/any.rb +130 -0
- data/lib/google/cloud/scheduler/v1/doc/google/protobuf/duration.rb +91 -0
- data/lib/google/cloud/scheduler/v1/doc/google/protobuf/empty.rb +29 -0
- data/lib/google/cloud/scheduler/v1/doc/google/protobuf/field_mask.rb +230 -0
- data/lib/google/cloud/scheduler/v1/doc/google/protobuf/timestamp.rb +109 -0
- data/lib/google/cloud/scheduler/v1/doc/google/rpc/status.rb +87 -0
- data/lib/google/cloud/scheduler/v1/helpers.rb +48 -0
- data/lib/google/cloud/scheduler/v1/job_pb.rb +56 -0
- data/lib/google/cloud/scheduler/v1/target_pb.rb +58 -0
- data/lib/google/cloud/scheduler/v1beta1.rb +1 -1
- data/lib/google/cloud/scheduler/v1beta1/cloud_scheduler_client.rb +28 -16
- data/lib/google/cloud/scheduler/v1beta1/cloudscheduler_services_pb.rb +23 -13
- data/lib/google/cloud/scheduler/v1beta1/credentials.rb +1 -1
- data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/cloudscheduler.rb +31 -18
- data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/job.rb +37 -25
- data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/target.rb +62 -42
- data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/any.rb +1 -1
- data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/duration.rb +1 -1
- data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/empty.rb +1 -1
- data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/field_mask.rb +1 -1
- data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/timestamp.rb +1 -1
- data/lib/google/cloud/scheduler/v1beta1/doc/google/rpc/status.rb +18 -15
- data/lib/google/cloud/scheduler/v1beta1/helpers.rb +7 -7
- metadata +23 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40535fd3bb0b1a972cac6044a10771898e7f700f0fa7a588e867e4e34cb655bc
|
4
|
+
data.tar.gz: 497ecf5db252daf856cb42a158aa44c5c3f8fa9dbea4b07fe3fb478bc955dd01
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: da833db8d170a82abe24c146619d99778509b8330a8e3df876274d2925bf0f8503dd14d520e4bac60b4c2c1801b803da4d46c19170ab0c0781b3dcaa27415ad3
|
7
|
+
data.tar.gz: d78330651185eb5631c05a66527f1ab4e0f0c6d2772f7fcb8fa3227f936d7b63319b3b0d9e2d74fe08795c426421d4e59330eb7818a61f3e3288925320997471
|
data/README.md
CHANGED
@@ -27,7 +27,7 @@ $ gem install google-cloud-scheduler
|
|
27
27
|
- View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
28
28
|
to see the full list of Cloud APIs that we cover.
|
29
29
|
|
30
|
-
[Client Library Documentation]: https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-scheduler/latest/google/cloud/scheduler/
|
30
|
+
[Client Library Documentation]: https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-scheduler/latest/google/cloud/scheduler/v1
|
31
31
|
[Product Documentation]: https://cloud.google.com/cloudscheduler
|
32
32
|
|
33
33
|
## Enabling Logging
|
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright
|
1
|
+
# Copyright 2019 Google LLC
|
2
2
|
#
|
3
3
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
4
|
# you may not use this file except in compliance with the License.
|
@@ -91,7 +91,7 @@ module Google
|
|
91
91
|
# schedule asynchronous jobs.
|
92
92
|
#
|
93
93
|
# @param version [Symbol, String]
|
94
|
-
# The major version of the service to be used. By default :
|
94
|
+
# The major version of the service to be used. By default :v1
|
95
95
|
# is used.
|
96
96
|
# @overload new(version:, credentials:, scopes:, client_config:, timeout:)
|
97
97
|
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
@@ -123,7 +123,7 @@ module Google
|
|
123
123
|
# @param exception_transformer [Proc]
|
124
124
|
# An optional proc that intercepts any exceptions raised during an API call to inject
|
125
125
|
# custom error handling.
|
126
|
-
def self.new(*args, version: :
|
126
|
+
def self.new(*args, version: :v1, **kwargs)
|
127
127
|
unless AVAILABLE_VERSIONS.include?(version.to_s.downcase)
|
128
128
|
raise "The version: #{version} is not available. The available versions " \
|
129
129
|
"are: [#{AVAILABLE_VERSIONS.join(", ")}]"
|
@@ -0,0 +1,139 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
|
15
|
+
|
16
|
+
require "google/cloud/scheduler/v1/cloud_scheduler_client"
|
17
|
+
require "google/cloud/scheduler/v1/helpers"
|
18
|
+
|
19
|
+
module Google
|
20
|
+
module Cloud
|
21
|
+
module Scheduler
|
22
|
+
# rubocop:disable LineLength
|
23
|
+
|
24
|
+
##
|
25
|
+
# # Ruby Client for Cloud Scheduler API ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
|
26
|
+
#
|
27
|
+
# [Cloud Scheduler API][Product Documentation]:
|
28
|
+
# Creates and manages jobs run on a regular recurring schedule.
|
29
|
+
# - [Product Documentation][]
|
30
|
+
#
|
31
|
+
# ## Quick Start
|
32
|
+
# In order to use this library, you first need to go through the following
|
33
|
+
# steps:
|
34
|
+
#
|
35
|
+
# 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
|
36
|
+
# 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
|
37
|
+
# 3. [Enable the Cloud Scheduler API.](https://console.cloud.google.com/apis/library/cloudscheduler.googleapis.com)
|
38
|
+
# 4. [Setup Authentication.](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud/master/guides/authentication)
|
39
|
+
#
|
40
|
+
# ### Installation
|
41
|
+
# ```
|
42
|
+
# $ gem install google-cloud-scheduler
|
43
|
+
# ```
|
44
|
+
#
|
45
|
+
# ### Next Steps
|
46
|
+
# - Read the [Cloud Scheduler API Product documentation][Product Documentation]
|
47
|
+
# to learn more about the product and see How-to Guides.
|
48
|
+
# - View this [repository's main README](https://github.com/googleapis/google-cloud-ruby/blob/master/README.md)
|
49
|
+
# to see the full list of Cloud APIs that we cover.
|
50
|
+
#
|
51
|
+
# [Product Documentation]: https://cloud.google.com/cloudscheduler
|
52
|
+
#
|
53
|
+
# ## Enabling Logging
|
54
|
+
#
|
55
|
+
# To enable logging for this library, set the logger for the underlying [gRPC](https://github.com/grpc/grpc/tree/master/src/ruby) library.
|
56
|
+
# The logger that you set may be a Ruby stdlib [`Logger`](https://ruby-doc.org/stdlib-2.5.0/libdoc/logger/rdoc/Logger.html) as shown below,
|
57
|
+
# or a [`Google::Cloud::Logging::Logger`](https://googleapis.github.io/google-cloud-ruby/#/docs/google-cloud-logging/latest/google/cloud/logging/logger)
|
58
|
+
# that will write logs to [Stackdriver Logging](https://cloud.google.com/logging/). See [grpc/logconfig.rb](https://github.com/grpc/grpc/blob/master/src/ruby/lib/grpc/logconfig.rb)
|
59
|
+
# and the gRPC [spec_helper.rb](https://github.com/grpc/grpc/blob/master/src/ruby/spec/spec_helper.rb) for additional information.
|
60
|
+
#
|
61
|
+
# Configuring a Ruby stdlib logger:
|
62
|
+
#
|
63
|
+
# ```ruby
|
64
|
+
# require "logger"
|
65
|
+
#
|
66
|
+
# module MyLogger
|
67
|
+
# LOGGER = Logger.new $stderr, level: Logger::WARN
|
68
|
+
# def logger
|
69
|
+
# LOGGER
|
70
|
+
# end
|
71
|
+
# end
|
72
|
+
#
|
73
|
+
# # Define a gRPC module-level logger method before grpc/logconfig.rb loads.
|
74
|
+
# module GRPC
|
75
|
+
# extend MyLogger
|
76
|
+
# end
|
77
|
+
# ```
|
78
|
+
#
|
79
|
+
module V1
|
80
|
+
# rubocop:enable LineLength
|
81
|
+
|
82
|
+
##
|
83
|
+
# The Cloud Scheduler API allows external entities to reliably
|
84
|
+
# schedule asynchronous jobs.
|
85
|
+
#
|
86
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
87
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
88
|
+
# be many types.
|
89
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
90
|
+
# authenticating requests made by this client.
|
91
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
92
|
+
# credentials for this client.
|
93
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
94
|
+
# credentials for this client.
|
95
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
96
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
97
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
98
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
99
|
+
# metadata for requests, generally, to give OAuth credentials.
|
100
|
+
# @param scopes [Array<String>]
|
101
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
102
|
+
# an updater_proc is supplied.
|
103
|
+
# @param client_config [Hash]
|
104
|
+
# A Hash for call options for each method. See
|
105
|
+
# Google::Gax#construct_settings for the structure of
|
106
|
+
# this data. Falls back to the default config if not specified
|
107
|
+
# or the specified config is missing data points.
|
108
|
+
# @param timeout [Numeric]
|
109
|
+
# The default timeout, in seconds, for calls made through this client.
|
110
|
+
# @param metadata [Hash]
|
111
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
112
|
+
# @param exception_transformer [Proc]
|
113
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
114
|
+
# custom error handling.
|
115
|
+
def self.new \
|
116
|
+
credentials: nil,
|
117
|
+
scopes: nil,
|
118
|
+
client_config: nil,
|
119
|
+
timeout: nil,
|
120
|
+
metadata: nil,
|
121
|
+
exception_transformer: nil,
|
122
|
+
lib_name: nil,
|
123
|
+
lib_version: nil
|
124
|
+
kwargs = {
|
125
|
+
credentials: credentials,
|
126
|
+
scopes: scopes,
|
127
|
+
client_config: client_config,
|
128
|
+
timeout: timeout,
|
129
|
+
metadata: metadata,
|
130
|
+
exception_transformer: exception_transformer,
|
131
|
+
lib_name: lib_name,
|
132
|
+
lib_version: lib_version
|
133
|
+
}.select { |_, v| v != nil }
|
134
|
+
Google::Cloud::Scheduler::V1::CloudSchedulerClient.new(**kwargs)
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -0,0 +1,612 @@
|
|
1
|
+
# Copyright 2019 Google LLC
|
2
|
+
#
|
3
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
4
|
+
# you may not use this file except in compliance with the License.
|
5
|
+
# You may obtain a copy of the License at
|
6
|
+
#
|
7
|
+
# https://www.apache.org/licenses/LICENSE-2.0
|
8
|
+
#
|
9
|
+
# Unless required by applicable law or agreed to in writing, software
|
10
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
11
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
12
|
+
# See the License for the specific language governing permissions and
|
13
|
+
# limitations under the License.
|
14
|
+
#
|
15
|
+
# EDITING INSTRUCTIONS
|
16
|
+
# This file was generated from the file
|
17
|
+
# https://github.com/googleapis/googleapis/blob/master/google/cloud/scheduler/v1/cloudscheduler.proto,
|
18
|
+
# and updates to that file get reflected here through a refresh process.
|
19
|
+
# For the short term, the refresh process will only be runnable by Google
|
20
|
+
# engineers.
|
21
|
+
|
22
|
+
|
23
|
+
require "json"
|
24
|
+
require "pathname"
|
25
|
+
|
26
|
+
require "google/gax"
|
27
|
+
|
28
|
+
require "google/cloud/scheduler/v1/cloudscheduler_pb"
|
29
|
+
require "google/cloud/scheduler/v1/credentials"
|
30
|
+
|
31
|
+
module Google
|
32
|
+
module Cloud
|
33
|
+
module Scheduler
|
34
|
+
module V1
|
35
|
+
# The Cloud Scheduler API allows external entities to reliably
|
36
|
+
# schedule asynchronous jobs.
|
37
|
+
#
|
38
|
+
# @!attribute [r] cloud_scheduler_stub
|
39
|
+
# @return [Google::Cloud::Scheduler::V1::CloudScheduler::Stub]
|
40
|
+
class CloudSchedulerClient
|
41
|
+
# @private
|
42
|
+
attr_reader :cloud_scheduler_stub
|
43
|
+
|
44
|
+
# The default address of the service.
|
45
|
+
SERVICE_ADDRESS = "cloudscheduler.googleapis.com".freeze
|
46
|
+
|
47
|
+
# The default port of the service.
|
48
|
+
DEFAULT_SERVICE_PORT = 443
|
49
|
+
|
50
|
+
# The default set of gRPC interceptors.
|
51
|
+
GRPC_INTERCEPTORS = []
|
52
|
+
|
53
|
+
DEFAULT_TIMEOUT = 30
|
54
|
+
|
55
|
+
PAGE_DESCRIPTORS = {
|
56
|
+
"list_jobs" => Google::Gax::PageDescriptor.new(
|
57
|
+
"page_token",
|
58
|
+
"next_page_token",
|
59
|
+
"jobs")
|
60
|
+
}.freeze
|
61
|
+
|
62
|
+
private_constant :PAGE_DESCRIPTORS
|
63
|
+
|
64
|
+
# The scopes needed to make gRPC calls to all of the methods defined in
|
65
|
+
# this service.
|
66
|
+
ALL_SCOPES = [
|
67
|
+
"https://www.googleapis.com/auth/cloud-platform"
|
68
|
+
].freeze
|
69
|
+
|
70
|
+
|
71
|
+
PROJECT_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
72
|
+
"projects/{project}"
|
73
|
+
)
|
74
|
+
|
75
|
+
private_constant :PROJECT_PATH_TEMPLATE
|
76
|
+
|
77
|
+
LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
78
|
+
"projects/{project}/locations/{location}"
|
79
|
+
)
|
80
|
+
|
81
|
+
private_constant :LOCATION_PATH_TEMPLATE
|
82
|
+
|
83
|
+
JOB_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
|
84
|
+
"projects/{project}/locations/{location}/jobs/{job}"
|
85
|
+
)
|
86
|
+
|
87
|
+
private_constant :JOB_PATH_TEMPLATE
|
88
|
+
|
89
|
+
# Returns a fully-qualified project resource name string.
|
90
|
+
# @param project [String]
|
91
|
+
# @return [String]
|
92
|
+
def self.project_path project
|
93
|
+
PROJECT_PATH_TEMPLATE.render(
|
94
|
+
:"project" => project
|
95
|
+
)
|
96
|
+
end
|
97
|
+
|
98
|
+
# Returns a fully-qualified location resource name string.
|
99
|
+
# @param project [String]
|
100
|
+
# @param location [String]
|
101
|
+
# @return [String]
|
102
|
+
def self.location_path project, location
|
103
|
+
LOCATION_PATH_TEMPLATE.render(
|
104
|
+
:"project" => project,
|
105
|
+
:"location" => location
|
106
|
+
)
|
107
|
+
end
|
108
|
+
|
109
|
+
# Returns a fully-qualified job resource name string.
|
110
|
+
# @param project [String]
|
111
|
+
# @param location [String]
|
112
|
+
# @param job [String]
|
113
|
+
# @return [String]
|
114
|
+
def self.job_path project, location, job
|
115
|
+
JOB_PATH_TEMPLATE.render(
|
116
|
+
:"project" => project,
|
117
|
+
:"location" => location,
|
118
|
+
:"job" => job
|
119
|
+
)
|
120
|
+
end
|
121
|
+
|
122
|
+
# @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
|
123
|
+
# Provides the means for authenticating requests made by the client. This parameter can
|
124
|
+
# be many types.
|
125
|
+
# A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
|
126
|
+
# authenticating requests made by this client.
|
127
|
+
# A `String` will be treated as the path to the keyfile to be used for the construction of
|
128
|
+
# credentials for this client.
|
129
|
+
# A `Hash` will be treated as the contents of a keyfile to be used for the construction of
|
130
|
+
# credentials for this client.
|
131
|
+
# A `GRPC::Core::Channel` will be used to make calls through.
|
132
|
+
# A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
|
133
|
+
# should already be composed with a `GRPC::Core::CallCredentials` object.
|
134
|
+
# A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
|
135
|
+
# metadata for requests, generally, to give OAuth credentials.
|
136
|
+
# @param scopes [Array<String>]
|
137
|
+
# The OAuth scopes for this service. This parameter is ignored if
|
138
|
+
# an updater_proc is supplied.
|
139
|
+
# @param client_config [Hash]
|
140
|
+
# A Hash for call options for each method. See
|
141
|
+
# Google::Gax#construct_settings for the structure of
|
142
|
+
# this data. Falls back to the default config if not specified
|
143
|
+
# or the specified config is missing data points.
|
144
|
+
# @param timeout [Numeric]
|
145
|
+
# The default timeout, in seconds, for calls made through this client.
|
146
|
+
# @param metadata [Hash]
|
147
|
+
# Default metadata to be sent with each request. This can be overridden on a per call basis.
|
148
|
+
# @param exception_transformer [Proc]
|
149
|
+
# An optional proc that intercepts any exceptions raised during an API call to inject
|
150
|
+
# custom error handling.
|
151
|
+
def initialize \
|
152
|
+
credentials: nil,
|
153
|
+
scopes: ALL_SCOPES,
|
154
|
+
client_config: {},
|
155
|
+
timeout: DEFAULT_TIMEOUT,
|
156
|
+
metadata: nil,
|
157
|
+
exception_transformer: nil,
|
158
|
+
lib_name: nil,
|
159
|
+
lib_version: ""
|
160
|
+
# These require statements are intentionally placed here to initialize
|
161
|
+
# the gRPC module only when it's required.
|
162
|
+
# See https://github.com/googleapis/toolkit/issues/446
|
163
|
+
require "google/gax/grpc"
|
164
|
+
require "google/cloud/scheduler/v1/cloudscheduler_services_pb"
|
165
|
+
|
166
|
+
credentials ||= Google::Cloud::Scheduler::V1::Credentials.default
|
167
|
+
|
168
|
+
if credentials.is_a?(String) || credentials.is_a?(Hash)
|
169
|
+
updater_proc = Google::Cloud::Scheduler::V1::Credentials.new(credentials).updater_proc
|
170
|
+
end
|
171
|
+
if credentials.is_a?(GRPC::Core::Channel)
|
172
|
+
channel = credentials
|
173
|
+
end
|
174
|
+
if credentials.is_a?(GRPC::Core::ChannelCredentials)
|
175
|
+
chan_creds = credentials
|
176
|
+
end
|
177
|
+
if credentials.is_a?(Proc)
|
178
|
+
updater_proc = credentials
|
179
|
+
end
|
180
|
+
if credentials.is_a?(Google::Auth::Credentials)
|
181
|
+
updater_proc = credentials.updater_proc
|
182
|
+
end
|
183
|
+
|
184
|
+
package_version = Gem.loaded_specs['google-cloud-scheduler'].version.version
|
185
|
+
|
186
|
+
google_api_client = "gl-ruby/#{RUBY_VERSION}"
|
187
|
+
google_api_client << " #{lib_name}/#{lib_version}" if lib_name
|
188
|
+
google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
|
189
|
+
google_api_client << " grpc/#{GRPC::VERSION}"
|
190
|
+
google_api_client.freeze
|
191
|
+
|
192
|
+
headers = { :"x-goog-api-client" => google_api_client }
|
193
|
+
headers.merge!(metadata) unless metadata.nil?
|
194
|
+
client_config_file = Pathname.new(__dir__).join(
|
195
|
+
"cloud_scheduler_client_config.json"
|
196
|
+
)
|
197
|
+
defaults = client_config_file.open do |f|
|
198
|
+
Google::Gax.construct_settings(
|
199
|
+
"google.cloud.scheduler.v1.CloudScheduler",
|
200
|
+
JSON.parse(f.read),
|
201
|
+
client_config,
|
202
|
+
Google::Gax::Grpc::STATUS_CODE_NAMES,
|
203
|
+
timeout,
|
204
|
+
page_descriptors: PAGE_DESCRIPTORS,
|
205
|
+
errors: Google::Gax::Grpc::API_ERRORS,
|
206
|
+
metadata: headers
|
207
|
+
)
|
208
|
+
end
|
209
|
+
|
210
|
+
# Allow overriding the service path/port in subclasses.
|
211
|
+
service_path = self.class::SERVICE_ADDRESS
|
212
|
+
port = self.class::DEFAULT_SERVICE_PORT
|
213
|
+
interceptors = self.class::GRPC_INTERCEPTORS
|
214
|
+
@cloud_scheduler_stub = Google::Gax::Grpc.create_stub(
|
215
|
+
service_path,
|
216
|
+
port,
|
217
|
+
chan_creds: chan_creds,
|
218
|
+
channel: channel,
|
219
|
+
updater_proc: updater_proc,
|
220
|
+
scopes: scopes,
|
221
|
+
interceptors: interceptors,
|
222
|
+
&Google::Cloud::Scheduler::V1::CloudScheduler::Stub.method(:new)
|
223
|
+
)
|
224
|
+
|
225
|
+
@list_jobs = Google::Gax.create_api_call(
|
226
|
+
@cloud_scheduler_stub.method(:list_jobs),
|
227
|
+
defaults["list_jobs"],
|
228
|
+
exception_transformer: exception_transformer
|
229
|
+
)
|
230
|
+
@get_job = Google::Gax.create_api_call(
|
231
|
+
@cloud_scheduler_stub.method(:get_job),
|
232
|
+
defaults["get_job"],
|
233
|
+
exception_transformer: exception_transformer
|
234
|
+
)
|
235
|
+
@create_job = Google::Gax.create_api_call(
|
236
|
+
@cloud_scheduler_stub.method(:create_job),
|
237
|
+
defaults["create_job"],
|
238
|
+
exception_transformer: exception_transformer
|
239
|
+
)
|
240
|
+
@update_job = Google::Gax.create_api_call(
|
241
|
+
@cloud_scheduler_stub.method(:update_job),
|
242
|
+
defaults["update_job"],
|
243
|
+
exception_transformer: exception_transformer
|
244
|
+
)
|
245
|
+
@delete_job = Google::Gax.create_api_call(
|
246
|
+
@cloud_scheduler_stub.method(:delete_job),
|
247
|
+
defaults["delete_job"],
|
248
|
+
exception_transformer: exception_transformer
|
249
|
+
)
|
250
|
+
@pause_job = Google::Gax.create_api_call(
|
251
|
+
@cloud_scheduler_stub.method(:pause_job),
|
252
|
+
defaults["pause_job"],
|
253
|
+
exception_transformer: exception_transformer
|
254
|
+
)
|
255
|
+
@resume_job = Google::Gax.create_api_call(
|
256
|
+
@cloud_scheduler_stub.method(:resume_job),
|
257
|
+
defaults["resume_job"],
|
258
|
+
exception_transformer: exception_transformer
|
259
|
+
)
|
260
|
+
@run_job = Google::Gax.create_api_call(
|
261
|
+
@cloud_scheduler_stub.method(:run_job),
|
262
|
+
defaults["run_job"],
|
263
|
+
exception_transformer: exception_transformer
|
264
|
+
)
|
265
|
+
end
|
266
|
+
|
267
|
+
# Service calls
|
268
|
+
|
269
|
+
# Lists jobs.
|
270
|
+
#
|
271
|
+
# @param parent [String]
|
272
|
+
# Required.
|
273
|
+
#
|
274
|
+
# The location name. For example:
|
275
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID`.
|
276
|
+
# @param page_size [Integer]
|
277
|
+
# The maximum number of resources contained in the underlying API
|
278
|
+
# response. If page streaming is performed per-resource, this
|
279
|
+
# parameter does not affect the return value. If page streaming is
|
280
|
+
# performed per-page, this determines the maximum number of
|
281
|
+
# resources in a page.
|
282
|
+
# @param options [Google::Gax::CallOptions]
|
283
|
+
# Overrides the default settings for this call, e.g, timeout,
|
284
|
+
# retries, etc.
|
285
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
286
|
+
# @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Scheduler::V1::Job>]
|
287
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
288
|
+
# @return [Google::Gax::PagedEnumerable<Google::Cloud::Scheduler::V1::Job>]
|
289
|
+
# An enumerable of Google::Cloud::Scheduler::V1::Job instances.
|
290
|
+
# See Google::Gax::PagedEnumerable documentation for other
|
291
|
+
# operations such as per-page iteration or access to the response
|
292
|
+
# object.
|
293
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
294
|
+
# @example
|
295
|
+
# require "google/cloud/scheduler"
|
296
|
+
#
|
297
|
+
# cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
|
298
|
+
# formatted_parent = Google::Cloud::Scheduler::V1::CloudSchedulerClient.location_path("[PROJECT]", "[LOCATION]")
|
299
|
+
#
|
300
|
+
# # Iterate over all results.
|
301
|
+
# cloud_scheduler_client.list_jobs(formatted_parent).each do |element|
|
302
|
+
# # Process element.
|
303
|
+
# end
|
304
|
+
#
|
305
|
+
# # Or iterate over results one page at a time.
|
306
|
+
# cloud_scheduler_client.list_jobs(formatted_parent).each_page do |page|
|
307
|
+
# # Process each page at a time.
|
308
|
+
# page.each do |element|
|
309
|
+
# # Process element.
|
310
|
+
# end
|
311
|
+
# end
|
312
|
+
|
313
|
+
def list_jobs \
|
314
|
+
parent,
|
315
|
+
page_size: nil,
|
316
|
+
options: nil,
|
317
|
+
&block
|
318
|
+
req = {
|
319
|
+
parent: parent,
|
320
|
+
page_size: page_size
|
321
|
+
}.delete_if { |_, v| v.nil? }
|
322
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::ListJobsRequest)
|
323
|
+
@list_jobs.call(req, options, &block)
|
324
|
+
end
|
325
|
+
|
326
|
+
# Gets a job.
|
327
|
+
#
|
328
|
+
# @param name [String]
|
329
|
+
# Required.
|
330
|
+
#
|
331
|
+
# The job name. For example:
|
332
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
|
333
|
+
# @param options [Google::Gax::CallOptions]
|
334
|
+
# Overrides the default settings for this call, e.g, timeout,
|
335
|
+
# retries, etc.
|
336
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
337
|
+
# @yieldparam result [Google::Cloud::Scheduler::V1::Job]
|
338
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
339
|
+
# @return [Google::Cloud::Scheduler::V1::Job]
|
340
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
341
|
+
# @example
|
342
|
+
# require "google/cloud/scheduler"
|
343
|
+
#
|
344
|
+
# cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
|
345
|
+
# formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
|
346
|
+
# response = cloud_scheduler_client.get_job(formatted_name)
|
347
|
+
|
348
|
+
def get_job \
|
349
|
+
name,
|
350
|
+
options: nil,
|
351
|
+
&block
|
352
|
+
req = {
|
353
|
+
name: name
|
354
|
+
}.delete_if { |_, v| v.nil? }
|
355
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::GetJobRequest)
|
356
|
+
@get_job.call(req, options, &block)
|
357
|
+
end
|
358
|
+
|
359
|
+
# Creates a job.
|
360
|
+
#
|
361
|
+
# @param parent [String]
|
362
|
+
# Required.
|
363
|
+
#
|
364
|
+
# The location name. For example:
|
365
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID`.
|
366
|
+
# @param job [Google::Cloud::Scheduler::V1::Job | Hash]
|
367
|
+
# Required.
|
368
|
+
#
|
369
|
+
# The job to add. The user can optionally specify a name for the
|
370
|
+
# job in {Google::Cloud::Scheduler::V1::Job#name name}. {Google::Cloud::Scheduler::V1::Job#name name} cannot be the same as an
|
371
|
+
# existing job. If a name is not specified then the system will
|
372
|
+
# generate a random unique name that will be returned
|
373
|
+
# ({Google::Cloud::Scheduler::V1::Job#name name}) in the response.
|
374
|
+
# A hash of the same form as `Google::Cloud::Scheduler::V1::Job`
|
375
|
+
# can also be provided.
|
376
|
+
# @param options [Google::Gax::CallOptions]
|
377
|
+
# Overrides the default settings for this call, e.g, timeout,
|
378
|
+
# retries, etc.
|
379
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
380
|
+
# @yieldparam result [Google::Cloud::Scheduler::V1::Job]
|
381
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
382
|
+
# @return [Google::Cloud::Scheduler::V1::Job]
|
383
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
384
|
+
# @example
|
385
|
+
# require "google/cloud/scheduler"
|
386
|
+
#
|
387
|
+
# cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
|
388
|
+
# formatted_parent = Google::Cloud::Scheduler::V1::CloudSchedulerClient.location_path("[PROJECT]", "[LOCATION]")
|
389
|
+
#
|
390
|
+
# # TODO: Initialize `job`:
|
391
|
+
# job = {}
|
392
|
+
# response = cloud_scheduler_client.create_job(formatted_parent, job)
|
393
|
+
|
394
|
+
def create_job \
|
395
|
+
parent,
|
396
|
+
job,
|
397
|
+
options: nil,
|
398
|
+
&block
|
399
|
+
req = {
|
400
|
+
parent: parent,
|
401
|
+
job: job
|
402
|
+
}.delete_if { |_, v| v.nil? }
|
403
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::CreateJobRequest)
|
404
|
+
@create_job.call(req, options, &block)
|
405
|
+
end
|
406
|
+
|
407
|
+
# Updates a job.
|
408
|
+
#
|
409
|
+
# If successful, the updated {Google::Cloud::Scheduler::V1::Job Job} is returned. If the job does
|
410
|
+
# not exist, `NOT_FOUND` is returned.
|
411
|
+
#
|
412
|
+
# If UpdateJob does not successfully return, it is possible for the
|
413
|
+
# job to be in an {Google::Cloud::Scheduler::V1::Job::State::UPDATE_FAILED Job::State::UPDATE_FAILED} state. A job in this state may
|
414
|
+
# not be executed. If this happens, retry the UpdateJob request
|
415
|
+
# until a successful response is received.
|
416
|
+
#
|
417
|
+
# @param job [Google::Cloud::Scheduler::V1::Job | Hash]
|
418
|
+
# Required.
|
419
|
+
#
|
420
|
+
# The new job properties. {Google::Cloud::Scheduler::V1::Job#name name} must be specified.
|
421
|
+
#
|
422
|
+
# Output only fields cannot be modified using UpdateJob.
|
423
|
+
# Any value specified for an output only field will be ignored.
|
424
|
+
# A hash of the same form as `Google::Cloud::Scheduler::V1::Job`
|
425
|
+
# can also be provided.
|
426
|
+
# @param update_mask [Google::Protobuf::FieldMask | Hash]
|
427
|
+
# A mask used to specify which fields of the job are being updated.
|
428
|
+
# A hash of the same form as `Google::Protobuf::FieldMask`
|
429
|
+
# can also be provided.
|
430
|
+
# @param options [Google::Gax::CallOptions]
|
431
|
+
# Overrides the default settings for this call, e.g, timeout,
|
432
|
+
# retries, etc.
|
433
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
434
|
+
# @yieldparam result [Google::Cloud::Scheduler::V1::Job]
|
435
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
436
|
+
# @return [Google::Cloud::Scheduler::V1::Job]
|
437
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
438
|
+
# @example
|
439
|
+
# require "google/cloud/scheduler"
|
440
|
+
#
|
441
|
+
# cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
|
442
|
+
#
|
443
|
+
# # TODO: Initialize `job`:
|
444
|
+
# job = {}
|
445
|
+
#
|
446
|
+
# # TODO: Initialize `update_mask`:
|
447
|
+
# update_mask = {}
|
448
|
+
# response = cloud_scheduler_client.update_job(job, update_mask)
|
449
|
+
|
450
|
+
def update_job \
|
451
|
+
job,
|
452
|
+
update_mask,
|
453
|
+
options: nil,
|
454
|
+
&block
|
455
|
+
req = {
|
456
|
+
job: job,
|
457
|
+
update_mask: update_mask
|
458
|
+
}.delete_if { |_, v| v.nil? }
|
459
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::UpdateJobRequest)
|
460
|
+
@update_job.call(req, options, &block)
|
461
|
+
end
|
462
|
+
|
463
|
+
# Deletes a job.
|
464
|
+
#
|
465
|
+
# @param name [String]
|
466
|
+
# Required.
|
467
|
+
#
|
468
|
+
# The job name. For example:
|
469
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
|
470
|
+
# @param options [Google::Gax::CallOptions]
|
471
|
+
# Overrides the default settings for this call, e.g, timeout,
|
472
|
+
# retries, etc.
|
473
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
474
|
+
# @yieldparam result []
|
475
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
476
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
477
|
+
# @example
|
478
|
+
# require "google/cloud/scheduler"
|
479
|
+
#
|
480
|
+
# cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
|
481
|
+
# formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
|
482
|
+
# cloud_scheduler_client.delete_job(formatted_name)
|
483
|
+
|
484
|
+
def delete_job \
|
485
|
+
name,
|
486
|
+
options: nil,
|
487
|
+
&block
|
488
|
+
req = {
|
489
|
+
name: name
|
490
|
+
}.delete_if { |_, v| v.nil? }
|
491
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::DeleteJobRequest)
|
492
|
+
@delete_job.call(req, options, &block)
|
493
|
+
nil
|
494
|
+
end
|
495
|
+
|
496
|
+
# Pauses a job.
|
497
|
+
#
|
498
|
+
# If a job is paused then the system will stop executing the job
|
499
|
+
# until it is re-enabled via {Google::Cloud::Scheduler::V1::CloudScheduler::ResumeJob ResumeJob}. The
|
500
|
+
# state of the job is stored in {Google::Cloud::Scheduler::V1::Job#state state}; if paused it
|
501
|
+
# will be set to {Google::Cloud::Scheduler::V1::Job::State::PAUSED Job::State::PAUSED}. A job must be in {Google::Cloud::Scheduler::V1::Job::State::ENABLED Job::State::ENABLED}
|
502
|
+
# to be paused.
|
503
|
+
#
|
504
|
+
# @param name [String]
|
505
|
+
# Required.
|
506
|
+
#
|
507
|
+
# The job name. For example:
|
508
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
|
509
|
+
# @param options [Google::Gax::CallOptions]
|
510
|
+
# Overrides the default settings for this call, e.g, timeout,
|
511
|
+
# retries, etc.
|
512
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
513
|
+
# @yieldparam result [Google::Cloud::Scheduler::V1::Job]
|
514
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
515
|
+
# @return [Google::Cloud::Scheduler::V1::Job]
|
516
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
517
|
+
# @example
|
518
|
+
# require "google/cloud/scheduler"
|
519
|
+
#
|
520
|
+
# cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
|
521
|
+
# formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
|
522
|
+
# response = cloud_scheduler_client.pause_job(formatted_name)
|
523
|
+
|
524
|
+
def pause_job \
|
525
|
+
name,
|
526
|
+
options: nil,
|
527
|
+
&block
|
528
|
+
req = {
|
529
|
+
name: name
|
530
|
+
}.delete_if { |_, v| v.nil? }
|
531
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::PauseJobRequest)
|
532
|
+
@pause_job.call(req, options, &block)
|
533
|
+
end
|
534
|
+
|
535
|
+
# Resume a job.
|
536
|
+
#
|
537
|
+
# This method reenables a job after it has been {Google::Cloud::Scheduler::V1::Job::State::PAUSED Job::State::PAUSED}. The
|
538
|
+
# state of a job is stored in {Google::Cloud::Scheduler::V1::Job#state Job#state}; after calling this method it
|
539
|
+
# will be set to {Google::Cloud::Scheduler::V1::Job::State::ENABLED Job::State::ENABLED}. A job must be in
|
540
|
+
# {Google::Cloud::Scheduler::V1::Job::State::PAUSED Job::State::PAUSED} to be resumed.
|
541
|
+
#
|
542
|
+
# @param name [String]
|
543
|
+
# Required.
|
544
|
+
#
|
545
|
+
# The job name. For example:
|
546
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
|
547
|
+
# @param options [Google::Gax::CallOptions]
|
548
|
+
# Overrides the default settings for this call, e.g, timeout,
|
549
|
+
# retries, etc.
|
550
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
551
|
+
# @yieldparam result [Google::Cloud::Scheduler::V1::Job]
|
552
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
553
|
+
# @return [Google::Cloud::Scheduler::V1::Job]
|
554
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
555
|
+
# @example
|
556
|
+
# require "google/cloud/scheduler"
|
557
|
+
#
|
558
|
+
# cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
|
559
|
+
# formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
|
560
|
+
# response = cloud_scheduler_client.resume_job(formatted_name)
|
561
|
+
|
562
|
+
def resume_job \
|
563
|
+
name,
|
564
|
+
options: nil,
|
565
|
+
&block
|
566
|
+
req = {
|
567
|
+
name: name
|
568
|
+
}.delete_if { |_, v| v.nil? }
|
569
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::ResumeJobRequest)
|
570
|
+
@resume_job.call(req, options, &block)
|
571
|
+
end
|
572
|
+
|
573
|
+
# Forces a job to run now.
|
574
|
+
#
|
575
|
+
# When this method is called, Cloud Scheduler will dispatch the job, even
|
576
|
+
# if the job is already running.
|
577
|
+
#
|
578
|
+
# @param name [String]
|
579
|
+
# Required.
|
580
|
+
#
|
581
|
+
# The job name. For example:
|
582
|
+
# `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
|
583
|
+
# @param options [Google::Gax::CallOptions]
|
584
|
+
# Overrides the default settings for this call, e.g, timeout,
|
585
|
+
# retries, etc.
|
586
|
+
# @yield [result, operation] Access the result along with the RPC operation
|
587
|
+
# @yieldparam result [Google::Cloud::Scheduler::V1::Job]
|
588
|
+
# @yieldparam operation [GRPC::ActiveCall::Operation]
|
589
|
+
# @return [Google::Cloud::Scheduler::V1::Job]
|
590
|
+
# @raise [Google::Gax::GaxError] if the RPC is aborted.
|
591
|
+
# @example
|
592
|
+
# require "google/cloud/scheduler"
|
593
|
+
#
|
594
|
+
# cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
|
595
|
+
# formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
|
596
|
+
# response = cloud_scheduler_client.run_job(formatted_name)
|
597
|
+
|
598
|
+
def run_job \
|
599
|
+
name,
|
600
|
+
options: nil,
|
601
|
+
&block
|
602
|
+
req = {
|
603
|
+
name: name
|
604
|
+
}.delete_if { |_, v| v.nil? }
|
605
|
+
req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::RunJobRequest)
|
606
|
+
@run_job.call(req, options, &block)
|
607
|
+
end
|
608
|
+
end
|
609
|
+
end
|
610
|
+
end
|
611
|
+
end
|
612
|
+
end
|