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
@@ -1,48 +0,0 @@
1
- # Copyright 2018 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
- module Google
16
- module Cloud
17
- module Scheduler
18
- module V1
19
- class CloudSchedulerClient
20
-
21
- # Alias for Google::Cloud::Scheduler::V1::CloudSchedulerClient.job_path.
22
- # @param project [String]
23
- # @param location [String]
24
- # @param job [String]
25
- # @return [String]
26
- def job_path project, location, job
27
- self.class.job_path project, location, job
28
- end
29
-
30
- # Alias for Google::Cloud::Scheduler::V1::CloudSchedulerClient.location_path.
31
- # @param project [String]
32
- # @param location [String]
33
- # @return [String]
34
- def location_path project, location
35
- self.class.location_path project, location
36
- end
37
-
38
- # Alias for Google::Cloud::Scheduler::V1::CloudSchedulerClient.project_path.
39
- # @param project [String]
40
- # @return [String]
41
- def project_path project
42
- self.class.project_path project
43
- end
44
- end
45
- end
46
- end
47
- end
48
- end
@@ -1,58 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: google/cloud/scheduler/v1/job.proto
3
-
4
-
5
- require 'google/protobuf'
6
-
7
- require 'google/api/resource_pb'
8
- require 'google/cloud/scheduler/v1/target_pb'
9
- require 'google/protobuf/duration_pb'
10
- require 'google/protobuf/timestamp_pb'
11
- require 'google/rpc/status_pb'
12
- require 'google/api/annotations_pb'
13
- Google::Protobuf::DescriptorPool.generated_pool.build do
14
- add_message "google.cloud.scheduler.v1.Job" do
15
- optional :name, :string, 1
16
- optional :description, :string, 2
17
- optional :schedule, :string, 20
18
- optional :time_zone, :string, 21
19
- optional :user_update_time, :message, 9, "google.protobuf.Timestamp"
20
- optional :state, :enum, 10, "google.cloud.scheduler.v1.Job.State"
21
- optional :status, :message, 11, "google.rpc.Status"
22
- optional :schedule_time, :message, 17, "google.protobuf.Timestamp"
23
- optional :last_attempt_time, :message, 18, "google.protobuf.Timestamp"
24
- optional :retry_config, :message, 19, "google.cloud.scheduler.v1.RetryConfig"
25
- optional :attempt_deadline, :message, 22, "google.protobuf.Duration"
26
- oneof :target do
27
- optional :pubsub_target, :message, 4, "google.cloud.scheduler.v1.PubsubTarget"
28
- optional :app_engine_http_target, :message, 5, "google.cloud.scheduler.v1.AppEngineHttpTarget"
29
- optional :http_target, :message, 6, "google.cloud.scheduler.v1.HttpTarget"
30
- end
31
- end
32
- add_enum "google.cloud.scheduler.v1.Job.State" do
33
- value :STATE_UNSPECIFIED, 0
34
- value :ENABLED, 1
35
- value :PAUSED, 2
36
- value :DISABLED, 3
37
- value :UPDATE_FAILED, 4
38
- end
39
- add_message "google.cloud.scheduler.v1.RetryConfig" do
40
- optional :retry_count, :int32, 1
41
- optional :max_retry_duration, :message, 2, "google.protobuf.Duration"
42
- optional :min_backoff_duration, :message, 3, "google.protobuf.Duration"
43
- optional :max_backoff_duration, :message, 4, "google.protobuf.Duration"
44
- optional :max_doublings, :int32, 5
45
- end
46
- end
47
-
48
- module Google
49
- module Cloud
50
- module Scheduler
51
- module V1
52
- Job = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.scheduler.v1.Job").msgclass
53
- Job::State = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.scheduler.v1.Job.State").enummodule
54
- RetryConfig = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.scheduler.v1.RetryConfig").msgclass
55
- end
56
- end
57
- end
58
- end
@@ -1,72 +0,0 @@
1
- # Generated by the protocol buffer compiler. DO NOT EDIT!
2
- # source: google/cloud/scheduler/v1/target.proto
3
-
4
-
5
- require 'google/protobuf'
6
-
7
- require 'google/api/resource_pb'
8
- require 'google/api/annotations_pb'
9
- Google::Protobuf::DescriptorPool.generated_pool.build do
10
- add_message "google.cloud.scheduler.v1.HttpTarget" do
11
- optional :uri, :string, 1
12
- optional :http_method, :enum, 2, "google.cloud.scheduler.v1.HttpMethod"
13
- map :headers, :string, :string, 3
14
- optional :body, :bytes, 4
15
- oneof :authorization_header do
16
- optional :oauth_token, :message, 5, "google.cloud.scheduler.v1.OAuthToken"
17
- optional :oidc_token, :message, 6, "google.cloud.scheduler.v1.OidcToken"
18
- end
19
- end
20
- add_message "google.cloud.scheduler.v1.AppEngineHttpTarget" do
21
- optional :http_method, :enum, 1, "google.cloud.scheduler.v1.HttpMethod"
22
- optional :app_engine_routing, :message, 2, "google.cloud.scheduler.v1.AppEngineRouting"
23
- optional :relative_uri, :string, 3
24
- map :headers, :string, :string, 4
25
- optional :body, :bytes, 5
26
- end
27
- add_message "google.cloud.scheduler.v1.PubsubTarget" do
28
- optional :topic_name, :string, 1
29
- optional :data, :bytes, 3
30
- map :attributes, :string, :string, 4
31
- end
32
- add_message "google.cloud.scheduler.v1.AppEngineRouting" do
33
- optional :service, :string, 1
34
- optional :version, :string, 2
35
- optional :instance, :string, 3
36
- optional :host, :string, 4
37
- end
38
- add_message "google.cloud.scheduler.v1.OAuthToken" do
39
- optional :service_account_email, :string, 1
40
- optional :scope, :string, 2
41
- end
42
- add_message "google.cloud.scheduler.v1.OidcToken" do
43
- optional :service_account_email, :string, 1
44
- optional :audience, :string, 2
45
- end
46
- add_enum "google.cloud.scheduler.v1.HttpMethod" do
47
- value :HTTP_METHOD_UNSPECIFIED, 0
48
- value :POST, 1
49
- value :GET, 2
50
- value :HEAD, 3
51
- value :PUT, 4
52
- value :DELETE, 5
53
- value :PATCH, 6
54
- value :OPTIONS, 7
55
- end
56
- end
57
-
58
- module Google
59
- module Cloud
60
- module Scheduler
61
- module V1
62
- HttpTarget = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.scheduler.v1.HttpTarget").msgclass
63
- AppEngineHttpTarget = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.scheduler.v1.AppEngineHttpTarget").msgclass
64
- PubsubTarget = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.scheduler.v1.PubsubTarget").msgclass
65
- AppEngineRouting = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.scheduler.v1.AppEngineRouting").msgclass
66
- OAuthToken = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.scheduler.v1.OAuthToken").msgclass
67
- OidcToken = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.scheduler.v1.OidcToken").msgclass
68
- HttpMethod = Google::Protobuf::DescriptorPool.generated_pool.lookup("google.cloud.scheduler.v1.HttpMethod").enummodule
69
- end
70
- end
71
- end
72
- end
@@ -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/v1beta1/cloud_scheduler_client"
17
- require "google/cloud/scheduler/v1beta1/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 V1beta1
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::V1beta1::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/v1beta1/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/v1beta1/cloudscheduler_pb"
29
- require "google/cloud/scheduler/v1beta1/credentials"
30
- require "google/cloud/scheduler/version"
31
-
32
- module Google
33
- module Cloud
34
- module Scheduler
35
- module V1beta1
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::V1beta1::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/v1beta1/cloudscheduler_services_pb"
160
-
161
- credentials ||= Google::Cloud::Scheduler::V1beta1::Credentials.default
162
-
163
- if credentials.is_a?(String) || credentials.is_a?(Hash)
164
- updater_proc = Google::Cloud::Scheduler::V1beta1::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.v1beta1.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::V1beta1::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::V1beta1::Job>]
307
- # @yieldparam operation [GRPC::ActiveCall::Operation]
308
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Scheduler::V1beta1::Job>]
309
- # An enumerable of Google::Cloud::Scheduler::V1beta1::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: :v1beta1)
318
- # formatted_parent = Google::Cloud::Scheduler::V1beta1::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::V1beta1::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::V1beta1::Job]
356
- # @yieldparam operation [GRPC::ActiveCall::Operation]
357
- # @return [Google::Cloud::Scheduler::V1beta1::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: :v1beta1)
363
- # formatted_name = Google::Cloud::Scheduler::V1beta1::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::V1beta1::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::V1beta1::Job | Hash]
383
- # Required. The job to add. The user can optionally specify a name for the
384
- # job in {Google::Cloud::Scheduler::V1beta1::Job#name name}. {Google::Cloud::Scheduler::V1beta1::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::V1beta1::Job#name name}) in the response.
388
- # A hash of the same form as `Google::Cloud::Scheduler::V1beta1::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::V1beta1::Job]
395
- # @yieldparam operation [GRPC::ActiveCall::Operation]
396
- # @return [Google::Cloud::Scheduler::V1beta1::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: :v1beta1)
402
- # formatted_parent = Google::Cloud::Scheduler::V1beta1::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::V1beta1::CreateJobRequest)
418
- @create_job.call(req, options, &block)
419
- end
420
-
421
- # Updates a job.
422
- #
423
- # If successful, the updated {Google::Cloud::Scheduler::V1beta1::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::V1beta1::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::V1beta1::Job | Hash]
432
- # Required. The new job properties. {Google::Cloud::Scheduler::V1beta1::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::V1beta1::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::V1beta1::Job]
447
- # @yieldparam operation [GRPC::ActiveCall::Operation]
448
- # @return [Google::Cloud::Scheduler::V1beta1::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: :v1beta1)
454
- #
455
- # # TODO: Initialize `job`:
456
- # job = {}
457
- # response = cloud_scheduler_client.update_job(job)
458
-
459
- def update_job \
460
- job,
461
- update_mask: nil,
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::V1beta1::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: :v1beta1)
488
- # formatted_name = Google::Cloud::Scheduler::V1beta1::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::V1beta1::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::V1beta1::CloudScheduler::ResumeJob ResumeJob}. The
507
- # state of the job is stored in {Google::Cloud::Scheduler::V1beta1::Job#state state}; if paused it
508
- # will be set to {Google::Cloud::Scheduler::V1beta1::Job::State::PAUSED Job::State::PAUSED}. A job must be in {Google::Cloud::Scheduler::V1beta1::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::V1beta1::Job]
519
- # @yieldparam operation [GRPC::ActiveCall::Operation]
520
- # @return [Google::Cloud::Scheduler::V1beta1::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: :v1beta1)
526
- # formatted_name = Google::Cloud::Scheduler::V1beta1::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::V1beta1::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::V1beta1::Job::State::PAUSED Job::State::PAUSED}. The
543
- # state of a job is stored in {Google::Cloud::Scheduler::V1beta1::Job#state Job#state}; after calling this method it
544
- # will be set to {Google::Cloud::Scheduler::V1beta1::Job::State::ENABLED Job::State::ENABLED}. A job must be in
545
- # {Google::Cloud::Scheduler::V1beta1::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::V1beta1::Job]
555
- # @yieldparam operation [GRPC::ActiveCall::Operation]
556
- # @return [Google::Cloud::Scheduler::V1beta1::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: :v1beta1)
562
- # formatted_name = Google::Cloud::Scheduler::V1beta1::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::V1beta1::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::V1beta1::Job]
589
- # @yieldparam operation [GRPC::ActiveCall::Operation]
590
- # @return [Google::Cloud::Scheduler::V1beta1::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: :v1beta1)
596
- # formatted_name = Google::Cloud::Scheduler::V1beta1::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::V1beta1::RunJobRequest)
607
- @run_job.call(req, options, &block)
608
- end
609
- end
610
- end
611
- end
612
- end
613
- end