google-cloud-scheduler 1.2.1 → 2.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -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 ([Alpha](https://github.com/googleapis/google-cloud-ruby#versioning))
26
- #
27
- # [Cloud Scheduler API][Product Documentation]:
28
- # Creates and manages jobs run on a regular recurring schedule.
29
- # - [Product Documentation][]
30
- #
31
- # ## Quick Start
32
- # In order to use this library, you first need to go through the following
33
- # steps:
34
- #
35
- # 1. [Select or create a Cloud Platform project.](https://console.cloud.google.com/project)
36
- # 2. [Enable billing for your project.](https://cloud.google.com/billing/docs/how-to/modify-project#enable_billing_for_a_project)
37
- # 3. [Enable the Cloud Scheduler API.](https://console.cloud.google.com/apis/library/cloudscheduler.googleapis.com)
38
- # 4. [Setup Authentication.](https://googleapis.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,610 +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
- 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.v1beta1.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::V1beta1::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::V1beta1::Job>]
304
- # @yieldparam operation [GRPC::ActiveCall::Operation]
305
- # @return [Google::Gax::PagedEnumerable<Google::Cloud::Scheduler::V1beta1::Job>]
306
- # An enumerable of Google::Cloud::Scheduler::V1beta1::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: :v1beta1)
315
- # formatted_parent = Google::Cloud::Scheduler::V1beta1::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::V1beta1::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::V1beta1::Job]
353
- # @yieldparam operation [GRPC::ActiveCall::Operation]
354
- # @return [Google::Cloud::Scheduler::V1beta1::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: :v1beta1)
360
- # formatted_name = Google::Cloud::Scheduler::V1beta1::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::V1beta1::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::V1beta1::Job | Hash]
380
- # Required. The job to add. The user can optionally specify a name for the
381
- # job in {Google::Cloud::Scheduler::V1beta1::Job#name name}. {Google::Cloud::Scheduler::V1beta1::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::V1beta1::Job#name name}) in the response.
385
- # A hash of the same form as `Google::Cloud::Scheduler::V1beta1::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::V1beta1::Job]
392
- # @yieldparam operation [GRPC::ActiveCall::Operation]
393
- # @return [Google::Cloud::Scheduler::V1beta1::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: :v1beta1)
399
- # formatted_parent = Google::Cloud::Scheduler::V1beta1::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::V1beta1::CreateJobRequest)
415
- @create_job.call(req, options, &block)
416
- end
417
-
418
- # Updates a job.
419
- #
420
- # If successful, the updated {Google::Cloud::Scheduler::V1beta1::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::V1beta1::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::V1beta1::Job | Hash]
429
- # Required. The new job properties. {Google::Cloud::Scheduler::V1beta1::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::V1beta1::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::V1beta1::Job]
444
- # @yieldparam operation [GRPC::ActiveCall::Operation]
445
- # @return [Google::Cloud::Scheduler::V1beta1::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: :v1beta1)
451
- #
452
- # # TODO: Initialize `job`:
453
- # job = {}
454
- # response = cloud_scheduler_client.update_job(job)
455
-
456
- def update_job \
457
- job,
458
- update_mask: nil,
459
- options: nil,
460
- &block
461
- req = {
462
- job: job,
463
- update_mask: update_mask
464
- }.delete_if { |_, v| v.nil? }
465
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1beta1::UpdateJobRequest)
466
- @update_job.call(req, options, &block)
467
- end
468
-
469
- # Deletes a job.
470
- #
471
- # @param name [String]
472
- # Required. The job name. For example:
473
- # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
474
- # @param options [Google::Gax::CallOptions]
475
- # Overrides the default settings for this call, e.g, timeout,
476
- # retries, etc.
477
- # @yield [result, operation] Access the result along with the RPC operation
478
- # @yieldparam result []
479
- # @yieldparam operation [GRPC::ActiveCall::Operation]
480
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
481
- # @example
482
- # require "google/cloud/scheduler"
483
- #
484
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1beta1)
485
- # formatted_name = Google::Cloud::Scheduler::V1beta1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
486
- # cloud_scheduler_client.delete_job(formatted_name)
487
-
488
- def delete_job \
489
- name,
490
- options: nil,
491
- &block
492
- req = {
493
- name: name
494
- }.delete_if { |_, v| v.nil? }
495
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1beta1::DeleteJobRequest)
496
- @delete_job.call(req, options, &block)
497
- nil
498
- end
499
-
500
- # Pauses a job.
501
- #
502
- # If a job is paused then the system will stop executing the job
503
- # until it is re-enabled via {Google::Cloud::Scheduler::V1beta1::CloudScheduler::ResumeJob ResumeJob}. The
504
- # state of the job is stored in {Google::Cloud::Scheduler::V1beta1::Job#state state}; if paused it
505
- # 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}
506
- # to be paused.
507
- #
508
- # @param name [String]
509
- # Required. The job name. For example:
510
- # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
511
- # @param options [Google::Gax::CallOptions]
512
- # Overrides the default settings for this call, e.g, timeout,
513
- # retries, etc.
514
- # @yield [result, operation] Access the result along with the RPC operation
515
- # @yieldparam result [Google::Cloud::Scheduler::V1beta1::Job]
516
- # @yieldparam operation [GRPC::ActiveCall::Operation]
517
- # @return [Google::Cloud::Scheduler::V1beta1::Job]
518
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
519
- # @example
520
- # require "google/cloud/scheduler"
521
- #
522
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1beta1)
523
- # formatted_name = Google::Cloud::Scheduler::V1beta1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
524
- # response = cloud_scheduler_client.pause_job(formatted_name)
525
-
526
- def pause_job \
527
- name,
528
- options: nil,
529
- &block
530
- req = {
531
- name: name
532
- }.delete_if { |_, v| v.nil? }
533
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1beta1::PauseJobRequest)
534
- @pause_job.call(req, options, &block)
535
- end
536
-
537
- # Resume a job.
538
- #
539
- # This method reenables a job after it has been {Google::Cloud::Scheduler::V1beta1::Job::State::PAUSED Job::State::PAUSED}. The
540
- # state of a job is stored in {Google::Cloud::Scheduler::V1beta1::Job#state Job#state}; after calling this method it
541
- # will be set to {Google::Cloud::Scheduler::V1beta1::Job::State::ENABLED Job::State::ENABLED}. A job must be in
542
- # {Google::Cloud::Scheduler::V1beta1::Job::State::PAUSED Job::State::PAUSED} to be resumed.
543
- #
544
- # @param name [String]
545
- # Required. The job name. For example:
546
- # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
547
- # @param options [Google::Gax::CallOptions]
548
- # Overrides the default settings for this call, e.g, timeout,
549
- # retries, etc.
550
- # @yield [result, operation] Access the result along with the RPC operation
551
- # @yieldparam result [Google::Cloud::Scheduler::V1beta1::Job]
552
- # @yieldparam operation [GRPC::ActiveCall::Operation]
553
- # @return [Google::Cloud::Scheduler::V1beta1::Job]
554
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
555
- # @example
556
- # require "google/cloud/scheduler"
557
- #
558
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1beta1)
559
- # formatted_name = Google::Cloud::Scheduler::V1beta1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
560
- # response = cloud_scheduler_client.resume_job(formatted_name)
561
-
562
- def resume_job \
563
- name,
564
- options: nil,
565
- &block
566
- req = {
567
- name: name
568
- }.delete_if { |_, v| v.nil? }
569
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1beta1::ResumeJobRequest)
570
- @resume_job.call(req, options, &block)
571
- end
572
-
573
- # Forces a job to run now.
574
- #
575
- # When this method is called, Cloud Scheduler will dispatch the job, even
576
- # if the job is already running.
577
- #
578
- # @param name [String]
579
- # Required. The job name. For example:
580
- # `projects/PROJECT_ID/locations/LOCATION_ID/jobs/JOB_ID`.
581
- # @param options [Google::Gax::CallOptions]
582
- # Overrides the default settings for this call, e.g, timeout,
583
- # retries, etc.
584
- # @yield [result, operation] Access the result along with the RPC operation
585
- # @yieldparam result [Google::Cloud::Scheduler::V1beta1::Job]
586
- # @yieldparam operation [GRPC::ActiveCall::Operation]
587
- # @return [Google::Cloud::Scheduler::V1beta1::Job]
588
- # @raise [Google::Gax::GaxError] if the RPC is aborted.
589
- # @example
590
- # require "google/cloud/scheduler"
591
- #
592
- # cloud_scheduler_client = Google::Cloud::Scheduler.new(version: :v1beta1)
593
- # formatted_name = Google::Cloud::Scheduler::V1beta1::CloudSchedulerClient.job_path("[PROJECT]", "[LOCATION]", "[JOB]")
594
- # response = cloud_scheduler_client.run_job(formatted_name)
595
-
596
- def run_job \
597
- name,
598
- options: nil,
599
- &block
600
- req = {
601
- name: name
602
- }.delete_if { |_, v| v.nil? }
603
- req = Google::Gax::to_proto(req, Google::Cloud::Scheduler::V1beta1::RunJobRequest)
604
- @run_job.call(req, options, &block)
605
- end
606
- end
607
- end
608
- end
609
- end
610
- end