google-cloud-scheduler 1.3.1 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (46) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +2 -1
  3. data/AUTHENTICATION.md +51 -54
  4. data/LICENSE.md +203 -0
  5. data/MIGRATING.md +275 -0
  6. data/README.md +36 -24
  7. data/lib/{google/cloud/scheduler/v1/doc/google/protobuf/empty.rb → google-cloud-scheduler.rb} +4 -14
  8. data/lib/google/cloud/scheduler.rb +82 -117
  9. data/lib/google/cloud/scheduler/version.rb +6 -2
  10. metadata +102 -73
  11. data/LICENSE +0 -201
  12. data/lib/google/cloud/scheduler/v1.rb +0 -147
  13. data/lib/google/cloud/scheduler/v1/cloud_scheduler_client.rb +0 -616
  14. data/lib/google/cloud/scheduler/v1/cloud_scheduler_client_config.json +0 -66
  15. data/lib/google/cloud/scheduler/v1/cloudscheduler_pb.rb +0 -65
  16. data/lib/google/cloud/scheduler/v1/cloudscheduler_services_pb.rb +0 -84
  17. data/lib/google/cloud/scheduler/v1/credentials.rb +0 -41
  18. data/lib/google/cloud/scheduler/v1/doc/google/cloud/scheduler/v1/cloudscheduler.rb +0 -124
  19. data/lib/google/cloud/scheduler/v1/doc/google/cloud/scheduler/v1/job.rb +0 -219
  20. data/lib/google/cloud/scheduler/v1/doc/google/cloud/scheduler/v1/target.rb +0 -336
  21. data/lib/google/cloud/scheduler/v1/doc/google/protobuf/any.rb +0 -131
  22. data/lib/google/cloud/scheduler/v1/doc/google/protobuf/duration.rb +0 -91
  23. data/lib/google/cloud/scheduler/v1/doc/google/protobuf/field_mask.rb +0 -222
  24. data/lib/google/cloud/scheduler/v1/doc/google/protobuf/timestamp.rb +0 -113
  25. data/lib/google/cloud/scheduler/v1/doc/google/rpc/status.rb +0 -39
  26. data/lib/google/cloud/scheduler/v1/helpers.rb +0 -48
  27. data/lib/google/cloud/scheduler/v1/job_pb.rb +0 -58
  28. data/lib/google/cloud/scheduler/v1/target_pb.rb +0 -72
  29. data/lib/google/cloud/scheduler/v1beta1.rb +0 -147
  30. data/lib/google/cloud/scheduler/v1beta1/cloud_scheduler_client.rb +0 -613
  31. data/lib/google/cloud/scheduler/v1beta1/cloud_scheduler_client_config.json +0 -66
  32. data/lib/google/cloud/scheduler/v1beta1/cloudscheduler_pb.rb +0 -65
  33. data/lib/google/cloud/scheduler/v1beta1/cloudscheduler_services_pb.rb +0 -84
  34. data/lib/google/cloud/scheduler/v1beta1/credentials.rb +0 -41
  35. data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/cloudscheduler.rb +0 -124
  36. data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/job.rb +0 -221
  37. data/lib/google/cloud/scheduler/v1beta1/doc/google/cloud/scheduler/v1beta1/target.rb +0 -336
  38. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/any.rb +0 -131
  39. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/duration.rb +0 -91
  40. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/empty.rb +0 -29
  41. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/field_mask.rb +0 -222
  42. data/lib/google/cloud/scheduler/v1beta1/doc/google/protobuf/timestamp.rb +0 -113
  43. data/lib/google/cloud/scheduler/v1beta1/doc/google/rpc/status.rb +0 -39
  44. data/lib/google/cloud/scheduler/v1beta1/helpers.rb +0 -48
  45. data/lib/google/cloud/scheduler/v1beta1/job_pb.rb +0 -58
  46. data/lib/google/cloud/scheduler/v1beta1/target_pb.rb +0 -72
data/LICENSE DELETED
@@ -1,201 +0,0 @@
1
- Apache License
2
- Version 2.0, January 2004
3
- https://www.apache.org/licenses/
4
-
5
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
-
7
- 1. Definitions.
8
-
9
- "License" shall mean the terms and conditions for use, reproduction,
10
- and distribution as defined by Sections 1 through 9 of this document.
11
-
12
- "Licensor" shall mean the copyright owner or entity authorized by
13
- the copyright owner that is granting the License.
14
-
15
- "Legal Entity" shall mean the union of the acting entity and all
16
- other entities that control, are controlled by, or are under common
17
- control with that entity. For the purposes of this definition,
18
- "control" means (i) the power, direct or indirect, to cause the
19
- direction or management of such entity, whether by contract or
20
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
- outstanding shares, or (iii) beneficial ownership of such entity.
22
-
23
- "You" (or "Your") shall mean an individual or Legal Entity
24
- exercising permissions granted by this License.
25
-
26
- "Source" form shall mean the preferred form for making modifications,
27
- including but not limited to software source code, documentation
28
- source, and configuration files.
29
-
30
- "Object" form shall mean any form resulting from mechanical
31
- transformation or translation of a Source form, including but
32
- not limited to compiled object code, generated documentation,
33
- and conversions to other media types.
34
-
35
- "Work" shall mean the work of authorship, whether in Source or
36
- Object form, made available under the License, as indicated by a
37
- copyright notice that is included in or attached to the work
38
- (an example is provided in the Appendix below).
39
-
40
- "Derivative Works" shall mean any work, whether in Source or Object
41
- form, that is based on (or derived from) the Work and for which the
42
- editorial revisions, annotations, elaborations, or other modifications
43
- represent, as a whole, an original work of authorship. For the purposes
44
- of this License, Derivative Works shall not include works that remain
45
- separable from, or merely link (or bind by name) to the interfaces of,
46
- the Work and Derivative Works thereof.
47
-
48
- "Contribution" shall mean any work of authorship, including
49
- the original version of the Work and any modifications or additions
50
- to that Work or Derivative Works thereof, that is intentionally
51
- submitted to Licensor for inclusion in the Work by the copyright owner
52
- or by an individual or Legal Entity authorized to submit on behalf of
53
- the copyright owner. For the purposes of this definition, "submitted"
54
- means any form of electronic, verbal, or written communication sent
55
- to the Licensor or its representatives, including but not limited to
56
- communication on electronic mailing lists, source code control systems,
57
- and issue tracking systems that are managed by, or on behalf of, the
58
- Licensor for the purpose of discussing and improving the Work, but
59
- excluding communication that is conspicuously marked or otherwise
60
- designated in writing by the copyright owner as "Not a Contribution."
61
-
62
- "Contributor" shall mean Licensor and any individual or Legal Entity
63
- on behalf of whom a Contribution has been received by Licensor and
64
- subsequently incorporated within the Work.
65
-
66
- 2. Grant of Copyright License. Subject to the terms and conditions of
67
- this License, each Contributor hereby grants to You a perpetual,
68
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
- copyright license to reproduce, prepare Derivative Works of,
70
- publicly display, publicly perform, sublicense, and distribute the
71
- Work and such Derivative Works in Source or Object form.
72
-
73
- 3. Grant of Patent License. Subject to the terms and conditions of
74
- this License, each Contributor hereby grants to You a perpetual,
75
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
- (except as stated in this section) patent license to make, have made,
77
- use, offer to sell, sell, import, and otherwise transfer the Work,
78
- where such license applies only to those patent claims licensable
79
- by such Contributor that are necessarily infringed by their
80
- Contribution(s) alone or by combination of their Contribution(s)
81
- with the Work to which such Contribution(s) was submitted. If You
82
- institute patent litigation against any entity (including a
83
- cross-claim or counterclaim in a lawsuit) alleging that the Work
84
- or a Contribution incorporated within the Work constitutes direct
85
- or contributory patent infringement, then any patent licenses
86
- granted to You under this License for that Work shall terminate
87
- as of the date such litigation is filed.
88
-
89
- 4. Redistribution. You may reproduce and distribute copies of the
90
- Work or Derivative Works thereof in any medium, with or without
91
- modifications, and in Source or Object form, provided that You
92
- meet the following conditions:
93
-
94
- (a) You must give any other recipients of the Work or
95
- Derivative Works a copy of this License; and
96
-
97
- (b) You must cause any modified files to carry prominent notices
98
- stating that You changed the files; and
99
-
100
- (c) You must retain, in the Source form of any Derivative Works
101
- that You distribute, all copyright, patent, trademark, and
102
- attribution notices from the Source form of the Work,
103
- excluding those notices that do not pertain to any part of
104
- the Derivative Works; and
105
-
106
- (d) If the Work includes a "NOTICE" text file as part of its
107
- distribution, then any Derivative Works that You distribute must
108
- include a readable copy of the attribution notices contained
109
- within such NOTICE file, excluding those notices that do not
110
- pertain to any part of the Derivative Works, in at least one
111
- of the following places: within a NOTICE text file distributed
112
- as part of the Derivative Works; within the Source form or
113
- documentation, if provided along with the Derivative Works; or,
114
- within a display generated by the Derivative Works, if and
115
- wherever such third-party notices normally appear. The contents
116
- of the NOTICE file are for informational purposes only and
117
- do not modify the License. You may add Your own attribution
118
- notices within Derivative Works that You distribute, alongside
119
- or as an addendum to the NOTICE text from the Work, provided
120
- that such additional attribution notices cannot be construed
121
- as modifying the License.
122
-
123
- You may add Your own copyright statement to Your modifications and
124
- may provide additional or different license terms and conditions
125
- for use, reproduction, or distribution of Your modifications, or
126
- for any such Derivative Works as a whole, provided Your use,
127
- reproduction, and distribution of the Work otherwise complies with
128
- the conditions stated in this License.
129
-
130
- 5. Submission of Contributions. Unless You explicitly state otherwise,
131
- any Contribution intentionally submitted for inclusion in the Work
132
- by You to the Licensor shall be under the terms and conditions of
133
- this License, without any additional terms or conditions.
134
- Notwithstanding the above, nothing herein shall supersede or modify
135
- the terms of any separate license agreement you may have executed
136
- with Licensor regarding such Contributions.
137
-
138
- 6. Trademarks. This License does not grant permission to use the trade
139
- names, trademarks, service marks, or product names of the Licensor,
140
- except as required for reasonable and customary use in describing the
141
- origin of the Work and reproducing the content of the NOTICE file.
142
-
143
- 7. Disclaimer of Warranty. Unless required by applicable law or
144
- agreed to in writing, Licensor provides the Work (and each
145
- Contributor provides its Contributions) on an "AS IS" BASIS,
146
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
- implied, including, without limitation, any warranties or conditions
148
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
- PARTICULAR PURPOSE. You are solely responsible for determining the
150
- appropriateness of using or redistributing the Work and assume any
151
- risks associated with Your exercise of permissions under this License.
152
-
153
- 8. Limitation of Liability. In no event and under no legal theory,
154
- whether in tort (including negligence), contract, or otherwise,
155
- unless required by applicable law (such as deliberate and grossly
156
- negligent acts) or agreed to in writing, shall any Contributor be
157
- liable to You for damages, including any direct, indirect, special,
158
- incidental, or consequential damages of any character arising as a
159
- result of this License or out of the use or inability to use the
160
- Work (including but not limited to damages for loss of goodwill,
161
- work stoppage, computer failure or malfunction, or any and all
162
- other commercial damages or losses), even if such Contributor
163
- has been advised of the possibility of such damages.
164
-
165
- 9. Accepting Warranty or Additional Liability. While redistributing
166
- the Work or Derivative Works thereof, You may choose to offer,
167
- and charge a fee for, acceptance of support, warranty, indemnity,
168
- or other liability obligations and/or rights consistent with this
169
- License. However, in accepting such obligations, You may act only
170
- on Your own behalf and on Your sole responsibility, not on behalf
171
- of any other Contributor, and only if You agree to indemnify,
172
- defend, and hold each Contributor harmless for any liability
173
- incurred by, or claims asserted against, such Contributor by reason
174
- of your accepting any such warranty or additional liability.
175
-
176
- END OF TERMS AND CONDITIONS
177
-
178
- APPENDIX: How to apply the Apache License to your work.
179
-
180
- To apply the Apache License to your work, attach the following
181
- boilerplate notice, with the fields enclosed by brackets "[]"
182
- replaced with your own identifying information. (Don't include
183
- the brackets!) The text should be enclosed in the appropriate
184
- comment syntax for the file format. We also recommend that a
185
- file or class name and description of purpose be included on the
186
- same "printed page" as the copyright notice for easier
187
- identification within third-party archives.
188
-
189
- Copyright [yyyy] [name of copyright owner]
190
-
191
- Licensed under the Apache License, Version 2.0 (the "License");
192
- you may not use this file except in compliance with the License.
193
- You may obtain a copy of the License at
194
-
195
- https://www.apache.org/licenses/LICENSE-2.0
196
-
197
- Unless required by applicable law or agreed to in writing, software
198
- distributed under the License is distributed on an "AS IS" BASIS,
199
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
- See the License for the specific language governing permissions and
201
- limitations under the License.
@@ -1,147 +0,0 @@
1
- # Copyright 2020 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
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.dev/ruby/google-cloud-scheduler/latest/file.AUTHENTICATION.html)
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/scheduler
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.dev/ruby/google-cloud-logging/latest)
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 service_address [String]
113
- # Override for the service hostname, or `nil` to leave as the default.
114
- # @param service_port [Integer]
115
- # Override for the service port, or `nil` to leave as the default.
116
- # @param exception_transformer [Proc]
117
- # An optional proc that intercepts any exceptions raised during an API call to inject
118
- # custom error handling.
119
- def self.new \
120
- credentials: nil,
121
- scopes: nil,
122
- client_config: nil,
123
- timeout: nil,
124
- metadata: nil,
125
- service_address: nil,
126
- service_port: nil,
127
- exception_transformer: nil,
128
- lib_name: nil,
129
- lib_version: nil
130
- kwargs = {
131
- credentials: credentials,
132
- scopes: scopes,
133
- client_config: client_config,
134
- timeout: timeout,
135
- metadata: metadata,
136
- exception_transformer: exception_transformer,
137
- lib_name: lib_name,
138
- service_address: service_address,
139
- service_port: service_port,
140
- lib_version: lib_version
141
- }.select { |_, v| v != nil }
142
- Google::Cloud::Scheduler::V1::CloudSchedulerClient.new(**kwargs)
143
- end
144
- end
145
- end
146
- end
147
- end
@@ -1,616 +0,0 @@
1
- # Copyright 2020 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
- require "google/cloud/scheduler/version"
31
-
32
- module Google
33
- module Cloud
34
- module Scheduler
35
- module V1
36
- # The Cloud Scheduler API allows external entities to reliably
37
- # schedule asynchronous jobs.
38
- #
39
- # @!attribute [r] cloud_scheduler_stub
40
- # @return [Google::Cloud::Scheduler::V1::CloudScheduler::Stub]
41
- class CloudSchedulerClient
42
- # @private
43
- attr_reader :cloud_scheduler_stub
44
-
45
- # @deprecated
46
- def self.project_path project; "projects/#{project}"; end
47
-
48
- # The default address of the service.
49
- SERVICE_ADDRESS = "cloudscheduler.googleapis.com".freeze
50
-
51
- # The default port of the service.
52
- DEFAULT_SERVICE_PORT = 443
53
-
54
- # The default set of gRPC interceptors.
55
- GRPC_INTERCEPTORS = []
56
-
57
- DEFAULT_TIMEOUT = 30
58
-
59
- PAGE_DESCRIPTORS = {
60
- "list_jobs" => Google::Gax::PageDescriptor.new(
61
- "page_token",
62
- "next_page_token",
63
- "jobs")
64
- }.freeze
65
-
66
- private_constant :PAGE_DESCRIPTORS
67
-
68
- # The scopes needed to make gRPC calls to all of the methods defined in
69
- # this service.
70
- ALL_SCOPES = [
71
- "https://www.googleapis.com/auth/cloud-platform"
72
- ].freeze
73
-
74
-
75
- JOB_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
76
- "projects/{project}/locations/{location}/jobs/{job}"
77
- )
78
-
79
- private_constant :JOB_PATH_TEMPLATE
80
-
81
- LOCATION_PATH_TEMPLATE = Google::Gax::PathTemplate.new(
82
- "projects/{project}/locations/{location}"
83
- )
84
-
85
- private_constant :LOCATION_PATH_TEMPLATE
86
-
87
- # Returns a fully-qualified job resource name string.
88
- # @param project [String]
89
- # @param location [String]
90
- # @param job [String]
91
- # @return [String]
92
- def self.job_path project, location, job
93
- JOB_PATH_TEMPLATE.render(
94
- :"project" => project,
95
- :"location" => location,
96
- :"job" => job
97
- )
98
- end
99
-
100
- # Returns a fully-qualified location resource name string.
101
- # @param project [String]
102
- # @param location [String]
103
- # @return [String]
104
- def self.location_path project, location
105
- LOCATION_PATH_TEMPLATE.render(
106
- :"project" => project,
107
- :"location" => location
108
- )
109
- end
110
-
111
- # @param credentials [Google::Auth::Credentials, String, Hash, GRPC::Core::Channel, GRPC::Core::ChannelCredentials, Proc]
112
- # Provides the means for authenticating requests made by the client. This parameter can
113
- # be many types.
114
- # A `Google::Auth::Credentials` uses a the properties of its represented keyfile for
115
- # authenticating requests made by this client.
116
- # A `String` will be treated as the path to the keyfile to be used for the construction of
117
- # credentials for this client.
118
- # A `Hash` will be treated as the contents of a keyfile to be used for the construction of
119
- # credentials for this client.
120
- # A `GRPC::Core::Channel` will be used to make calls through.
121
- # A `GRPC::Core::ChannelCredentials` for the setting up the RPC client. The channel credentials
122
- # should already be composed with a `GRPC::Core::CallCredentials` object.
123
- # A `Proc` will be used as an updater_proc for the Grpc channel. The proc transforms the
124
- # metadata for requests, generally, to give OAuth credentials.
125
- # @param scopes [Array<String>]
126
- # The OAuth scopes for this service. This parameter is ignored if
127
- # an updater_proc is supplied.
128
- # @param client_config [Hash]
129
- # A Hash for call options for each method. See
130
- # Google::Gax#construct_settings for the structure of
131
- # this data. Falls back to the default config if not specified
132
- # or the specified config is missing data points.
133
- # @param timeout [Numeric]
134
- # The default timeout, in seconds, for calls made through this client.
135
- # @param metadata [Hash]
136
- # Default metadata to be sent with each request. This can be overridden on a per call basis.
137
- # @param service_address [String]
138
- # Override for the service hostname, or `nil` to leave as the default.
139
- # @param service_port [Integer]
140
- # Override for the service port, or `nil` to leave as the default.
141
- # @param exception_transformer [Proc]
142
- # An optional proc that intercepts any exceptions raised during an API call to inject
143
- # custom error handling.
144
- def initialize \
145
- credentials: nil,
146
- scopes: ALL_SCOPES,
147
- client_config: {},
148
- timeout: DEFAULT_TIMEOUT,
149
- metadata: nil,
150
- service_address: nil,
151
- service_port: nil,
152
- exception_transformer: nil,
153
- lib_name: nil,
154
- lib_version: ""
155
- # These require statements are intentionally placed here to initialize
156
- # the gRPC module only when it's required.
157
- # See https://github.com/googleapis/toolkit/issues/446
158
- require "google/gax/grpc"
159
- require "google/cloud/scheduler/v1/cloudscheduler_services_pb"
160
-
161
- credentials ||= Google::Cloud::Scheduler::V1::Credentials.default
162
-
163
- if credentials.is_a?(String) || credentials.is_a?(Hash)
164
- updater_proc = Google::Cloud::Scheduler::V1::Credentials.new(credentials).updater_proc
165
- end
166
- if credentials.is_a?(GRPC::Core::Channel)
167
- channel = credentials
168
- end
169
- if credentials.is_a?(GRPC::Core::ChannelCredentials)
170
- chan_creds = credentials
171
- end
172
- if credentials.is_a?(Proc)
173
- updater_proc = credentials
174
- end
175
- if credentials.is_a?(Google::Auth::Credentials)
176
- updater_proc = credentials.updater_proc
177
- end
178
-
179
- package_version = Google::Cloud::Scheduler::VERSION
180
-
181
- google_api_client = "gl-ruby/#{RUBY_VERSION}"
182
- google_api_client << " #{lib_name}/#{lib_version}" if lib_name
183
- google_api_client << " gapic/#{package_version} gax/#{Google::Gax::VERSION}"
184
- google_api_client << " grpc/#{GRPC::VERSION}"
185
- google_api_client.freeze
186
-
187
- headers = { :"x-goog-api-client" => google_api_client }
188
- if credentials.respond_to?(:quota_project_id) && credentials.quota_project_id
189
- headers[:"x-goog-user-project"] = credentials.quota_project_id
190
- end
191
- headers.merge!(metadata) unless metadata.nil?
192
- client_config_file = Pathname.new(__dir__).join(
193
- "cloud_scheduler_client_config.json"
194
- )
195
- defaults = client_config_file.open do |f|
196
- Google::Gax.construct_settings(
197
- "google.cloud.scheduler.v1.CloudScheduler",
198
- JSON.parse(f.read),
199
- client_config,
200
- Google::Gax::Grpc::STATUS_CODE_NAMES,
201
- timeout,
202
- page_descriptors: PAGE_DESCRIPTORS,
203
- errors: Google::Gax::Grpc::API_ERRORS,
204
- metadata: headers
205
- )
206
- end
207
-
208
- # Allow overriding the service path/port in subclasses.
209
- service_path = service_address || self.class::SERVICE_ADDRESS
210
- port = service_port || self.class::DEFAULT_SERVICE_PORT
211
- interceptors = self.class::GRPC_INTERCEPTORS
212
- @cloud_scheduler_stub = Google::Gax::Grpc.create_stub(
213
- service_path,
214
- port,
215
- chan_creds: chan_creds,
216
- channel: channel,
217
- updater_proc: updater_proc,
218
- scopes: scopes,
219
- interceptors: interceptors,
220
- &Google::Cloud::Scheduler::V1::CloudScheduler::Stub.method(:new)
221
- )
222
-
223
- @list_jobs = Google::Gax.create_api_call(
224
- @cloud_scheduler_stub.method(:list_jobs),
225
- defaults["list_jobs"],
226
- exception_transformer: exception_transformer,
227
- params_extractor: proc do |request|
228
- {'parent' => request.parent}
229
- end
230
- )
231
- @get_job = Google::Gax.create_api_call(
232
- @cloud_scheduler_stub.method(:get_job),
233
- defaults["get_job"],
234
- exception_transformer: exception_transformer,
235
- params_extractor: proc do |request|
236
- {'name' => request.name}
237
- end
238
- )
239
- @create_job = Google::Gax.create_api_call(
240
- @cloud_scheduler_stub.method(:create_job),
241
- defaults["create_job"],
242
- exception_transformer: exception_transformer,
243
- params_extractor: proc do |request|
244
- {'parent' => request.parent}
245
- end
246
- )
247
- @update_job = Google::Gax.create_api_call(
248
- @cloud_scheduler_stub.method(:update_job),
249
- defaults["update_job"],
250
- exception_transformer: exception_transformer,
251
- params_extractor: proc do |request|
252
- {'job.name' => request.job.name}
253
- end
254
- )
255
- @delete_job = Google::Gax.create_api_call(
256
- @cloud_scheduler_stub.method(:delete_job),
257
- defaults["delete_job"],
258
- exception_transformer: exception_transformer,
259
- params_extractor: proc do |request|
260
- {'name' => request.name}
261
- end
262
- )
263
- @pause_job = Google::Gax.create_api_call(
264
- @cloud_scheduler_stub.method(:pause_job),
265
- defaults["pause_job"],
266
- exception_transformer: exception_transformer,
267
- params_extractor: proc do |request|
268
- {'name' => request.name}
269
- end
270
- )
271
- @resume_job = Google::Gax.create_api_call(
272
- @cloud_scheduler_stub.method(:resume_job),
273
- defaults["resume_job"],
274
- exception_transformer: exception_transformer,
275
- params_extractor: proc do |request|
276
- {'name' => request.name}
277
- end
278
- )
279
- @run_job = Google::Gax.create_api_call(
280
- @cloud_scheduler_stub.method(:run_job),
281
- defaults["run_job"],
282
- exception_transformer: exception_transformer,
283
- params_extractor: proc do |request|
284
- {'name' => request.name}
285
- end
286
- )
287
- end
288
-
289
- # Service calls
290
-
291
- # Lists jobs.
292
- #
293
- # @param parent [String]
294
- # Required. The location name. For example:
295
- # `projects/PROJECT_ID/locations/LOCATION_ID`.
296
- # @param page_size [Integer]
297
- # The maximum number of resources contained in the underlying API
298
- # response. If page streaming is performed per-resource, this
299
- # parameter does not affect the return value. If page streaming is
300
- # performed per-page, this determines the maximum number of
301
- # resources in a page.
302
- # @param options [Google::Gax::CallOptions]
303
- # Overrides the default settings for this call, e.g, timeout,
304
- # retries, etc.
305
- # @yield [result, operation] Access the result along with the RPC operation
306
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Scheduler::V1::Job>]
307
- # @yieldparam operation [GRPC::ActiveCall::Operation]
308
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Scheduler::V1::Job>]
309
- # An enumerable of Google::Cloud::Scheduler::V1::Job instances.
310
- # See Google::Gax::PagedEnumerable documentation for other
311
- # operations such as per-page iteration or access to the response
312
- # object.
313
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
314
- # @example
315
- # require "google/cloud/scheduler"
316
- #
317
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
318
- # formatted_parent = Google::Cloud::Scheduler::V1::CloudSchedulerClient.location_path("[PROJECT]", "[LOCATION]")
319
- #
320
- # # Iterate over all results.
321
- # cloud_scheduler_client.list_jobs(formatted_parent).each do |element|
322
- # # Process element.
323
- # end
324
- #
325
- # # Or iterate over results one page at a time.
326
- # cloud_scheduler_client.list_jobs(formatted_parent).each_page do |page|
327
- # # Process each page at a time.
328
- # page.each do |element|
329
- # # Process element.
330
- # end
331
- # end
332
-
333
- def list_jobs \
334
- parent,
335
- page_size: nil,
336
- options: nil,
337
- &block
338
- req = {
339
- parent: parent,
340
- page_size: page_size
341
- }.delete_if { |_, v| v.nil? }
342
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::ListJobsRequest)
343
- @list_jobs.call(req, options, &block)
344
- end
345
-
346
- # Gets a job.
347
- #
348
- # @param name [String]
349
- # Required. The job name. For example:
350
- # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
351
- # @param options [Google::Gax::CallOptions]
352
- # Overrides the default settings for this call, e.g, timeout,
353
- # retries, etc.
354
- # @yield [result, operation] Access the result along with the RPC operation
355
- # @yieldparam result [Google::Cloud::Scheduler::V1::Job]
356
- # @yieldparam operation [GRPC::ActiveCall::Operation]
357
- # @return [Google::Cloud::Scheduler::V1::Job]
358
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
359
- # @example
360
- # require "google/cloud/scheduler"
361
- #
362
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
363
- # formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
364
- # response = cloud_scheduler_client.get_job(formatted_name)
365
-
366
- def get_job \
367
- name,
368
- options: nil,
369
- &block
370
- req = {
371
- name: name
372
- }.delete_if { |_, v| v.nil? }
373
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::GetJobRequest)
374
- @get_job.call(req, options, &block)
375
- end
376
-
377
- # Creates a job.
378
- #
379
- # @param parent [String]
380
- # Required. The location name. For example:
381
- # `projects/PROJECT_ID/locations/LOCATION_ID`.
382
- # @param job [Google::Cloud::Scheduler::V1::Job | Hash]
383
- # Required. The job to add. The user can optionally specify a name for the
384
- # job in {Google::Cloud::Scheduler::V1::Job#name name}. {Google::Cloud::Scheduler::V1::Job#name name} cannot be the same as an
385
- # existing job. If a name is not specified then the system will
386
- # generate a random unique name that will be returned
387
- # ({Google::Cloud::Scheduler::V1::Job#name name}) in the response.
388
- # A hash of the same form as `Google::Cloud::Scheduler::V1::Job`
389
- # can also be provided.
390
- # @param options [Google::Gax::CallOptions]
391
- # Overrides the default settings for this call, e.g, timeout,
392
- # retries, etc.
393
- # @yield [result, operation] Access the result along with the RPC operation
394
- # @yieldparam result [Google::Cloud::Scheduler::V1::Job]
395
- # @yieldparam operation [GRPC::ActiveCall::Operation]
396
- # @return [Google::Cloud::Scheduler::V1::Job]
397
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
398
- # @example
399
- # require "google/cloud/scheduler"
400
- #
401
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
402
- # formatted_parent = Google::Cloud::Scheduler::V1::CloudSchedulerClient.location_path("[PROJECT]", "[LOCATION]")
403
- #
404
- # # TODO: Initialize `job`:
405
- # job = {}
406
- # response = cloud_scheduler_client.create_job(formatted_parent, job)
407
-
408
- def create_job \
409
- parent,
410
- job,
411
- options: nil,
412
- &block
413
- req = {
414
- parent: parent,
415
- job: job
416
- }.delete_if { |_, v| v.nil? }
417
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::CreateJobRequest)
418
- @create_job.call(req, options, &block)
419
- end
420
-
421
- # Updates a job.
422
- #
423
- # If successful, the updated {Google::Cloud::Scheduler::V1::Job Job} is returned. If the job does
424
- # not exist, `NOT_FOUND` is returned.
425
- #
426
- # If UpdateJob does not successfully return, it is possible for the
427
- # job to be in an {Google::Cloud::Scheduler::V1::Job::State::UPDATE_FAILED Job::State::UPDATE_FAILED} state. A job in this state may
428
- # not be executed. If this happens, retry the UpdateJob request
429
- # until a successful response is received.
430
- #
431
- # @param job [Google::Cloud::Scheduler::V1::Job | Hash]
432
- # Required. The new job properties. {Google::Cloud::Scheduler::V1::Job#name name} must be specified.
433
- #
434
- # Output only fields cannot be modified using UpdateJob.
435
- # Any value specified for an output only field will be ignored.
436
- # A hash of the same form as `Google::Cloud::Scheduler::V1::Job`
437
- # can also be provided.
438
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
439
- # A mask used to specify which fields of the job are being updated.
440
- # A hash of the same form as `Google::Protobuf::FieldMask`
441
- # can also be provided.
442
- # @param options [Google::Gax::CallOptions]
443
- # Overrides the default settings for this call, e.g, timeout,
444
- # retries, etc.
445
- # @yield [result, operation] Access the result along with the RPC operation
446
- # @yieldparam result [Google::Cloud::Scheduler::V1::Job]
447
- # @yieldparam operation [GRPC::ActiveCall::Operation]
448
- # @return [Google::Cloud::Scheduler::V1::Job]
449
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
450
- # @example
451
- # require "google/cloud/scheduler"
452
- #
453
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
454
- #
455
- # # TODO: Initialize `job`:
456
- # job = {}
457
- #
458
- # # TODO: Initialize `update_mask`:
459
- # update_mask = {}
460
- # response = cloud_scheduler_client.update_job(job, update_mask)
461
-
462
- def update_job \
463
- job,
464
- update_mask,
465
- options: nil,
466
- &block
467
- req = {
468
- job: job,
469
- update_mask: update_mask
470
- }.delete_if { |_, v| v.nil? }
471
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::UpdateJobRequest)
472
- @update_job.call(req, options, &block)
473
- end
474
-
475
- # Deletes a job.
476
- #
477
- # @param name [String]
478
- # Required. The job name. For example:
479
- # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
480
- # @param options [Google::Gax::CallOptions]
481
- # Overrides the default settings for this call, e.g, timeout,
482
- # retries, etc.
483
- # @yield [result, operation] Access the result along with the RPC operation
484
- # @yieldparam result []
485
- # @yieldparam operation [GRPC::ActiveCall::Operation]
486
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
487
- # @example
488
- # require "google/cloud/scheduler"
489
- #
490
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
491
- # formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
492
- # cloud_scheduler_client.delete_job(formatted_name)
493
-
494
- def delete_job \
495
- name,
496
- options: nil,
497
- &block
498
- req = {
499
- name: name
500
- }.delete_if { |_, v| v.nil? }
501
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::DeleteJobRequest)
502
- @delete_job.call(req, options, &block)
503
- nil
504
- end
505
-
506
- # Pauses a job.
507
- #
508
- # If a job is paused then the system will stop executing the job
509
- # until it is re-enabled via {Google::Cloud::Scheduler::V1::CloudScheduler::ResumeJob ResumeJob}. The
510
- # state of the job is stored in {Google::Cloud::Scheduler::V1::Job#state state}; if paused it
511
- # 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}
512
- # to be paused.
513
- #
514
- # @param name [String]
515
- # Required. The job name. For example:
516
- # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
517
- # @param options [Google::Gax::CallOptions]
518
- # Overrides the default settings for this call, e.g, timeout,
519
- # retries, etc.
520
- # @yield [result, operation] Access the result along with the RPC operation
521
- # @yieldparam result [Google::Cloud::Scheduler::V1::Job]
522
- # @yieldparam operation [GRPC::ActiveCall::Operation]
523
- # @return [Google::Cloud::Scheduler::V1::Job]
524
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
525
- # @example
526
- # require "google/cloud/scheduler"
527
- #
528
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
529
- # formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
530
- # response = cloud_scheduler_client.pause_job(formatted_name)
531
-
532
- def pause_job \
533
- name,
534
- options: nil,
535
- &block
536
- req = {
537
- name: name
538
- }.delete_if { |_, v| v.nil? }
539
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::PauseJobRequest)
540
- @pause_job.call(req, options, &block)
541
- end
542
-
543
- # Resume a job.
544
- #
545
- # This method reenables a job after it has been {Google::Cloud::Scheduler::V1::Job::State::PAUSED Job::State::PAUSED}. The
546
- # state of a job is stored in {Google::Cloud::Scheduler::V1::Job#state Job#state}; after calling this method it
547
- # will be set to {Google::Cloud::Scheduler::V1::Job::State::ENABLED Job::State::ENABLED}. A job must be in
548
- # {Google::Cloud::Scheduler::V1::Job::State::PAUSED Job::State::PAUSED} to be resumed.
549
- #
550
- # @param name [String]
551
- # Required. The job name. For example:
552
- # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
553
- # @param options [Google::Gax::CallOptions]
554
- # Overrides the default settings for this call, e.g, timeout,
555
- # retries, etc.
556
- # @yield [result, operation] Access the result along with the RPC operation
557
- # @yieldparam result [Google::Cloud::Scheduler::V1::Job]
558
- # @yieldparam operation [GRPC::ActiveCall::Operation]
559
- # @return [Google::Cloud::Scheduler::V1::Job]
560
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
561
- # @example
562
- # require "google/cloud/scheduler"
563
- #
564
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
565
- # formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
566
- # response = cloud_scheduler_client.resume_job(formatted_name)
567
-
568
- def resume_job \
569
- name,
570
- options: nil,
571
- &block
572
- req = {
573
- name: name
574
- }.delete_if { |_, v| v.nil? }
575
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::ResumeJobRequest)
576
- @resume_job.call(req, options, &block)
577
- end
578
-
579
- # Forces a job to run now.
580
- #
581
- # When this method is called, Cloud Scheduler will dispatch the job, even
582
- # if the job is already running.
583
- #
584
- # @param name [String]
585
- # Required. The job name. For example:
586
- # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
587
- # @param options [Google::Gax::CallOptions]
588
- # Overrides the default settings for this call, e.g, timeout,
589
- # retries, etc.
590
- # @yield [result, operation] Access the result along with the RPC operation
591
- # @yieldparam result [Google::Cloud::Scheduler::V1::Job]
592
- # @yieldparam operation [GRPC::ActiveCall::Operation]
593
- # @return [Google::Cloud::Scheduler::V1::Job]
594
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
595
- # @example
596
- # require "google/cloud/scheduler"
597
- #
598
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
599
- # formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
600
- # response = cloud_scheduler_client.run_job(formatted_name)
601
-
602
- def run_job \
603
- name,
604
- options: nil,
605
- &block
606
- req = {
607
- name: name
608
- }.delete_if { |_, v| v.nil? }
609
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::RunJobRequest)
610
- @run_job.call(req, options, &block)
611
- end
612
- end
613
- end
614
- end
615
- end
616
- end