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.
Files changed (169) hide show
  1. checksums.yaml +5 -13
  2. data/lib/gcloud.rb +27 -456
  3. data/lib/gcloud/bigquery.rb +2 -382
  4. data/lib/gcloud/datastore.rb +2 -576
  5. data/lib/gcloud/dns.rb +2 -321
  6. data/lib/gcloud/logging.rb +1 -322
  7. data/lib/gcloud/pubsub.rb +2 -476
  8. data/lib/gcloud/resource_manager.rb +2 -273
  9. data/lib/gcloud/storage.rb +2 -440
  10. data/lib/gcloud/translate.rb +1 -250
  11. data/lib/gcloud/version.rb +2 -2
  12. data/lib/gcloud/vision.rb +1 -501
  13. metadata +36 -332
  14. data/AUTHENTICATION.md +0 -75
  15. data/CHANGELOG.md +0 -382
  16. data/OVERVIEW.md +0 -259
  17. data/lib/gcloud/backoff.rb +0 -150
  18. data/lib/gcloud/bigquery/copy_job.rb +0 -97
  19. data/lib/gcloud/bigquery/credentials.rb +0 -29
  20. data/lib/gcloud/bigquery/data.rb +0 -239
  21. data/lib/gcloud/bigquery/dataset.rb +0 -753
  22. data/lib/gcloud/bigquery/dataset/access.rb +0 -507
  23. data/lib/gcloud/bigquery/dataset/list.rb +0 -169
  24. data/lib/gcloud/bigquery/extract_job.rb +0 -117
  25. data/lib/gcloud/bigquery/insert_response.rb +0 -81
  26. data/lib/gcloud/bigquery/job.rb +0 -299
  27. data/lib/gcloud/bigquery/job/list.rb +0 -172
  28. data/lib/gcloud/bigquery/load_job.rb +0 -202
  29. data/lib/gcloud/bigquery/project.rb +0 -475
  30. data/lib/gcloud/bigquery/query_data.rb +0 -234
  31. data/lib/gcloud/bigquery/query_job.rb +0 -137
  32. data/lib/gcloud/bigquery/schema.rb +0 -359
  33. data/lib/gcloud/bigquery/service.rb +0 -506
  34. data/lib/gcloud/bigquery/table.rb +0 -1141
  35. data/lib/gcloud/bigquery/table/list.rb +0 -180
  36. data/lib/gcloud/bigquery/view.rb +0 -475
  37. data/lib/gcloud/credentials.rb +0 -129
  38. data/lib/gcloud/datastore/commit.rb +0 -148
  39. data/lib/gcloud/datastore/credentials.rb +0 -35
  40. data/lib/gcloud/datastore/cursor.rb +0 -76
  41. data/lib/gcloud/datastore/dataset.rb +0 -660
  42. data/lib/gcloud/datastore/dataset/lookup_results.rb +0 -219
  43. data/lib/gcloud/datastore/dataset/query_results.rb +0 -386
  44. data/lib/gcloud/datastore/entity.rb +0 -449
  45. data/lib/gcloud/datastore/errors.rb +0 -41
  46. data/lib/gcloud/datastore/gql_query.rb +0 -211
  47. data/lib/gcloud/datastore/grpc_utils.rb +0 -132
  48. data/lib/gcloud/datastore/key.rb +0 -281
  49. data/lib/gcloud/datastore/properties.rb +0 -128
  50. data/lib/gcloud/datastore/query.rb +0 -348
  51. data/lib/gcloud/datastore/service.rb +0 -167
  52. data/lib/gcloud/datastore/transaction.rb +0 -362
  53. data/lib/gcloud/dns/change.rb +0 -158
  54. data/lib/gcloud/dns/change/list.rb +0 -173
  55. data/lib/gcloud/dns/credentials.rb +0 -29
  56. data/lib/gcloud/dns/importer.rb +0 -183
  57. data/lib/gcloud/dns/project.rb +0 -247
  58. data/lib/gcloud/dns/record.rb +0 -170
  59. data/lib/gcloud/dns/record/list.rb +0 -174
  60. data/lib/gcloud/dns/service.rb +0 -167
  61. data/lib/gcloud/dns/zone.rb +0 -759
  62. data/lib/gcloud/dns/zone/list.rb +0 -168
  63. data/lib/gcloud/dns/zone/transaction.rb +0 -176
  64. data/lib/gcloud/errors.rb +0 -206
  65. data/lib/gcloud/gce.rb +0 -56
  66. data/lib/gcloud/grpc_utils.rb +0 -87
  67. data/lib/gcloud/logging/credentials.rb +0 -29
  68. data/lib/gcloud/logging/entry.rb +0 -465
  69. data/lib/gcloud/logging/entry/http_request.rb +0 -141
  70. data/lib/gcloud/logging/entry/list.rb +0 -177
  71. data/lib/gcloud/logging/entry/operation.rb +0 -90
  72. data/lib/gcloud/logging/logger.rb +0 -307
  73. data/lib/gcloud/logging/metric.rb +0 -169
  74. data/lib/gcloud/logging/metric/list.rb +0 -172
  75. data/lib/gcloud/logging/project.rb +0 -642
  76. data/lib/gcloud/logging/resource.rb +0 -84
  77. data/lib/gcloud/logging/resource_descriptor.rb +0 -137
  78. data/lib/gcloud/logging/resource_descriptor/list.rb +0 -174
  79. data/lib/gcloud/logging/service.rb +0 -267
  80. data/lib/gcloud/logging/sink.rb +0 -227
  81. data/lib/gcloud/logging/sink/list.rb +0 -171
  82. data/lib/gcloud/pubsub/credentials.rb +0 -29
  83. data/lib/gcloud/pubsub/message.rb +0 -94
  84. data/lib/gcloud/pubsub/policy.rb +0 -204
  85. data/lib/gcloud/pubsub/project.rb +0 -482
  86. data/lib/gcloud/pubsub/received_message.rb +0 -160
  87. data/lib/gcloud/pubsub/service.rb +0 -334
  88. data/lib/gcloud/pubsub/subscription.rb +0 -565
  89. data/lib/gcloud/pubsub/subscription/list.rb +0 -208
  90. data/lib/gcloud/pubsub/topic.rb +0 -511
  91. data/lib/gcloud/pubsub/topic/list.rb +0 -174
  92. data/lib/gcloud/pubsub/topic/publisher.rb +0 -85
  93. data/lib/gcloud/resource_manager/credentials.rb +0 -30
  94. data/lib/gcloud/resource_manager/manager.rb +0 -266
  95. data/lib/gcloud/resource_manager/policy.rb +0 -211
  96. data/lib/gcloud/resource_manager/project.rb +0 -484
  97. data/lib/gcloud/resource_manager/project/list.rb +0 -167
  98. data/lib/gcloud/resource_manager/project/updater.rb +0 -130
  99. data/lib/gcloud/resource_manager/service.rb +0 -127
  100. data/lib/gcloud/storage/bucket.rb +0 -775
  101. data/lib/gcloud/storage/bucket/acl.rb +0 -810
  102. data/lib/gcloud/storage/bucket/cors.rb +0 -153
  103. data/lib/gcloud/storage/bucket/list.rb +0 -172
  104. data/lib/gcloud/storage/credentials.rb +0 -29
  105. data/lib/gcloud/storage/errors.rb +0 -65
  106. data/lib/gcloud/storage/file.rb +0 -842
  107. data/lib/gcloud/storage/file/acl.rb +0 -425
  108. data/lib/gcloud/storage/file/list.rb +0 -191
  109. data/lib/gcloud/storage/file/verifier.rb +0 -67
  110. data/lib/gcloud/storage/project.rb +0 -316
  111. data/lib/gcloud/storage/service.rb +0 -347
  112. data/lib/gcloud/translate/api.rb +0 -241
  113. data/lib/gcloud/translate/detection.rb +0 -137
  114. data/lib/gcloud/translate/language.rb +0 -69
  115. data/lib/gcloud/translate/service.rb +0 -80
  116. data/lib/gcloud/translate/translation.rb +0 -112
  117. data/lib/gcloud/vision/annotate.rb +0 -224
  118. data/lib/gcloud/vision/annotation.rb +0 -455
  119. data/lib/gcloud/vision/annotation/entity.rb +0 -234
  120. data/lib/gcloud/vision/annotation/face.rb +0 -1750
  121. data/lib/gcloud/vision/annotation/properties.rb +0 -245
  122. data/lib/gcloud/vision/annotation/safe_search.rb +0 -161
  123. data/lib/gcloud/vision/annotation/text.rb +0 -236
  124. data/lib/gcloud/vision/annotation/vertex.rb +0 -108
  125. data/lib/gcloud/vision/credentials.rb +0 -29
  126. data/lib/gcloud/vision/image.rb +0 -590
  127. data/lib/gcloud/vision/location.rb +0 -115
  128. data/lib/gcloud/vision/project.rb +0 -278
  129. data/lib/gcloud/vision/service.rb +0 -66
  130. data/lib/google/api/annotations.rb +0 -14
  131. data/lib/google/api/http.rb +0 -30
  132. data/lib/google/api/label.rb +0 -24
  133. data/lib/google/api/monitored_resource.rb +0 -25
  134. data/lib/google/datastore/v1beta3/datastore.rb +0 -115
  135. data/lib/google/datastore/v1beta3/datastore_services.rb +0 -33
  136. data/lib/google/datastore/v1beta3/entity.rb +0 -63
  137. data/lib/google/datastore/v1beta3/query.rb +0 -128
  138. data/lib/google/devtools/cloudtrace/v1/trace.rb +0 -78
  139. data/lib/google/devtools/cloudtrace/v1/trace_services.rb +0 -32
  140. data/lib/google/example/library/v1/library.rb +0 -91
  141. data/lib/google/example/library/v1/library_services.rb +0 -40
  142. data/lib/google/iam/v1/iam_policy.rb +0 -33
  143. data/lib/google/iam/v1/iam_policy_services.rb +0 -30
  144. data/lib/google/iam/v1/policy.rb +0 -25
  145. data/lib/google/logging/type/http_request.rb +0 -28
  146. data/lib/google/logging/type/log_severity.rb +0 -27
  147. data/lib/google/logging/v2/log_entry.rb +0 -44
  148. data/lib/google/logging/v2/logging.rb +0 -56
  149. data/lib/google/logging/v2/logging_config.rb +0 -59
  150. data/lib/google/logging/v2/logging_config_services.rb +0 -32
  151. data/lib/google/logging/v2/logging_metrics.rb +0 -51
  152. data/lib/google/logging/v2/logging_metrics_services.rb +0 -32
  153. data/lib/google/logging/v2/logging_services.rb +0 -31
  154. data/lib/google/longrunning/operations.rb +0 -50
  155. data/lib/google/longrunning/operations_services.rb +0 -29
  156. data/lib/google/protobuf/descriptor.rb +0 -0
  157. data/lib/google/pubsub/v1/pubsub.rb +0 -129
  158. data/lib/google/pubsub/v1/pubsub_services.rb +0 -56
  159. data/lib/google/pubsub/v1beta2/pubsub.rb +0 -126
  160. data/lib/google/pubsub/v1beta2/pubsub_services.rb +0 -56
  161. data/lib/google/rpc/code.rb +0 -32
  162. data/lib/google/rpc/error_details.rb +0 -61
  163. data/lib/google/rpc/status.rb +0 -19
  164. data/lib/google/type/color.rb +0 -20
  165. data/lib/google/type/date.rb +0 -18
  166. data/lib/google/type/dayofweek.rb +0 -23
  167. data/lib/google/type/latlng.rb +0 -17
  168. data/lib/google/type/money.rb +0 -18
  169. data/lib/google/type/timeofday.rb +0 -19
data/lib/gcloud/dns.rb CHANGED
@@ -1,4 +1,4 @@
1
- # Copyright 2015 Google Inc. All rights reserved.
1
+ # Copyright 2016 Google Inc. All rights reserved.
2
2
  #
3
3
  # Licensed under the Apache License, Version 2.0 (the "License");
4
4
  # you may not use this file except in compliance with the License.
@@ -14,323 +14,4 @@
14
14
 
15
15
 
16
16
  require "gcloud"
17
- require "gcloud/dns/project"
18
-
19
- module Gcloud
20
- ##
21
- # Creates a new `Project` instance connected to the DNS service.
22
- # Each call creates a new connection.
23
- #
24
- # For more information on connecting to Google Cloud see the [Authentication
25
- # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
26
- #
27
- # @param [String] project Identifier for a DNS project. If not present, the
28
- # default project for the credentials is used.
29
- # @param [String, Hash] keyfile Keyfile downloaded from Google Cloud. If file
30
- # path the file must be readable.
31
- # @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
32
- # set of resources and operations that the connection can access. See [Using
33
- # OAuth 2.0 to Access Google
34
- # APIs](https://developers.google.com/identity/protocols/OAuth2).
35
- #
36
- # The default scope is:
37
- #
38
- # * `https://www.googleapis.com/auth/ndev.clouddns.readwrite`
39
- # @param [Integer] retries Number of times to retry requests on server error.
40
- # The default value is `3`. Optional.
41
- # @param [Integer] timeout Default timeout to use in requests. Optional.
42
- #
43
- # @return [Gcloud::Dns::Project]
44
- #
45
- # @example
46
- # require "gcloud"
47
- #
48
- # dns = Gcloud.dns "my-dns-project",
49
- # "/path/to/keyfile.json"
50
- #
51
- # zone = dns.zone "example-com"
52
- #
53
- def self.dns project = nil, keyfile = nil, scope: nil, retries: nil,
54
- timeout: nil
55
- project ||= Gcloud::Dns::Project.default_project
56
- project = project.to_s # Always cast to a string
57
- fail ArgumentError, "project is missing" if project.empty?
58
-
59
- if keyfile.nil?
60
- credentials = Gcloud::Dns::Credentials.default scope: scope
61
- else
62
- credentials = Gcloud::Dns::Credentials.new keyfile, scope: scope
63
- end
64
-
65
- Gcloud::Dns::Project.new(
66
- Gcloud::Dns::Service.new(
67
- project, credentials, retries: retries, timeout: timeout))
68
- end
69
-
70
- ##
71
- # # Google Cloud DNS
72
- #
73
- # Google Cloud DNS is a high-performance, resilient, global DNS service that
74
- # provides a cost-effective way to make your applications and services
75
- # available to your users. This programmable, authoritative DNS service can be
76
- # used to easily publish and manage DNS records using the same infrastructure
77
- # relied upon by Google. To learn more, read [What is Google Cloud
78
- # DNS?](https://cloud.google.com/dns/what-is-cloud-dns).
79
- #
80
- # The goal of gcloud-ruby is to provide an API that is comfortable
81
- # to Rubyists. Authentication is handled by {Gcloud#dns}. You can provide the
82
- # project and credential information to connect to the Cloud DNS service, or
83
- # if you are running on Google Compute Engine this configuration is taken care
84
- # of for you. You can read more about the options for connecting in the
85
- # [Authentication
86
- # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
87
- #
88
- # ## Creating Zones
89
- #
90
- # To get started with Google Cloud DNS, use your DNS Project to create a new
91
- # Zone. The second argument to {Gcloud::Dns::Project#create_zone} must be a
92
- # unique domain name for which you can [verify
93
- # ownership](https://www.google.com/webmasters/verification/home). Substitute
94
- # a domain name of your own (ending with a dot to signify that it is [fully
95
- # qualified](https://en.wikipedia.org/wiki/Fully_qualified_domain_name)) as
96
- # you follow along with these examples.
97
- #
98
- # ```ruby
99
- # require "gcloud"
100
- #
101
- # gcloud = Gcloud.new
102
- # dns = gcloud.dns
103
- # zone = dns.create_zone "example-com", "example.com."
104
- # puts zone.id # unique identifier defined by the server
105
- # ```
106
- #
107
- # For more information, see [Managing
108
- # Zones](https://cloud.google.com/dns/zones/).
109
- #
110
- # ## Listing Zones
111
- #
112
- # You can retrieve all the zones in your project.
113
- #
114
- # ```ruby
115
- # require "gcloud"
116
- #
117
- # gcloud = Gcloud.new
118
- # dns = gcloud.dns
119
- # zones = dns.zones
120
- # zones.each do |zone|
121
- # puts "#{zone.name} - #{zone.dns}"
122
- # end
123
- # ```
124
- #
125
- # You can also retrieve a single zone by either name or id.
126
- #
127
- # ```ruby
128
- # require "gcloud"
129
- #
130
- # gcloud = Gcloud.new
131
- # dns = gcloud.dns
132
- # zone = dns.zone "example-com"
133
- # ```
134
- #
135
- # ## Listing Records
136
- #
137
- # When you create a zone, the Cloud DNS service automatically creates two
138
- # Record instances for it, providing configuration for Cloud DNS nameservers.
139
- # Let's take a look at these records.
140
- #
141
- # ```ruby
142
- # require "gcloud"
143
- #
144
- # gcloud = Gcloud.new
145
- # dns = gcloud.dns
146
- # zone = dns.zone "example-com"
147
- # records = zone.records
148
- # records.count #=> 2
149
- # records.map &:type #=> ["NS", "SOA"]
150
- # zone.records.first.data.count #=> 4
151
- # zone.records.first.data #=> ["ns-cloud-d1.googledomains.com.", ...]
152
- # ```
153
- #
154
- # Note that {Gcloud::Dns::Record#data} returns an array. The Cloud DNS service
155
- # only allows the zone to have one Record instance for each name and type
156
- # combination. It supports multiple "resource records" (in this case, the four
157
- # nameserver addresses) via this `data` collection.
158
- #
159
- # ## Managing Records
160
- #
161
- # You can easily add your own records to the zone. Each call to
162
- # {Gcloud::Dns::Zone#add} results in a new Cloud DNS Change instance.
163
- #
164
- # ```ruby
165
- # require "gcloud"
166
- #
167
- # gcloud = Gcloud.new
168
- # dns = gcloud.dns
169
- # zone = dns.zone "example-com"
170
- # change = zone.add "www", "A", 86400, ["1.2.3.4"]
171
- # change.additions.map &:type #=> ["A", "SOA"]
172
- # change.deletions.map &:type #=> ["SOA"]
173
- # ```
174
- #
175
- # Whenever you change the set of records belonging to a zone, the zone's start
176
- # of authority (SOA) record should be updated with a higher serial number. The
177
- # gcloud-ruby library automates this update for you, deleting the old SOA
178
- # record and adding an updated one, as shown in the example above. You can
179
- # disable or modify this behavior, of course. See {Gcloud::Dns::Zone#update}
180
- # for details.
181
- #
182
- # You can retrieve records by name and type. The name argument can be a
183
- # subdomain (e.g., `www`) fragment for convenience, but notice that the
184
- # retrieved record's domain name is always fully-qualified.
185
- #
186
- # ```ruby
187
- # require "gcloud"
188
- #
189
- # gcloud = Gcloud.new
190
- # dns = gcloud.dns
191
- # zone = dns.zone "example-com"
192
- # records = zone.records "www", "A"
193
- # records.first.name #=> "www.example.com."
194
- # ```
195
- #
196
- # You can use {Gcloud::Dns::Zone#replace} to update the `ttl` and `data` for a
197
- # record.
198
- #
199
- # ```ruby
200
- # require "gcloud"
201
- #
202
- # gcloud = Gcloud.new
203
- # dns = gcloud.dns
204
- # zone = dns.zone "example-com"
205
- # change = zone.replace "www", "A", 86400, ["5.6.7.8"]
206
- # ```
207
- #
208
- # Or, you can use {Gcloud::Dns::Zone#modify} to update just the `ttl` or
209
- # `data`, without the risk of inadvertently changing values that you wish to
210
- # leave unchanged.
211
- #
212
- # ```ruby
213
- # require "gcloud"
214
- #
215
- # gcloud = Gcloud.new
216
- # dns = gcloud.dns
217
- # zone = dns.zone "example-com"
218
- # change = zone.modify "www", "A" do |r|
219
- # r.ttl = 3600 # change only the TTL
220
- # end
221
- # ```
222
- #
223
- # You can also delete records by name and type.
224
- #
225
- # ```ruby
226
- # require "gcloud"
227
- #
228
- # gcloud = Gcloud.new
229
- # dns = gcloud.dns
230
- # zone = dns.zone "example-com"
231
- # change = zone.remove "www", "A"
232
- # record = change.deletions.first
233
- # ```
234
- #
235
- # The best way to add, remove, and update multiple records in a single
236
- # [transaction](https://cloud.google.com/dns/records) is to call
237
- # {Gcloud::Dns::Zone#update} with a block. See
238
- # {Gcloud::Dns::Zone::Transaction}.
239
- #
240
- # ```ruby
241
- # require "gcloud"
242
- #
243
- # gcloud = Gcloud.new
244
- # dns = gcloud.dns
245
- # zone = dns.zone "example-com"
246
- # change = zone.update do |tx|
247
- # tx.add "www", "A", 86400, "1.2.3.4"
248
- # tx.remove "example.com.", "TXT"
249
- # tx.replace "example.com.", "MX", 86400, ["10 mail1.example.com.",
250
- # "20 mail2.example.com."]
251
- # tx.modify "www.example.com.", "CNAME" do |r|
252
- # r.ttl = 86400 # only change the TTL
253
- # end
254
- # end
255
- # ```
256
- #
257
- # Finally, you can add and delete records by reference, using
258
- # {Gcloud::Dns::Zone#update}.
259
- #
260
- # ```ruby
261
- # require "gcloud"
262
- #
263
- # gcloud = Gcloud.new
264
- # dns = gcloud.dns
265
- # zone = dns.zone "example-com"
266
- # to_add = zone.record "www", "AAAA", 86400, ["2607:f8b0:400a:801::1005"]
267
- # to_delete = zone.records "www", "A"
268
- # change = zone.update to_add, to_delete
269
- # ```
270
- #
271
- # ## Listing Changes
272
- #
273
- # Because the transactions you execute against your zone do not always
274
- # complete immediately, you can retrieve and inspect changes.
275
- #
276
- # ```ruby
277
- # require "gcloud"
278
- #
279
- # gcloud = Gcloud.new
280
- # dns = gcloud.dns
281
- # zone = dns.zone "example-com"
282
- # changes = zone.changes
283
- # changes.each do |change|
284
- # puts "#{change.id} - #{change.started_at} - #{change.status}"
285
- # end
286
- # ```
287
- #
288
- # ## Importing and exporting zone files
289
- #
290
- # You can import from a zone file. Because the Cloud DNS service only allows
291
- # the zone to have one Record instance for each name and type combination,
292
- # lines may be merged as needed into records with multiple `data` values.
293
- #
294
- # ```ruby
295
- # require "gcloud"
296
- #
297
- # gcloud = Gcloud.new
298
- # dns = gcloud.dns
299
- # zone = dns.zone "example-com"
300
- # change = zone.import "path/to/db.example.com"
301
- # ```
302
- #
303
- # You can also export to a zone file.
304
- #
305
- # ```ruby
306
- # require "gcloud"
307
- #
308
- # gcloud = Gcloud.new
309
- # dns = gcloud.dns
310
- # zone = dns.zone "example-com"
311
- #
312
- # zone.export "path/to/db.example.com"
313
- # ```
314
- #
315
- # ## Configuring retries and timeout
316
- #
317
- # You can configure how many times API requests may be automatically retried.
318
- # When an API request fails, the response will be inspected to see if the
319
- # request meets criteria indicating that it may succeed on retry, such as
320
- # `500` and `503` status codes or a specific internal error code such as
321
- # `rateLimitExceeded`. If it meets the criteria, the request will be retried
322
- # after a delay. If another error occurs, the delay will be increased before a
323
- # subsequent attempt, until the `retries` limit is reached.
324
- #
325
- # You can also set the request `timeout` value in seconds.
326
- #
327
- # ```ruby
328
- # require "gcloud"
329
- #
330
- # gcloud = Gcloud.new
331
- # dns = gcloud.dns retries: 10, timeout: 120
332
- # ```
333
- #
334
- module Dns
335
- end
336
- end
17
+ require "google/cloud/dns"
@@ -14,325 +14,4 @@
14
14
 
15
15
 
16
16
  require "gcloud"
17
- require "gcloud/logging/project"
18
-
19
- module Gcloud
20
- ##
21
- # Creates a new object for connecting to the Stackdriver Logging service.
22
- # Each call creates a new connection.
23
- #
24
- # For more information on connecting to Google Cloud see the [Authentication
25
- # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
26
- #
27
- # @param [String] project Project identifier for the Stackdriver Logging
28
- # service.
29
- # @param [String, Hash] keyfile Keyfile downloaded from Google Cloud. If file
30
- # path the file must be readable.
31
- # @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
32
- # set of resources and operations that the connection can access. See [Using
33
- # OAuth 2.0 to Access Google
34
- # APIs](https://developers.google.com/identity/protocols/OAuth2).
35
- #
36
- # The default scope is:
37
- #
38
- # * `https://www.googleapis.com/auth/logging.admin`
39
- # @param [Integer] retries Number of times to retry requests on server error.
40
- # The default value is `3`. Optional.
41
- # @param [Integer] timeout Default timeout to use in requests. Optional.
42
- #
43
- # @return [Gcloud::Logging::Project]
44
- #
45
- # @example
46
- # require "gcloud/logging"
47
- #
48
- # gcloud = Gcloud.new
49
- # logging = gcloud.logging
50
- # # ...
51
- #
52
- def self.logging project = nil, keyfile = nil, scope: nil, retries: nil,
53
- timeout: nil
54
- project ||= Gcloud::Logging::Project.default_project
55
- project = project.to_s # Always cast to a string
56
- fail ArgumentError, "project is missing" if project.empty?
57
-
58
- if keyfile.nil?
59
- credentials = Gcloud::Logging::Credentials.default scope: scope
60
- else
61
- credentials = Gcloud::Logging::Credentials.new keyfile, scope: scope
62
- end
63
-
64
- Gcloud::Logging::Project.new(
65
- Gcloud::Logging::Service.new(
66
- project, credentials, retries: retries, timeout: timeout))
67
- end
68
-
69
- ##
70
- # # Stackdriver Logging
71
- #
72
- # The Stackdriver Logging service collects and stores logs from applications
73
- # and services on the Google Cloud Platform, giving you fine-grained,
74
- # programmatic control over your projects' logs. You can use the Stackdriver
75
- # Logging API to:
76
- #
77
- # * [Read and filter log entries](#listing-log-entries)
78
- # * [Export your log entries](#exporting-log-entries) to Cloud Storage,
79
- # BigQuery, or Cloud Pub/Sub
80
- # * [Create logs-based metrics](#creating-logs-based-metrics) for use in Cloud
81
- # Monitoring
82
- # * [Write log entries](#writing-log-entries)
83
- #
84
- # For general information about Stackdriver Logging, read [Stackdriver Logging
85
- # Documentation](https://cloud.google.com/logging/docs/).
86
- #
87
- # The goal of gcloud-ruby is to provide an API that is comfortable to
88
- # Rubyists. Authentication is handled by {Gcloud#logging}. You can provide the
89
- # project and credential information to connect to the Stackdriver Logging
90
- # service, or if you are running on Google Compute Engine this configuration
91
- # is taken care of for you. You can read more about the options for connecting
92
- # in the [Authentication
93
- # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
94
- #
95
- # ## Listing log entries
96
- #
97
- # Stackdriver Logging gathers log entries from many services, including Google
98
- # App Engine and Google Compute Engine. (See the [List of Log
99
- # Types](https://cloud.google.com/logging/docs/view/logs_index).) In addition,
100
- # you can write your own log entries to the service.
101
- #
102
- # {Gcloud::Logging::Project#entries} returns the {Gcloud::Logging::Entry}
103
- # records belonging to your project:
104
- #
105
- # ```ruby
106
- # require "gcloud"
107
- #
108
- # gcloud = Gcloud.new
109
- # logging = gcloud.logging
110
- # entries = logging.entries
111
- # entries.each do |e|
112
- # puts "[#{e.timestamp}] #{e.log_name} #{e.payload.inspect}"
113
- # end
114
- # ```
115
- #
116
- # You can narrow the results to a single log using an [advanced logs
117
- # filter](https://cloud.google.com/logging/docs/view/advanced_filters). A
118
- # log is a named collection of entries. Logs can be produced by Google Cloud
119
- # Platform services, by third-party services, or by your applications. For
120
- # example, the log `compute.googleapis.com/activity_log` is produced by Google
121
- # Compute Engine. Logs are simply referenced by name in gcloud-ruby. There is
122
- # no `Log` type in gcloud-ruby or `Log` resource in the Stackdriver Logging
123
- # API.
124
- #
125
- # ```ruby
126
- # require "gcloud"
127
- #
128
- # gcloud = Gcloud.new
129
- # logging = gcloud.logging
130
- # entries = logging.entries filter: "log:syslog"
131
- # entries.each do |e|
132
- # puts "[#{e.timestamp}] #{e.payload.inspect}"
133
- # end
134
- # ```
135
- #
136
- # You can also order the log entries by `timestamp`.
137
- #
138
- # ```ruby
139
- # require "gcloud"
140
- #
141
- # gcloud = Gcloud.new
142
- # logging = gcloud.logging
143
- # entries = logging.entries order: "timestamp desc"
144
- # entries.each do |e|
145
- # puts "[#{e.timestamp}] #{e.log_name} #{e.payload.inspect}"
146
- # end
147
- # ```
148
- #
149
- # ## Exporting log entries
150
- #
151
- # Stackdriver Logging lets you export log entries to destinations including
152
- # Google Cloud Storage buckets (for long term log storage), Google BigQuery
153
- # datasets (for log analysis), and Google Pub/Sub (for streaming to other
154
- # applications).
155
- #
156
- # ### Creating sinks
157
- #
158
- # A {Gcloud::Logging::Sink} is an object that lets you to specify a set of log
159
- # entries to export.
160
- #
161
- # In addition to the name of the sink and the export destination,
162
- # {Gcloud::Logging::Project#create_sink} accepts an [advanced
163
- # logs filter](https://cloud.google.com/logging/docs/view/advanced_filters) to
164
- # narrow the collection.
165
- #
166
- # Before creating the sink, ensure that you have granted
167
- # `cloud-logs@google.com` permission to write logs to the destination. See
168
- # [Permissions for writing exported
169
- # logs](https://cloud.google.com/logging/docs/export/configure_export#setting_product_name_short_permissions_for_writing_exported_logs).
170
- #
171
- # ```ruby
172
- # require "gcloud"
173
- #
174
- # gcloud = Gcloud.new
175
- # logging = gcloud.logging
176
- # storage = gcloud.storage
177
- #
178
- # bucket = storage.create_bucket "my-logs-bucket"
179
- #
180
- # # Grant owner permission to Stackdriver Logging service
181
- # email = "cloud-logs@google.com"
182
- # bucket.acl.add_owner "group-#{email}"
183
- #
184
- # sink = logging.create_sink "my-sink", "storage.googleapis.com/#{bucket.id}"
185
- # ```
186
- #
187
- # When you create a sink, only new log entries are exported. Stackdriver
188
- # Logging does not send previously-ingested log entries to the sink's
189
- # destination.
190
- #
191
- # ### Listing sinks
192
- #
193
- # You can also list the sinks belonging to your project with
194
- # {Gcloud::Logging::Project#sinks}.
195
- #
196
- # ```ruby
197
- # require "gcloud"
198
- #
199
- # gcloud = Gcloud.new
200
- # logging = gcloud.logging
201
- # sinks = logging.sinks
202
- # sinks.each do |s|
203
- # puts "#{s.name}: #{s.filter} -> #{s.destination}"
204
- # end
205
- # ```
206
- #
207
- # ## Creating logs-based metrics
208
- #
209
- # You can use log entries in your project as the basis for [Google Cloud
210
- # Monitoring](https://cloud.google.com/monitoring/docs) metrics. These metrics
211
- # can then be used to produce Cloud Monitoring reports and alerts.
212
- #
213
- # ### Creating metrics
214
- #
215
- # A metric is a measured value that can be used to assess a system. Use
216
- # {Gcloud::Logging::Project#create_metric} to configure a
217
- # {Gcloud::Logging::Metric} based on a collection of log entries matching an
218
- # [advanced
219
- # logs filter](https://cloud.google.com/logging/docs/view/advanced_filters).
220
- #
221
- # ```ruby
222
- # require "gcloud"
223
- #
224
- # gcloud = Gcloud.new
225
- # logging = gcloud.logging
226
- # metric = logging.create_metric "errors", "severity>=ERROR"
227
- # ```
228
- #
229
- # ### Listing metrics
230
- #
231
- # You can also list the metrics belonging to your project with
232
- # {Gcloud::Logging::Project#metrics}.
233
- #
234
- # ```ruby
235
- # require "gcloud"
236
- #
237
- # gcloud = Gcloud.new
238
- # logging = gcloud.logging
239
- # metrics = logging.metrics
240
- # metrics.each do |m|
241
- # puts "#{m.name}: #{m.filter}"
242
- # end
243
- # ```
244
- #
245
- # ## Writing log entries
246
- #
247
- # An {Gcloud::Logging::Entry} is composed of metadata and a payload. The
248
- # payload is traditionally a message string, but in Stackdriver Logging it can
249
- # also be a JSON or protocol buffer object. A single log can have entries with
250
- # different payload types. In addition to the payload, your argument(s) to
251
- # {Gcloud::Logging::Project#write_entries} must also contain a log name and a
252
- # resource.
253
- #
254
- # ```ruby
255
- # require "gcloud"
256
- #
257
- # gcloud = Gcloud.new
258
- # logging = gcloud.logging
259
- #
260
- # entry = logging.entry
261
- # entry.payload = "Job started."
262
- # entry.log_name = "my_app_log"
263
- # entry.resource.type = "gae_app"
264
- # entry.resource.labels[:module_id] = "1"
265
- # entry.resource.labels[:version_id] = "20150925t173233"
266
- #
267
- # logging.write_entries entry
268
- # ```
269
- #
270
- # If you write a collection of log entries, you can provide the log name,
271
- # resource, and/or labels hash to be used for all of the entries, and omit
272
- # these values from the individual entries.
273
- #
274
- # ```ruby
275
- # require "gcloud"
276
- #
277
- # gcloud = Gcloud.new
278
- # logging = gcloud.logging
279
- #
280
- # entry1 = logging.entry
281
- # entry1.payload = "Job started."
282
- # entry2 = logging.entry
283
- # entry2.payload = "Job completed."
284
- # labels = { job_size: "large", job_code: "red" }
285
- #
286
- # resource = logging.resource "gae_app",
287
- # "module_id" => "1",
288
- # "version_id" => "20150925t173233"
289
- #
290
- # logging.write_entries [entry1, entry2],
291
- # log_name: "my_app_log",
292
- # resource: resource,
293
- # labels: labels
294
- # ```
295
- #
296
- # ### Creating a Ruby Logger implementation
297
- #
298
- # If your environment requires a logger instance that is API-compatible with
299
- # Ruby's standard library
300
- # [Logger](http://ruby-doc.org/stdlib/libdoc/logger/rdoc), you can use
301
- # {Gcloud::Logging::Project#logger} to create one.
302
- #
303
- # ```ruby
304
- # require "gcloud"
305
- #
306
- # gcloud = Gcloud.new
307
- # logging = gcloud.logging
308
- #
309
- # resource = logging.resource "gae_app",
310
- # module_id: "1",
311
- # version_id: "20150925t173233"
312
- #
313
- # logger = logging.logger "my_app_log", resource, env: :production
314
- # logger.info "Job started."
315
- # ```
316
- #
317
- # ## Configuring retries and timeout
318
- #
319
- # You can configure how many times API requests may be automatically retried.
320
- # When an API request fails, the response will be inspected to see if the
321
- # request meets criteria indicating that it may succeed on retry, such as
322
- # `500` and `503` status codes or a specific internal error code such as
323
- # `rateLimitExceeded`. If it meets the criteria, the request will be retried
324
- # after a delay. If another error occurs, the delay will be increased before a
325
- # subsequent attempt, until the `retries` limit is reached.
326
- #
327
- # You can also set the request `timeout` value in seconds.
328
- #
329
- # ```ruby
330
- # require "gcloud"
331
- #
332
- # gcloud = Gcloud.new
333
- # logging = gcloud.logging retries: 10, timeout: 120
334
- # ```
335
- #
336
- module Logging
337
- end
338
- end
17
+ require "google/cloud/logging"