gcloud 0.12.2 → 0.20.0
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.
- checksums.yaml +5 -13
- data/lib/gcloud.rb +27 -456
- data/lib/gcloud/bigquery.rb +2 -382
- data/lib/gcloud/datastore.rb +2 -576
- data/lib/gcloud/dns.rb +2 -321
- data/lib/gcloud/logging.rb +1 -322
- data/lib/gcloud/pubsub.rb +2 -476
- data/lib/gcloud/resource_manager.rb +2 -273
- data/lib/gcloud/storage.rb +2 -440
- data/lib/gcloud/translate.rb +1 -250
- data/lib/gcloud/version.rb +2 -2
- data/lib/gcloud/vision.rb +1 -501
- metadata +36 -332
- data/AUTHENTICATION.md +0 -75
- data/CHANGELOG.md +0 -382
- data/OVERVIEW.md +0 -259
- data/lib/gcloud/backoff.rb +0 -150
- data/lib/gcloud/bigquery/copy_job.rb +0 -97
- data/lib/gcloud/bigquery/credentials.rb +0 -29
- data/lib/gcloud/bigquery/data.rb +0 -239
- data/lib/gcloud/bigquery/dataset.rb +0 -753
- data/lib/gcloud/bigquery/dataset/access.rb +0 -507
- data/lib/gcloud/bigquery/dataset/list.rb +0 -169
- data/lib/gcloud/bigquery/extract_job.rb +0 -117
- data/lib/gcloud/bigquery/insert_response.rb +0 -81
- data/lib/gcloud/bigquery/job.rb +0 -299
- data/lib/gcloud/bigquery/job/list.rb +0 -172
- data/lib/gcloud/bigquery/load_job.rb +0 -202
- data/lib/gcloud/bigquery/project.rb +0 -475
- data/lib/gcloud/bigquery/query_data.rb +0 -234
- data/lib/gcloud/bigquery/query_job.rb +0 -137
- data/lib/gcloud/bigquery/schema.rb +0 -359
- data/lib/gcloud/bigquery/service.rb +0 -506
- data/lib/gcloud/bigquery/table.rb +0 -1141
- data/lib/gcloud/bigquery/table/list.rb +0 -180
- data/lib/gcloud/bigquery/view.rb +0 -475
- data/lib/gcloud/credentials.rb +0 -129
- data/lib/gcloud/datastore/commit.rb +0 -148
- data/lib/gcloud/datastore/credentials.rb +0 -35
- data/lib/gcloud/datastore/cursor.rb +0 -76
- data/lib/gcloud/datastore/dataset.rb +0 -660
- data/lib/gcloud/datastore/dataset/lookup_results.rb +0 -219
- data/lib/gcloud/datastore/dataset/query_results.rb +0 -386
- data/lib/gcloud/datastore/entity.rb +0 -449
- data/lib/gcloud/datastore/errors.rb +0 -41
- data/lib/gcloud/datastore/gql_query.rb +0 -211
- data/lib/gcloud/datastore/grpc_utils.rb +0 -132
- data/lib/gcloud/datastore/key.rb +0 -281
- data/lib/gcloud/datastore/properties.rb +0 -128
- data/lib/gcloud/datastore/query.rb +0 -348
- data/lib/gcloud/datastore/service.rb +0 -167
- data/lib/gcloud/datastore/transaction.rb +0 -362
- data/lib/gcloud/dns/change.rb +0 -158
- data/lib/gcloud/dns/change/list.rb +0 -173
- data/lib/gcloud/dns/credentials.rb +0 -29
- data/lib/gcloud/dns/importer.rb +0 -183
- data/lib/gcloud/dns/project.rb +0 -247
- data/lib/gcloud/dns/record.rb +0 -170
- data/lib/gcloud/dns/record/list.rb +0 -174
- data/lib/gcloud/dns/service.rb +0 -167
- data/lib/gcloud/dns/zone.rb +0 -759
- data/lib/gcloud/dns/zone/list.rb +0 -168
- data/lib/gcloud/dns/zone/transaction.rb +0 -176
- data/lib/gcloud/errors.rb +0 -206
- data/lib/gcloud/gce.rb +0 -56
- data/lib/gcloud/grpc_utils.rb +0 -87
- data/lib/gcloud/logging/credentials.rb +0 -29
- data/lib/gcloud/logging/entry.rb +0 -465
- data/lib/gcloud/logging/entry/http_request.rb +0 -141
- data/lib/gcloud/logging/entry/list.rb +0 -177
- data/lib/gcloud/logging/entry/operation.rb +0 -90
- data/lib/gcloud/logging/logger.rb +0 -307
- data/lib/gcloud/logging/metric.rb +0 -169
- data/lib/gcloud/logging/metric/list.rb +0 -172
- data/lib/gcloud/logging/project.rb +0 -642
- data/lib/gcloud/logging/resource.rb +0 -84
- data/lib/gcloud/logging/resource_descriptor.rb +0 -137
- data/lib/gcloud/logging/resource_descriptor/list.rb +0 -174
- data/lib/gcloud/logging/service.rb +0 -267
- data/lib/gcloud/logging/sink.rb +0 -227
- data/lib/gcloud/logging/sink/list.rb +0 -171
- data/lib/gcloud/pubsub/credentials.rb +0 -29
- data/lib/gcloud/pubsub/message.rb +0 -94
- data/lib/gcloud/pubsub/policy.rb +0 -204
- data/lib/gcloud/pubsub/project.rb +0 -482
- data/lib/gcloud/pubsub/received_message.rb +0 -160
- data/lib/gcloud/pubsub/service.rb +0 -334
- data/lib/gcloud/pubsub/subscription.rb +0 -565
- data/lib/gcloud/pubsub/subscription/list.rb +0 -208
- data/lib/gcloud/pubsub/topic.rb +0 -511
- data/lib/gcloud/pubsub/topic/list.rb +0 -174
- data/lib/gcloud/pubsub/topic/publisher.rb +0 -85
- data/lib/gcloud/resource_manager/credentials.rb +0 -30
- data/lib/gcloud/resource_manager/manager.rb +0 -266
- data/lib/gcloud/resource_manager/policy.rb +0 -211
- data/lib/gcloud/resource_manager/project.rb +0 -484
- data/lib/gcloud/resource_manager/project/list.rb +0 -167
- data/lib/gcloud/resource_manager/project/updater.rb +0 -130
- data/lib/gcloud/resource_manager/service.rb +0 -127
- data/lib/gcloud/storage/bucket.rb +0 -775
- data/lib/gcloud/storage/bucket/acl.rb +0 -810
- data/lib/gcloud/storage/bucket/cors.rb +0 -153
- data/lib/gcloud/storage/bucket/list.rb +0 -172
- data/lib/gcloud/storage/credentials.rb +0 -29
- data/lib/gcloud/storage/errors.rb +0 -65
- data/lib/gcloud/storage/file.rb +0 -842
- data/lib/gcloud/storage/file/acl.rb +0 -425
- data/lib/gcloud/storage/file/list.rb +0 -191
- data/lib/gcloud/storage/file/verifier.rb +0 -67
- data/lib/gcloud/storage/project.rb +0 -316
- data/lib/gcloud/storage/service.rb +0 -347
- data/lib/gcloud/translate/api.rb +0 -241
- data/lib/gcloud/translate/detection.rb +0 -137
- data/lib/gcloud/translate/language.rb +0 -69
- data/lib/gcloud/translate/service.rb +0 -80
- data/lib/gcloud/translate/translation.rb +0 -112
- data/lib/gcloud/vision/annotate.rb +0 -224
- data/lib/gcloud/vision/annotation.rb +0 -455
- data/lib/gcloud/vision/annotation/entity.rb +0 -234
- data/lib/gcloud/vision/annotation/face.rb +0 -1750
- data/lib/gcloud/vision/annotation/properties.rb +0 -245
- data/lib/gcloud/vision/annotation/safe_search.rb +0 -161
- data/lib/gcloud/vision/annotation/text.rb +0 -236
- data/lib/gcloud/vision/annotation/vertex.rb +0 -108
- data/lib/gcloud/vision/credentials.rb +0 -29
- data/lib/gcloud/vision/image.rb +0 -590
- data/lib/gcloud/vision/location.rb +0 -115
- data/lib/gcloud/vision/project.rb +0 -278
- data/lib/gcloud/vision/service.rb +0 -66
- data/lib/google/api/annotations.rb +0 -14
- data/lib/google/api/http.rb +0 -30
- data/lib/google/api/label.rb +0 -24
- data/lib/google/api/monitored_resource.rb +0 -25
- data/lib/google/datastore/v1beta3/datastore.rb +0 -115
- data/lib/google/datastore/v1beta3/datastore_services.rb +0 -33
- data/lib/google/datastore/v1beta3/entity.rb +0 -63
- data/lib/google/datastore/v1beta3/query.rb +0 -128
- data/lib/google/devtools/cloudtrace/v1/trace.rb +0 -78
- data/lib/google/devtools/cloudtrace/v1/trace_services.rb +0 -32
- data/lib/google/example/library/v1/library.rb +0 -91
- data/lib/google/example/library/v1/library_services.rb +0 -40
- data/lib/google/iam/v1/iam_policy.rb +0 -33
- data/lib/google/iam/v1/iam_policy_services.rb +0 -30
- data/lib/google/iam/v1/policy.rb +0 -25
- data/lib/google/logging/type/http_request.rb +0 -28
- data/lib/google/logging/type/log_severity.rb +0 -27
- data/lib/google/logging/v2/log_entry.rb +0 -44
- data/lib/google/logging/v2/logging.rb +0 -56
- data/lib/google/logging/v2/logging_config.rb +0 -59
- data/lib/google/logging/v2/logging_config_services.rb +0 -32
- data/lib/google/logging/v2/logging_metrics.rb +0 -51
- data/lib/google/logging/v2/logging_metrics_services.rb +0 -32
- data/lib/google/logging/v2/logging_services.rb +0 -31
- data/lib/google/longrunning/operations.rb +0 -50
- data/lib/google/longrunning/operations_services.rb +0 -29
- data/lib/google/protobuf/descriptor.rb +0 -0
- data/lib/google/pubsub/v1/pubsub.rb +0 -129
- data/lib/google/pubsub/v1/pubsub_services.rb +0 -56
- data/lib/google/pubsub/v1beta2/pubsub.rb +0 -126
- data/lib/google/pubsub/v1beta2/pubsub_services.rb +0 -56
- data/lib/google/rpc/code.rb +0 -32
- data/lib/google/rpc/error_details.rb +0 -61
- data/lib/google/rpc/status.rb +0 -19
- data/lib/google/type/color.rb +0 -20
- data/lib/google/type/date.rb +0 -18
- data/lib/google/type/dayofweek.rb +0 -23
- data/lib/google/type/latlng.rb +0 -17
- data/lib/google/type/money.rb +0 -18
- data/lib/google/type/timeofday.rb +0 -19
data/lib/gcloud/logging/sink.rb
DELETED
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
# Copyright 2016 Google Inc. All rights reserved.
|
|
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
|
-
# http://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 "gcloud/logging/sink/list"
|
|
17
|
-
|
|
18
|
-
module Gcloud
|
|
19
|
-
module Logging
|
|
20
|
-
##
|
|
21
|
-
# # Sink
|
|
22
|
-
#
|
|
23
|
-
# Used to export log entries outside Stackdriver Logging. When you create a
|
|
24
|
-
# sink, new log entries are exported. Stackdriver Logging does not send
|
|
25
|
-
# previously-ingested log entries to the sink's destination.
|
|
26
|
-
#
|
|
27
|
-
# Before creating the sink, ensure that you have granted
|
|
28
|
-
# `cloud-logs@google.com` permission to write logs to the destination. See
|
|
29
|
-
# [Permissions for writing exported
|
|
30
|
-
# logs](https://cloud.google.com/logging/docs/export/configure_export#setting_product_name_short_permissions_for_writing_exported_logs).
|
|
31
|
-
#
|
|
32
|
-
# You can retrieve an existing sink with {Project#sink}.
|
|
33
|
-
#
|
|
34
|
-
# @see https://cloud.google.com/logging/docs/api/tasks/exporting-logs
|
|
35
|
-
# Exporting Logs With Sinks
|
|
36
|
-
# @see https://cloud.google.com/logging/docs/api/introduction_v2#kinds_of_log_sinks
|
|
37
|
-
# Kinds of log sinks (API V2)
|
|
38
|
-
# @see https://cloud.google.com/logging/docs/api/#sinks Sinks (API V1)
|
|
39
|
-
# @see https://cloud.google.com/logging/docs/export/configure_export#setting_product_name_short_permissions_for_writing_exported_logs
|
|
40
|
-
# Permissions for writing exported logs
|
|
41
|
-
#
|
|
42
|
-
# @example
|
|
43
|
-
# require "gcloud"
|
|
44
|
-
#
|
|
45
|
-
# gcloud = Gcloud.new
|
|
46
|
-
# logging = gcloud.logging
|
|
47
|
-
# storage = gcloud.storage
|
|
48
|
-
#
|
|
49
|
-
# bucket = storage.create_bucket "my-logs-bucket"
|
|
50
|
-
#
|
|
51
|
-
# # Grant owner permission to Stackdriver Logging service
|
|
52
|
-
# email = "cloud-logs@google.com"
|
|
53
|
-
# bucket.acl.add_owner "group-#{email}"
|
|
54
|
-
#
|
|
55
|
-
# sink = logging.create_sink "my-sink",
|
|
56
|
-
# "storage.googleapis.com/#{bucket.id}"
|
|
57
|
-
#
|
|
58
|
-
class Sink
|
|
59
|
-
##
|
|
60
|
-
# @private The gRPC Service object.
|
|
61
|
-
attr_accessor :service
|
|
62
|
-
|
|
63
|
-
##
|
|
64
|
-
# @private The Google API Client object.
|
|
65
|
-
attr_accessor :grpc
|
|
66
|
-
|
|
67
|
-
##
|
|
68
|
-
# @private Create an empty Sink object.
|
|
69
|
-
def initialize
|
|
70
|
-
@service = nil
|
|
71
|
-
@grpc = Google::Logging::V2::LogSink.new
|
|
72
|
-
end
|
|
73
|
-
|
|
74
|
-
##
|
|
75
|
-
# The client-assigned sink identifier. Sink identifiers are limited to
|
|
76
|
-
# 1000 characters and can include only the following characters: `A-Z`,
|
|
77
|
-
# `a-z`, `0-9`, and the special characters `_-.`.
|
|
78
|
-
def name
|
|
79
|
-
@grpc.name
|
|
80
|
-
end
|
|
81
|
-
|
|
82
|
-
##
|
|
83
|
-
# The export destination. See [Exporting Logs With
|
|
84
|
-
# Sinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs).
|
|
85
|
-
def destination
|
|
86
|
-
@grpc.destination
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
##
|
|
90
|
-
# Updates the export destination. See [Exporting Logs With
|
|
91
|
-
# Sinks](https://cloud.google.com/logging/docs/api/tasks/exporting-logs).
|
|
92
|
-
def destination= destination
|
|
93
|
-
@grpc.destination = destination
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
##
|
|
97
|
-
# An [advanced logs
|
|
98
|
-
# filter](https://cloud.google.com/logging/docs/view/advanced_filters)
|
|
99
|
-
# that defines the log entries to be exported. The filter must be
|
|
100
|
-
# consistent with the log entry format designed by the `version`
|
|
101
|
-
# parameter, regardless of the format of the log entry that was originally
|
|
102
|
-
# written to Stackdriver Logging.
|
|
103
|
-
def filter
|
|
104
|
-
@grpc.filter
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
##
|
|
108
|
-
# Updates the [advanced logs
|
|
109
|
-
# filter](https://cloud.google.com/logging/docs/view/advanced_filters)
|
|
110
|
-
# that defines the log entries to be exported. The filter must be
|
|
111
|
-
# consistent with the log entry format designed by the `version`
|
|
112
|
-
# parameter, regardless of the format of the log entry that was originally
|
|
113
|
-
# written to Stackdriver Logging.
|
|
114
|
-
def filter= filter
|
|
115
|
-
@grpc.filter = filter
|
|
116
|
-
end
|
|
117
|
-
|
|
118
|
-
##
|
|
119
|
-
# The log entry version used when exporting log entries from this sink.
|
|
120
|
-
# This version does not have to correspond to the version of the log entry
|
|
121
|
-
# when it was written to Stackdriver Logging.
|
|
122
|
-
def version
|
|
123
|
-
@grpc.output_version_format
|
|
124
|
-
end
|
|
125
|
-
|
|
126
|
-
##
|
|
127
|
-
# Updates the log entry version used when exporting log entries from this
|
|
128
|
-
# sink. This version does not have to correspond to the version of the log
|
|
129
|
-
# entry when it was written to Stackdriver Logging. Accepted values are
|
|
130
|
-
# `:VERSION_FORMAT_UNSPECIFIED`, `:V2`, and `:V1`.
|
|
131
|
-
def version= version
|
|
132
|
-
@grpc.output_version_format = self.class.resolve_version(version)
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
##
|
|
136
|
-
# Helper to determine if the sink's version is
|
|
137
|
-
# `VERSION_FORMAT_UNSPECIFIED`.
|
|
138
|
-
def unspecified?
|
|
139
|
-
!(v1? || v2?)
|
|
140
|
-
end
|
|
141
|
-
|
|
142
|
-
##
|
|
143
|
-
# Helper to determine if the sink's version is `V2`.
|
|
144
|
-
def v2?
|
|
145
|
-
version == :V2
|
|
146
|
-
end
|
|
147
|
-
|
|
148
|
-
##
|
|
149
|
-
# Helper to determine if the sink's version is `V1`.
|
|
150
|
-
def v1?
|
|
151
|
-
version == :V1
|
|
152
|
-
end
|
|
153
|
-
|
|
154
|
-
##
|
|
155
|
-
# Updates the logs-based sink.
|
|
156
|
-
#
|
|
157
|
-
# @example
|
|
158
|
-
# require "gcloud"
|
|
159
|
-
#
|
|
160
|
-
# gcloud = Gcloud.new
|
|
161
|
-
# logging = gcloud.logging
|
|
162
|
-
# sink = logging.sink "severe_errors"
|
|
163
|
-
# sink.filter = "logName:syslog AND severity>=ERROR"
|
|
164
|
-
# sink.save
|
|
165
|
-
#
|
|
166
|
-
def save
|
|
167
|
-
ensure_service!
|
|
168
|
-
@grpc = service.update_sink name, destination, filter, version
|
|
169
|
-
end
|
|
170
|
-
|
|
171
|
-
##
|
|
172
|
-
# Reloads the logs-based sink with current data from the Logging
|
|
173
|
-
# service.
|
|
174
|
-
def reload!
|
|
175
|
-
ensure_service!
|
|
176
|
-
@grpc = service.get_sink name
|
|
177
|
-
end
|
|
178
|
-
alias_method :refresh!, :reload!
|
|
179
|
-
|
|
180
|
-
##
|
|
181
|
-
# Permanently deletes the logs-based sink.
|
|
182
|
-
#
|
|
183
|
-
# @return [Boolean] Returns `true` if the sink was deleted.
|
|
184
|
-
#
|
|
185
|
-
# @example
|
|
186
|
-
# require "gcloud"
|
|
187
|
-
#
|
|
188
|
-
# gcloud = Gcloud.new
|
|
189
|
-
# logging = gcloud.logging
|
|
190
|
-
# sink = logging.sink "severe_errors"
|
|
191
|
-
# sink.delete
|
|
192
|
-
#
|
|
193
|
-
def delete
|
|
194
|
-
ensure_service!
|
|
195
|
-
service.delete_sink name
|
|
196
|
-
true
|
|
197
|
-
end
|
|
198
|
-
|
|
199
|
-
##
|
|
200
|
-
# @private New Sink from a Google::Logging::V2::LogSink object.
|
|
201
|
-
def self.from_grpc grpc, service
|
|
202
|
-
new.tap do |f|
|
|
203
|
-
f.grpc = grpc
|
|
204
|
-
f.service = service
|
|
205
|
-
end
|
|
206
|
-
end
|
|
207
|
-
|
|
208
|
-
##
|
|
209
|
-
# @private Convert a version value to the gRPC enum value.
|
|
210
|
-
def self.resolve_version version
|
|
211
|
-
ver = version.to_s.upcase.to_sym
|
|
212
|
-
ver = Google::Logging::V2::LogSink::VersionFormat.resolve ver
|
|
213
|
-
return ver if ver
|
|
214
|
-
Google::Logging::V2::LogSink::VersionFormat::VERSION_FORMAT_UNSPECIFIED
|
|
215
|
-
end
|
|
216
|
-
|
|
217
|
-
protected
|
|
218
|
-
|
|
219
|
-
##
|
|
220
|
-
# @private Raise an error unless an active connection to the service is
|
|
221
|
-
# available.
|
|
222
|
-
def ensure_service!
|
|
223
|
-
fail "Must have active connection to service" unless service
|
|
224
|
-
end
|
|
225
|
-
end
|
|
226
|
-
end
|
|
227
|
-
end
|
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
# Copyright 2016 Google Inc. All rights reserved.
|
|
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
|
-
# http://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 "delegate"
|
|
17
|
-
|
|
18
|
-
module Gcloud
|
|
19
|
-
module Logging
|
|
20
|
-
class Sink
|
|
21
|
-
##
|
|
22
|
-
# Sink::List is a special case Array with additional values.
|
|
23
|
-
class List < DelegateClass(::Array)
|
|
24
|
-
##
|
|
25
|
-
# If not empty, indicates that there are more records that match
|
|
26
|
-
# the request and this value should be passed to continue.
|
|
27
|
-
attr_accessor :token
|
|
28
|
-
|
|
29
|
-
##
|
|
30
|
-
# @private Create a new Sink::List with an array of Sink instances.
|
|
31
|
-
def initialize arr = []
|
|
32
|
-
super arr
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
##
|
|
36
|
-
# Whether there is a next page of sinks.
|
|
37
|
-
#
|
|
38
|
-
# @return [Boolean]
|
|
39
|
-
#
|
|
40
|
-
# @example
|
|
41
|
-
# require "gcloud"
|
|
42
|
-
#
|
|
43
|
-
# gcloud = Gcloud.new
|
|
44
|
-
# logging = gcloud.logging
|
|
45
|
-
#
|
|
46
|
-
# sinks = logging.sinks
|
|
47
|
-
# if sinks.next?
|
|
48
|
-
# next_sinks = sinks.next
|
|
49
|
-
# end
|
|
50
|
-
#
|
|
51
|
-
def next?
|
|
52
|
-
!token.nil?
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
##
|
|
56
|
-
# Retrieve the next page of sinks.
|
|
57
|
-
#
|
|
58
|
-
# @return [Sink::List]
|
|
59
|
-
#
|
|
60
|
-
# @example
|
|
61
|
-
# require "gcloud"
|
|
62
|
-
#
|
|
63
|
-
# gcloud = Gcloud.new
|
|
64
|
-
# logging = gcloud.logging
|
|
65
|
-
#
|
|
66
|
-
# sinks = dataset.sinks
|
|
67
|
-
# if sinks.next?
|
|
68
|
-
# next_sinks = sinks.next
|
|
69
|
-
# end
|
|
70
|
-
#
|
|
71
|
-
def next
|
|
72
|
-
return nil unless next?
|
|
73
|
-
ensure_service!
|
|
74
|
-
list_grpc = @service.list_sinks token: token, max: @max
|
|
75
|
-
self.class.from_grpc list_grpc, @service
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
##
|
|
79
|
-
# Retrieves all sinks by repeatedly loading {#next} until {#next?}
|
|
80
|
-
# returns `false`. Calls the given block once for each sink, which is
|
|
81
|
-
# passed as the parameter.
|
|
82
|
-
#
|
|
83
|
-
# An Enumerator is returned if no block is given.
|
|
84
|
-
#
|
|
85
|
-
# This method may make several API calls until all sinks are retrieved.
|
|
86
|
-
# Be sure to use as narrow a search criteria as possible. Please use
|
|
87
|
-
# with caution.
|
|
88
|
-
#
|
|
89
|
-
# @param [Integer] request_limit The upper limit of API requests to make
|
|
90
|
-
# to load all sinks. Default is no limit.
|
|
91
|
-
# @yield [sink] The block for accessing each sink.
|
|
92
|
-
# @yieldparam [Sink] sink The sink object.
|
|
93
|
-
#
|
|
94
|
-
# @return [Enumerator]
|
|
95
|
-
#
|
|
96
|
-
# @example Iterating each sink by passing a block:
|
|
97
|
-
# require "gcloud"
|
|
98
|
-
#
|
|
99
|
-
# gcloud = Gcloud.new
|
|
100
|
-
# logging = gcloud.logging
|
|
101
|
-
# sinks = logging.sinks
|
|
102
|
-
#
|
|
103
|
-
# sinks.all do |sink|
|
|
104
|
-
# puts "#{sink.name}: #{sink.filter} -> #{sink.destination}"
|
|
105
|
-
# end
|
|
106
|
-
#
|
|
107
|
-
# @example Using the enumerator by not passing a block:
|
|
108
|
-
# require "gcloud"
|
|
109
|
-
#
|
|
110
|
-
# gcloud = Gcloud.new
|
|
111
|
-
# logging = gcloud.logging
|
|
112
|
-
# sinks = logging.sinks
|
|
113
|
-
#
|
|
114
|
-
# all_names = sinks.all.map do |sink|
|
|
115
|
-
# sink.name
|
|
116
|
-
# end
|
|
117
|
-
#
|
|
118
|
-
# @example Limit the number of API calls made:
|
|
119
|
-
# require "gcloud"
|
|
120
|
-
#
|
|
121
|
-
# gcloud = Gcloud.new
|
|
122
|
-
# logging = gcloud.logging
|
|
123
|
-
# sinks = logging.sinks
|
|
124
|
-
#
|
|
125
|
-
# sinks.all(request_limit: 10) do |sink|
|
|
126
|
-
# puts "#{sink.name}: #{sink.filter} -> #{sink.destination}"
|
|
127
|
-
# end
|
|
128
|
-
#
|
|
129
|
-
def all request_limit: nil
|
|
130
|
-
request_limit = request_limit.to_i if request_limit
|
|
131
|
-
unless block_given?
|
|
132
|
-
return enum_for(:all, request_limit: request_limit)
|
|
133
|
-
end
|
|
134
|
-
results = self
|
|
135
|
-
loop do
|
|
136
|
-
results.each { |r| yield r }
|
|
137
|
-
if request_limit
|
|
138
|
-
request_limit -= 1
|
|
139
|
-
break if request_limit < 0
|
|
140
|
-
end
|
|
141
|
-
break unless results.next?
|
|
142
|
-
results = results.next
|
|
143
|
-
end
|
|
144
|
-
end
|
|
145
|
-
|
|
146
|
-
##
|
|
147
|
-
# @private New Sink::List from a Google::Logging::V2::ListSinksResponse
|
|
148
|
-
# object.
|
|
149
|
-
def self.from_grpc grpc_list, service, max = nil
|
|
150
|
-
sinks = new(Array(grpc_list.sinks).map do |grpc|
|
|
151
|
-
Sink.from_grpc grpc, service
|
|
152
|
-
end)
|
|
153
|
-
token = grpc_list.next_page_token
|
|
154
|
-
token = nil if token == ""
|
|
155
|
-
sinks.instance_variable_set "@token", token
|
|
156
|
-
sinks.instance_variable_set "@service", service
|
|
157
|
-
sinks.instance_variable_set "@max", max
|
|
158
|
-
sinks
|
|
159
|
-
end
|
|
160
|
-
|
|
161
|
-
protected
|
|
162
|
-
|
|
163
|
-
##
|
|
164
|
-
# Raise an error unless an active service is available.
|
|
165
|
-
def ensure_service!
|
|
166
|
-
fail "Must have active service" unless @service
|
|
167
|
-
end
|
|
168
|
-
end
|
|
169
|
-
end
|
|
170
|
-
end
|
|
171
|
-
end
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
# Copyright 2015 Google Inc. All rights reserved.
|
|
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
|
-
# http://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 "gcloud/credentials"
|
|
17
|
-
|
|
18
|
-
module Gcloud
|
|
19
|
-
module Pubsub
|
|
20
|
-
##
|
|
21
|
-
# @private Represents the OAuth 2.0 signing logic for Pub/Sub.
|
|
22
|
-
class Credentials < Gcloud::Credentials
|
|
23
|
-
SCOPE = ["https://www.googleapis.com/auth/pubsub"]
|
|
24
|
-
PATH_ENV_VARS = %w(PUBSUB_KEYFILE GCLOUD_KEYFILE GOOGLE_CLOUD_KEYFILE)
|
|
25
|
-
JSON_ENV_VARS = %w(PUBSUB_KEYFILE_JSON GCLOUD_KEYFILE_JSON
|
|
26
|
-
GOOGLE_CLOUD_KEYFILE_JSON)
|
|
27
|
-
end
|
|
28
|
-
end
|
|
29
|
-
end
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
# Copyright 2015 Google Inc. All rights reserved.
|
|
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
|
-
# http://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 "gcloud/errors"
|
|
17
|
-
|
|
18
|
-
module Gcloud
|
|
19
|
-
module Pubsub
|
|
20
|
-
##
|
|
21
|
-
# # Message
|
|
22
|
-
#
|
|
23
|
-
# Represents a Pub/Sub Message.
|
|
24
|
-
#
|
|
25
|
-
# Message objects are created by {Topic#publish}.
|
|
26
|
-
# {Subscription#pull} returns an array of {ReceivedMessage} objects, each of
|
|
27
|
-
# which contains a Message object. Each {ReceivedMessage} object can be
|
|
28
|
-
# acknowledged and/or delayed.
|
|
29
|
-
#
|
|
30
|
-
# @example
|
|
31
|
-
# require "gcloud"
|
|
32
|
-
#
|
|
33
|
-
# gcloud = Gcloud.new
|
|
34
|
-
# pubsub = gcloud.pubsub
|
|
35
|
-
#
|
|
36
|
-
# # Publish a message
|
|
37
|
-
# topic = pubsub.topic "my-topic"
|
|
38
|
-
# message = topic.publish "new-message"
|
|
39
|
-
# puts message.data #=> "new-message"
|
|
40
|
-
#
|
|
41
|
-
# # Pull a message
|
|
42
|
-
# sub = pubsub.subscription "my-topic-sub"
|
|
43
|
-
# received_message = sub.pull.first
|
|
44
|
-
# puts received_message.message.data #=> "new-message"
|
|
45
|
-
#
|
|
46
|
-
class Message
|
|
47
|
-
##
|
|
48
|
-
# @private The gRPC Google::Pubsub::V1::PubsubMessage object.
|
|
49
|
-
attr_accessor :grpc
|
|
50
|
-
|
|
51
|
-
##
|
|
52
|
-
# Create an empty Message object.
|
|
53
|
-
# This can be used to publish several messages in bulk.
|
|
54
|
-
def initialize data = nil, attributes = {}
|
|
55
|
-
# Convert attributes to strings to match the protobuf definition
|
|
56
|
-
attributes = Hash[attributes.map { |k, v| [String(k), String(v)] }]
|
|
57
|
-
|
|
58
|
-
@grpc = Google::Pubsub::V1::PubsubMessage.new(
|
|
59
|
-
data: String(data).encode("ASCII-8BIT"),
|
|
60
|
-
attributes: attributes)
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
##
|
|
64
|
-
# The received data.
|
|
65
|
-
def data
|
|
66
|
-
@grpc.data
|
|
67
|
-
end
|
|
68
|
-
|
|
69
|
-
##
|
|
70
|
-
# The received attributes.
|
|
71
|
-
def attributes
|
|
72
|
-
return @grpc.attributes.to_h if @grpc.attributes.respond_to? :to_h
|
|
73
|
-
# Enumerable doesn't have to_h on Ruby 2.0, so fallback to this
|
|
74
|
-
Hash[@grpc.attributes.to_a]
|
|
75
|
-
end
|
|
76
|
-
|
|
77
|
-
##
|
|
78
|
-
# The ID of this message, assigned by the server at publication time.
|
|
79
|
-
# Guaranteed to be unique within the topic.
|
|
80
|
-
def message_id
|
|
81
|
-
@grpc.message_id
|
|
82
|
-
end
|
|
83
|
-
alias_method :msg_id, :message_id
|
|
84
|
-
|
|
85
|
-
##
|
|
86
|
-
# @private New Message from a Google::Pubsub::V1::PubsubMessage object.
|
|
87
|
-
def self.from_grpc grpc
|
|
88
|
-
new.tap do |m|
|
|
89
|
-
m.instance_variable_set "@grpc", grpc
|
|
90
|
-
end
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
|
-
end
|