google-cloud-scheduler 1.2.1 → 2.1.1

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 -59
  4. data/LICENSE.md +203 -0
  5. data/MIGRATING.md +321 -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 +88 -117
  9. data/lib/google/cloud/scheduler/version.rb +6 -2
  10. metadata +75 -74
  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 -613
  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 -610
  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 ([GA](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.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,613 +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
- headers.merge!(metadata) unless metadata.nil?
189
- client_config_file = Pathname.new(__dir__).join(
190
- "cloud_scheduler_client_config.json"
191
- )
192
- defaults = client_config_file.open do |f|
193
- Google::Gax.construct_settings(
194
- "google.cloud.scheduler.v1.CloudScheduler",
195
- JSON.parse(f.read),
196
- client_config,
197
- Google::Gax::Grpc::STATUS_CODE_NAMES,
198
- timeout,
199
- page_descriptors: PAGE_DESCRIPTORS,
200
- errors: Google::Gax::Grpc::API_ERRORS,
201
- metadata: headers
202
- )
203
- end
204
-
205
- # Allow overriding the service path/port in subclasses.
206
- service_path = service_address || self.class::SERVICE_ADDRESS
207
- port = service_port || self.class::DEFAULT_SERVICE_PORT
208
- interceptors = self.class::GRPC_INTERCEPTORS
209
- @cloud_scheduler_stub = Google::Gax::Grpc.create_stub(
210
- service_path,
211
- port,
212
- chan_creds: chan_creds,
213
- channel: channel,
214
- updater_proc: updater_proc,
215
- scopes: scopes,
216
- interceptors: interceptors,
217
- &Google::Cloud::Scheduler::V1::CloudScheduler::Stub.method(:new)
218
- )
219
-
220
- @list_jobs = Google::Gax.create_api_call(
221
- @cloud_scheduler_stub.method(:list_jobs),
222
- defaults["list_jobs"],
223
- exception_transformer: exception_transformer,
224
- params_extractor: proc do |request|
225
- {'parent' => request.parent}
226
- end
227
- )
228
- @get_job = Google::Gax.create_api_call(
229
- @cloud_scheduler_stub.method(:get_job),
230
- defaults["get_job"],
231
- exception_transformer: exception_transformer,
232
- params_extractor: proc do |request|
233
- {'name' => request.name}
234
- end
235
- )
236
- @create_job = Google::Gax.create_api_call(
237
- @cloud_scheduler_stub.method(:create_job),
238
- defaults["create_job"],
239
- exception_transformer: exception_transformer,
240
- params_extractor: proc do |request|
241
- {'parent' => request.parent}
242
- end
243
- )
244
- @update_job = Google::Gax.create_api_call(
245
- @cloud_scheduler_stub.method(:update_job),
246
- defaults["update_job"],
247
- exception_transformer: exception_transformer,
248
- params_extractor: proc do |request|
249
- {'job.name' => request.job.name}
250
- end
251
- )
252
- @delete_job = Google::Gax.create_api_call(
253
- @cloud_scheduler_stub.method(:delete_job),
254
- defaults["delete_job"],
255
- exception_transformer: exception_transformer,
256
- params_extractor: proc do |request|
257
- {'name' => request.name}
258
- end
259
- )
260
- @pause_job = Google::Gax.create_api_call(
261
- @cloud_scheduler_stub.method(:pause_job),
262
- defaults["pause_job"],
263
- exception_transformer: exception_transformer,
264
- params_extractor: proc do |request|
265
- {'name' => request.name}
266
- end
267
- )
268
- @resume_job = Google::Gax.create_api_call(
269
- @cloud_scheduler_stub.method(:resume_job),
270
- defaults["resume_job"],
271
- exception_transformer: exception_transformer,
272
- params_extractor: proc do |request|
273
- {'name' => request.name}
274
- end
275
- )
276
- @run_job = Google::Gax.create_api_call(
277
- @cloud_scheduler_stub.method(:run_job),
278
- defaults["run_job"],
279
- exception_transformer: exception_transformer,
280
- params_extractor: proc do |request|
281
- {'name' => request.name}
282
- end
283
- )
284
- end
285
-
286
- # Service calls
287
-
288
- # Lists jobs.
289
- #
290
- # @param parent [String]
291
- # Required. The location name. For example:
292
- # `projects/PROJECT_ID/locations/LOCATION_ID`.
293
- # @param page_size [Integer]
294
- # The maximum number of resources contained in the underlying API
295
- # response. If page streaming is performed per-resource, this
296
- # parameter does not affect the return value. If page streaming is
297
- # performed per-page, this determines the maximum number of
298
- # resources in a page.
299
- # @param options [Google::Gax::CallOptions]
300
- # Overrides the default settings for this call, e.g, timeout,
301
- # retries, etc.
302
- # @yield [result, operation] Access the result along with the RPC operation
303
- # @yieldparam result [Google::Gax::PagedEnumerable<Google::Cloud::Scheduler::V1::Job>]
304
- # @yieldparam operation [GRPC::ActiveCall::Operation]
305
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Scheduler::V1::Job>]
306
- # An enumerable of Google::Cloud::Scheduler::V1::Job instances.
307
- # See Google::Gax::PagedEnumerable documentation for other
308
- # operations such as per-page iteration or access to the response
309
- # object.
310
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
311
- # @example
312
- # require "google/cloud/scheduler"
313
- #
314
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
315
- # formatted_parent = Google::Cloud::Scheduler::V1::CloudSchedulerClient.location_path("[PROJECT]", "[LOCATION]")
316
- #
317
- # # Iterate over all results.
318
- # cloud_scheduler_client.list_jobs(formatted_parent).each do |element|
319
- # # Process element.
320
- # end
321
- #
322
- # # Or iterate over results one page at a time.
323
- # cloud_scheduler_client.list_jobs(formatted_parent).each_page do |page|
324
- # # Process each page at a time.
325
- # page.each do |element|
326
- # # Process element.
327
- # end
328
- # end
329
-
330
- def list_jobs \
331
- parent,
332
- page_size: nil,
333
- options: nil,
334
- &block
335
- req = {
336
- parent: parent,
337
- page_size: page_size
338
- }.delete_if { |_, v| v.nil? }
339
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::ListJobsRequest)
340
- @list_jobs.call(req, options, &block)
341
- end
342
-
343
- # Gets a job.
344
- #
345
- # @param name [String]
346
- # Required. The job name. For example:
347
- # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
348
- # @param options [Google::Gax::CallOptions]
349
- # Overrides the default settings for this call, e.g, timeout,
350
- # retries, etc.
351
- # @yield [result, operation] Access the result along with the RPC operation
352
- # @yieldparam result [Google::Cloud::Scheduler::V1::Job]
353
- # @yieldparam operation [GRPC::ActiveCall::Operation]
354
- # @return [Google::Cloud::Scheduler::V1::Job]
355
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
356
- # @example
357
- # require "google/cloud/scheduler"
358
- #
359
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
360
- # formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
361
- # response = cloud_scheduler_client.get_job(formatted_name)
362
-
363
- def get_job \
364
- name,
365
- options: nil,
366
- &block
367
- req = {
368
- name: name
369
- }.delete_if { |_, v| v.nil? }
370
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::GetJobRequest)
371
- @get_job.call(req, options, &block)
372
- end
373
-
374
- # Creates a job.
375
- #
376
- # @param parent [String]
377
- # Required. The location name. For example:
378
- # `projects/PROJECT_ID/locations/LOCATION_ID`.
379
- # @param job [Google::Cloud::Scheduler::V1::Job | Hash]
380
- # Required. The job to add. The user can optionally specify a name for the
381
- # job in {Google::Cloud::Scheduler::V1::Job#name name}. {Google::Cloud::Scheduler::V1::Job#name name} cannot be the same as an
382
- # existing job. If a name is not specified then the system will
383
- # generate a random unique name that will be returned
384
- # ({Google::Cloud::Scheduler::V1::Job#name name}) in the response.
385
- # A hash of the same form as `Google::Cloud::Scheduler::V1::Job`
386
- # can also be provided.
387
- # @param options [Google::Gax::CallOptions]
388
- # Overrides the default settings for this call, e.g, timeout,
389
- # retries, etc.
390
- # @yield [result, operation] Access the result along with the RPC operation
391
- # @yieldparam result [Google::Cloud::Scheduler::V1::Job]
392
- # @yieldparam operation [GRPC::ActiveCall::Operation]
393
- # @return [Google::Cloud::Scheduler::V1::Job]
394
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
395
- # @example
396
- # require "google/cloud/scheduler"
397
- #
398
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
399
- # formatted_parent = Google::Cloud::Scheduler::V1::CloudSchedulerClient.location_path("[PROJECT]", "[LOCATION]")
400
- #
401
- # # TODO: Initialize `job`:
402
- # job = {}
403
- # response = cloud_scheduler_client.create_job(formatted_parent, job)
404
-
405
- def create_job \
406
- parent,
407
- job,
408
- options: nil,
409
- &block
410
- req = {
411
- parent: parent,
412
- job: job
413
- }.delete_if { |_, v| v.nil? }
414
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::CreateJobRequest)
415
- @create_job.call(req, options, &block)
416
- end
417
-
418
- # Updates a job.
419
- #
420
- # If successful, the updated {Google::Cloud::Scheduler::V1::Job Job} is returned. If the job does
421
- # not exist, `NOT_FOUND` is returned.
422
- #
423
- # If UpdateJob does not successfully return, it is possible for the
424
- # job to be in an {Google::Cloud::Scheduler::V1::Job::State::UPDATE_FAILED Job::State::UPDATE_FAILED} state. A job in this state may
425
- # not be executed. If this happens, retry the UpdateJob request
426
- # until a successful response is received.
427
- #
428
- # @param job [Google::Cloud::Scheduler::V1::Job | Hash]
429
- # Required. The new job properties. {Google::Cloud::Scheduler::V1::Job#name name} must be specified.
430
- #
431
- # Output only fields cannot be modified using UpdateJob.
432
- # Any value specified for an output only field will be ignored.
433
- # A hash of the same form as `Google::Cloud::Scheduler::V1::Job`
434
- # can also be provided.
435
- # @param update_mask [Google::Protobuf::FieldMask | Hash]
436
- # A mask used to specify which fields of the job are being updated.
437
- # A hash of the same form as `Google::Protobuf::FieldMask`
438
- # can also be provided.
439
- # @param options [Google::Gax::CallOptions]
440
- # Overrides the default settings for this call, e.g, timeout,
441
- # retries, etc.
442
- # @yield [result, operation] Access the result along with the RPC operation
443
- # @yieldparam result [Google::Cloud::Scheduler::V1::Job]
444
- # @yieldparam operation [GRPC::ActiveCall::Operation]
445
- # @return [Google::Cloud::Scheduler::V1::Job]
446
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
447
- # @example
448
- # require "google/cloud/scheduler"
449
- #
450
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
451
- #
452
- # # TODO: Initialize `job`:
453
- # job = {}
454
- #
455
- # # TODO: Initialize `update_mask`:
456
- # update_mask = {}
457
- # response = cloud_scheduler_client.update_job(job, update_mask)
458
-
459
- def update_job \
460
- job,
461
- update_mask,
462
- options: nil,
463
- &block
464
- req = {
465
- job: job,
466
- update_mask: update_mask
467
- }.delete_if { |_, v| v.nil? }
468
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::UpdateJobRequest)
469
- @update_job.call(req, options, &block)
470
- end
471
-
472
- # Deletes a job.
473
- #
474
- # @param name [String]
475
- # Required. The job name. For example:
476
- # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
477
- # @param options [Google::Gax::CallOptions]
478
- # Overrides the default settings for this call, e.g, timeout,
479
- # retries, etc.
480
- # @yield [result, operation] Access the result along with the RPC operation
481
- # @yieldparam result []
482
- # @yieldparam operation [GRPC::ActiveCall::Operation]
483
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
484
- # @example
485
- # require "google/cloud/scheduler"
486
- #
487
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
488
- # formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
489
- # cloud_scheduler_client.delete_job(formatted_name)
490
-
491
- def delete_job \
492
- name,
493
- options: nil,
494
- &block
495
- req = {
496
- name: name
497
- }.delete_if { |_, v| v.nil? }
498
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::DeleteJobRequest)
499
- @delete_job.call(req, options, &block)
500
- nil
501
- end
502
-
503
- # Pauses a job.
504
- #
505
- # If a job is paused then the system will stop executing the job
506
- # until it is re-enabled via {Google::Cloud::Scheduler::V1::CloudScheduler::ResumeJob ResumeJob}. The
507
- # state of the job is stored in {Google::Cloud::Scheduler::V1::Job#state state}; if paused it
508
- # 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}
509
- # to be paused.
510
- #
511
- # @param name [String]
512
- # Required. The job name. For example:
513
- # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
514
- # @param options [Google::Gax::CallOptions]
515
- # Overrides the default settings for this call, e.g, timeout,
516
- # retries, etc.
517
- # @yield [result, operation] Access the result along with the RPC operation
518
- # @yieldparam result [Google::Cloud::Scheduler::V1::Job]
519
- # @yieldparam operation [GRPC::ActiveCall::Operation]
520
- # @return [Google::Cloud::Scheduler::V1::Job]
521
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
522
- # @example
523
- # require "google/cloud/scheduler"
524
- #
525
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
526
- # formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
527
- # response = cloud_scheduler_client.pause_job(formatted_name)
528
-
529
- def pause_job \
530
- name,
531
- options: nil,
532
- &block
533
- req = {
534
- name: name
535
- }.delete_if { |_, v| v.nil? }
536
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::PauseJobRequest)
537
- @pause_job.call(req, options, &block)
538
- end
539
-
540
- # Resume a job.
541
- #
542
- # This method reenables a job after it has been {Google::Cloud::Scheduler::V1::Job::State::PAUSED Job::State::PAUSED}. The
543
- # state of a job is stored in {Google::Cloud::Scheduler::V1::Job#state Job#state}; after calling this method it
544
- # will be set to {Google::Cloud::Scheduler::V1::Job::State::ENABLED Job::State::ENABLED}. A job must be in
545
- # {Google::Cloud::Scheduler::V1::Job::State::PAUSED Job::State::PAUSED} to be resumed.
546
- #
547
- # @param name [String]
548
- # Required. The job name. For example:
549
- # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
550
- # @param options [Google::Gax::CallOptions]
551
- # Overrides the default settings for this call, e.g, timeout,
552
- # retries, etc.
553
- # @yield [result, operation] Access the result along with the RPC operation
554
- # @yieldparam result [Google::Cloud::Scheduler::V1::Job]
555
- # @yieldparam operation [GRPC::ActiveCall::Operation]
556
- # @return [Google::Cloud::Scheduler::V1::Job]
557
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
558
- # @example
559
- # require "google/cloud/scheduler"
560
- #
561
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
562
- # formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
563
- # response = cloud_scheduler_client.resume_job(formatted_name)
564
-
565
- def resume_job \
566
- name,
567
- options: nil,
568
- &block
569
- req = {
570
- name: name
571
- }.delete_if { |_, v| v.nil? }
572
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::ResumeJobRequest)
573
- @resume_job.call(req, options, &block)
574
- end
575
-
576
- # Forces a job to run now.
577
- #
578
- # When this method is called, Cloud Scheduler will dispatch the job, even
579
- # if the job is already running.
580
- #
581
- # @param name [String]
582
- # Required. The job name. For example:
583
- # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
584
- # @param options [Google::Gax::CallOptions]
585
- # Overrides the default settings for this call, e.g, timeout,
586
- # retries, etc.
587
- # @yield [result, operation] Access the result along with the RPC operation
588
- # @yieldparam result [Google::Cloud::Scheduler::V1::Job]
589
- # @yieldparam operation [GRPC::ActiveCall::Operation]
590
- # @return [Google::Cloud::Scheduler::V1::Job]
591
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
592
- # @example
593
- # require "google/cloud/scheduler"
594
- #
595
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1)
596
- # formatted_name = Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
597
- # response = cloud_scheduler_client.run_job(formatted_name)
598
-
599
- def run_job \
600
- name,
601
- options: nil,
602
- &block
603
- req = {
604
- name: name
605
- }.delete_if { |_, v| v.nil? }
606
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1::RunJobRequest)
607
- @run_job.call(req, options, &block)
608
- end
609
- end
610
- end
611
- end
612
- end
613
- end