gcloud 0.6.3 → 0.7.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (175) hide show
  1. checksums.yaml +8 -8
  2. data/AUTHENTICATION.md +13 -9
  3. data/CHANGELOG.md +8 -3
  4. data/OVERVIEW.md +46 -8
  5. data/lib/gcloud.rb +123 -117
  6. data/lib/gcloud/backoff.rb +43 -15
  7. data/lib/gcloud/bigquery.rb +211 -195
  8. data/lib/gcloud/bigquery/connection.rb +9 -9
  9. data/lib/gcloud/bigquery/copy_job.rb +15 -16
  10. data/lib/gcloud/bigquery/credentials.rb +3 -3
  11. data/lib/gcloud/bigquery/data.rb +12 -11
  12. data/lib/gcloud/bigquery/dataset.rb +162 -216
  13. data/lib/gcloud/bigquery/dataset/access.rb +59 -43
  14. data/lib/gcloud/bigquery/dataset/list.rb +3 -3
  15. data/lib/gcloud/bigquery/errors.rb +9 -5
  16. data/lib/gcloud/bigquery/extract_job.rb +18 -18
  17. data/lib/gcloud/bigquery/insert_response.rb +7 -4
  18. data/lib/gcloud/bigquery/job.rb +48 -44
  19. data/lib/gcloud/bigquery/job/list.rb +3 -3
  20. data/lib/gcloud/bigquery/load_job.rb +24 -25
  21. data/lib/gcloud/bigquery/project.rb +145 -204
  22. data/lib/gcloud/bigquery/query_data.rb +10 -9
  23. data/lib/gcloud/bigquery/query_job.rb +23 -32
  24. data/lib/gcloud/bigquery/table.rb +238 -280
  25. data/lib/gcloud/bigquery/table/list.rb +3 -3
  26. data/lib/gcloud/bigquery/table/schema.rb +79 -87
  27. data/lib/gcloud/bigquery/view.rb +69 -82
  28. data/lib/gcloud/credentials.rb +3 -9
  29. data/lib/gcloud/datastore.rb +194 -170
  30. data/lib/gcloud/datastore/connection.rb +12 -8
  31. data/lib/gcloud/datastore/credentials.rb +6 -4
  32. data/lib/gcloud/datastore/dataset.rb +74 -141
  33. data/lib/gcloud/datastore/dataset/lookup_results.rb +6 -4
  34. data/lib/gcloud/datastore/dataset/query_results.rb +6 -4
  35. data/lib/gcloud/datastore/entity.rb +81 -76
  36. data/lib/gcloud/datastore/errors.rb +10 -8
  37. data/lib/gcloud/datastore/key.rb +41 -77
  38. data/lib/gcloud/datastore/properties.rb +3 -3
  39. data/lib/gcloud/datastore/proto.rb +7 -4
  40. data/lib/gcloud/datastore/query.rb +26 -3
  41. data/lib/gcloud/datastore/transaction.rb +12 -8
  42. data/lib/gcloud/dns.rb +180 -152
  43. data/lib/gcloud/dns/change.rb +16 -16
  44. data/lib/gcloud/dns/change/list.rb +3 -3
  45. data/lib/gcloud/dns/connection.rb +9 -10
  46. data/lib/gcloud/dns/credentials.rb +3 -3
  47. data/lib/gcloud/dns/errors.rb +9 -5
  48. data/lib/gcloud/dns/importer.rb +17 -23
  49. data/lib/gcloud/dns/project.rb +42 -64
  50. data/lib/gcloud/dns/record.rb +58 -46
  51. data/lib/gcloud/dns/record/list.rb +6 -7
  52. data/lib/gcloud/dns/zone.rb +198 -289
  53. data/lib/gcloud/dns/zone/list.rb +3 -3
  54. data/lib/gcloud/dns/zone/transaction.rb +56 -72
  55. data/lib/gcloud/errors.rb +174 -3
  56. data/lib/gcloud/gce.rb +3 -4
  57. data/lib/gcloud/grpc_utils.rb +76 -0
  58. data/lib/gcloud/logging.rb +308 -0
  59. data/lib/gcloud/logging/credentials.rb +29 -0
  60. data/lib/gcloud/logging/entry.rb +303 -0
  61. data/lib/gcloud/logging/entry/http_request.rb +141 -0
  62. data/lib/gcloud/logging/entry/list.rb +111 -0
  63. data/lib/gcloud/logging/entry/operation.rb +90 -0
  64. data/lib/gcloud/logging/logger.rb +307 -0
  65. data/lib/gcloud/logging/metric.rb +175 -0
  66. data/lib/gcloud/logging/metric/list.rb +98 -0
  67. data/lib/gcloud/logging/project.rb +650 -0
  68. data/lib/gcloud/logging/resource.rb +95 -0
  69. data/lib/gcloud/logging/resource_descriptor.rb +140 -0
  70. data/lib/gcloud/logging/resource_descriptor/list.rb +78 -0
  71. data/lib/gcloud/logging/service.rb +258 -0
  72. data/lib/gcloud/logging/sink.rb +233 -0
  73. data/lib/gcloud/logging/sink/list.rb +97 -0
  74. data/lib/gcloud/pubsub.rb +241 -199
  75. data/lib/gcloud/pubsub/credentials.rb +3 -3
  76. data/lib/gcloud/pubsub/message.rb +26 -20
  77. data/lib/gcloud/pubsub/project.rb +166 -233
  78. data/lib/gcloud/pubsub/received_message.rb +28 -38
  79. data/lib/gcloud/pubsub/service.rb +323 -0
  80. data/lib/gcloud/pubsub/subscription.rb +172 -242
  81. data/lib/gcloud/pubsub/subscription/list.rb +11 -9
  82. data/lib/gcloud/pubsub/topic.rb +152 -271
  83. data/lib/gcloud/pubsub/topic/batch.rb +66 -0
  84. data/lib/gcloud/pubsub/topic/list.rb +9 -7
  85. data/lib/gcloud/resource_manager.rb +158 -138
  86. data/lib/gcloud/resource_manager/connection.rb +6 -5
  87. data/lib/gcloud/resource_manager/credentials.rb +3 -3
  88. data/lib/gcloud/resource_manager/errors.rb +9 -5
  89. data/lib/gcloud/resource_manager/manager.rb +54 -86
  90. data/lib/gcloud/resource_manager/project.rb +69 -88
  91. data/lib/gcloud/resource_manager/project/list.rb +4 -5
  92. data/lib/gcloud/resource_manager/project/updater.rb +12 -14
  93. data/lib/gcloud/search.rb +158 -135
  94. data/lib/gcloud/search/api_client.rb +7 -7
  95. data/lib/gcloud/search/connection.rb +8 -8
  96. data/lib/gcloud/search/credentials.rb +3 -3
  97. data/lib/gcloud/search/document.rb +64 -87
  98. data/lib/gcloud/search/document/list.rb +5 -5
  99. data/lib/gcloud/search/errors.rb +9 -5
  100. data/lib/gcloud/search/field_value.rb +32 -38
  101. data/lib/gcloud/search/field_values.rb +50 -80
  102. data/lib/gcloud/search/fields.rb +44 -65
  103. data/lib/gcloud/search/index.rb +163 -204
  104. data/lib/gcloud/search/index/list.rb +5 -5
  105. data/lib/gcloud/search/project.rb +31 -47
  106. data/lib/gcloud/search/result.rb +27 -31
  107. data/lib/gcloud/search/result/list.rb +6 -6
  108. data/lib/gcloud/storage.rb +224 -190
  109. data/lib/gcloud/storage/bucket.rb +202 -227
  110. data/lib/gcloud/storage/bucket/acl.rb +83 -170
  111. data/lib/gcloud/storage/bucket/cors.rb +31 -34
  112. data/lib/gcloud/storage/bucket/list.rb +3 -3
  113. data/lib/gcloud/storage/connection.rb +11 -7
  114. data/lib/gcloud/storage/credentials.rb +3 -3
  115. data/lib/gcloud/storage/errors.rb +11 -8
  116. data/lib/gcloud/storage/file.rb +129 -171
  117. data/lib/gcloud/storage/file/acl.rb +51 -99
  118. data/lib/gcloud/storage/file/list.rb +3 -3
  119. data/lib/gcloud/storage/file/verifier.rb +3 -2
  120. data/lib/gcloud/storage/project.rb +111 -132
  121. data/lib/gcloud/upload.rb +4 -7
  122. data/lib/gcloud/version.rb +2 -4
  123. data/lib/google/api/annotations.rb +14 -0
  124. data/lib/google/api/http.rb +30 -0
  125. data/lib/google/api/label.rb +24 -0
  126. data/lib/google/api/monitored_resource.rb +25 -0
  127. data/lib/google/datastore/v1beta3/datastore.rb +115 -0
  128. data/lib/google/datastore/v1beta3/datastore_services.rb +33 -0
  129. data/lib/google/datastore/v1beta3/entity.rb +63 -0
  130. data/lib/google/datastore/v1beta3/query.rb +128 -0
  131. data/lib/google/devtools/cloudtrace/v1/trace.rb +78 -0
  132. data/lib/google/devtools/cloudtrace/v1/trace_services.rb +32 -0
  133. data/lib/google/example/library/v1/library.rb +91 -0
  134. data/lib/google/example/library/v1/library_services.rb +40 -0
  135. data/lib/google/iam/v1/iam_policy.rb +33 -0
  136. data/lib/google/iam/v1/iam_policy_services.rb +30 -0
  137. data/lib/google/iam/v1/policy.rb +25 -0
  138. data/lib/google/logging/type/http_request.rb +28 -0
  139. data/lib/google/logging/type/log_severity.rb +27 -0
  140. data/lib/google/logging/v2/log_entry.rb +44 -0
  141. data/lib/google/logging/v2/logging.rb +56 -0
  142. data/lib/google/logging/v2/logging_config.rb +59 -0
  143. data/lib/google/logging/v2/logging_config_services.rb +32 -0
  144. data/lib/google/logging/v2/logging_metrics.rb +51 -0
  145. data/lib/google/logging/v2/logging_metrics_services.rb +32 -0
  146. data/lib/google/logging/v2/logging_services.rb +31 -0
  147. data/lib/google/longrunning/operations.rb +50 -0
  148. data/lib/google/longrunning/operations_services.rb +29 -0
  149. data/lib/google/protobuf/any.rb +17 -0
  150. data/lib/google/protobuf/api.rb +31 -0
  151. data/lib/google/protobuf/descriptor.rb +0 -0
  152. data/lib/google/protobuf/duration.rb +17 -0
  153. data/lib/google/protobuf/empty.rb +15 -0
  154. data/lib/google/protobuf/field_mask.rb +16 -0
  155. data/lib/google/protobuf/source_context.rb +16 -0
  156. data/lib/google/protobuf/struct.rb +35 -0
  157. data/lib/google/protobuf/timestamp.rb +17 -0
  158. data/lib/google/protobuf/type.rb +79 -0
  159. data/lib/google/protobuf/wrappers.rb +48 -0
  160. data/lib/google/pubsub/v1/pubsub.rb +129 -0
  161. data/lib/google/pubsub/v1/pubsub_services.rb +56 -0
  162. data/lib/google/pubsub/v1beta2/pubsub.rb +126 -0
  163. data/lib/google/pubsub/v1beta2/pubsub_services.rb +56 -0
  164. data/lib/google/rpc/code.rb +32 -0
  165. data/lib/google/rpc/error_details.rb +61 -0
  166. data/lib/google/rpc/status.rb +19 -0
  167. data/lib/google/type/color.rb +20 -0
  168. data/lib/google/type/date.rb +18 -0
  169. data/lib/google/type/dayofweek.rb +23 -0
  170. data/lib/google/type/latlng.rb +17 -0
  171. data/lib/google/type/money.rb +18 -0
  172. data/lib/google/type/timeofday.rb +19 -0
  173. metadata +101 -4
  174. data/lib/gcloud/pubsub/connection.rb +0 -295
  175. data/lib/gcloud/pubsub/errors.rb +0 -93
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2015 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,6 +12,7 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  module Gcloud
17
17
  module Search
18
18
  class Index
@@ -25,7 +25,7 @@ module Gcloud
25
25
  attr_accessor :token
26
26
 
27
27
  ##
28
- # Create a new Index::List with an array of Index instances.
28
+ # Create a new Index::List with an array of {Index} instances.
29
29
  def initialize arr = []
30
30
  super arr
31
31
  end
@@ -50,7 +50,7 @@ module Gcloud
50
50
  end
51
51
 
52
52
  ##
53
- # Retrieves all indexes by repeatedly loading pages until #next?
53
+ # Retrieves all indexes by repeatedly loading pages until {#next?}
54
54
  # returns false. Returns the list instance for method chaining.
55
55
  def all
56
56
  while next?
@@ -62,8 +62,8 @@ module Gcloud
62
62
  end
63
63
 
64
64
  ##
65
- # New Indexs::List from a response object.
66
- def self.from_response resp, conn #:nodoc:
65
+ # @private New Index::List from a response object.
66
+ def self.from_response resp, conn
67
67
  data = JSON.parse resp.body
68
68
  indexes = new(Array(data["indexes"]).map do |raw_index|
69
69
  Index.from_raw raw_index, conn
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2015 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,6 +12,7 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  require "gcloud/gce"
17
17
  require "gcloud/search/connection"
18
18
  require "gcloud/search/credentials"
@@ -22,31 +22,31 @@ require "gcloud/search/errors"
22
22
  module Gcloud
23
23
  module Search
24
24
  ##
25
- # = Project
25
+ # # Project
26
26
  #
27
27
  # Projects are top-level containers in Google Cloud Platform. They store
28
28
  # information about billing and authorized users, and they control access to
29
29
  # Google Cloud Search resources. Each project has a friendly name and a
30
- # unique ID. Projects can be created only in the {Google Developers
31
- # Console}[https://console.developers.google.com].
30
+ # unique ID. Projects can be created only in the [Google Developers
31
+ # Console](https://console.developers.google.com). See {Gcloud#search}.
32
32
  #
33
+ # @example
33
34
  # require "gcloud"
34
35
  #
35
36
  # gcloud = Gcloud.new
36
37
  # search = gcloud.search
37
38
  # index = search.index "books"
38
39
  #
39
- # See Gcloud#search
40
40
  class Project
41
41
  ##
42
- # The Connection object.
43
- attr_accessor :connection #:nodoc:
42
+ # @private The Connection object.
43
+ attr_accessor :connection
44
44
 
45
45
  ##
46
- # Creates a new Connection instance.
46
+ # @private Creates a new Connection instance.
47
47
  #
48
48
  # See Gcloud.search
49
- def initialize project, credentials #:nodoc:
49
+ def initialize project, credentials
50
50
  project = project.to_s # Always cast to a string
51
51
  fail ArgumentError, "project is missing" if project.empty?
52
52
  @connection = Connection.new project, credentials
@@ -55,8 +55,9 @@ module Gcloud
55
55
  ##
56
56
  # The ID of the current project.
57
57
  #
58
- # === Example
58
+ # @return [String]
59
59
  #
60
+ # @example
60
61
  # require "gcloud"
61
62
  #
62
63
  # gcloud = Gcloud.new "my-project", "/path/to/keyfile.json"
@@ -69,8 +70,8 @@ module Gcloud
69
70
  end
70
71
 
71
72
  ##
72
- # Default project.
73
- def self.default_project #:nodoc:
73
+ # @private Default project.
74
+ def self.default_project
74
75
  ENV["SEARCH_PROJECT"] ||
75
76
  ENV["GCLOUD_PROJECT"] ||
76
77
  ENV["GOOGLE_CLOUD_PROJECT"] ||
@@ -80,22 +81,15 @@ module Gcloud
80
81
  ##
81
82
  # Retrieves an existing index by ID.
82
83
  #
83
- # === Parameters
84
- #
85
- # +index_id+::
86
- # The ID of an index. (+String+)
87
- # +skip_lookup+::
88
- # Optionally create an Index object without verifying the index resource
89
- # exists on the Search service. Documents saved on this object will
90
- # create the index resource if the resource does not yet exist. Default
91
- # is +false+. (+Boolean+)
92
- #
93
- # === Returns
84
+ # @param [String] index_id The ID of an index.
85
+ # @param [Boolean] skip_lookup Optionally create an Index object without
86
+ # verifying the index resource exists on the Search service. Documents
87
+ # saved on this object will create the index resource if the resource
88
+ # does not yet exist. Default is `false`.
94
89
  #
95
- # Gcloud::Search::Index or nil if the index does not exist
96
- #
97
- # === Examples
90
+ # @return [Gcloud::Search::Index, nil] nil if the index does not exist
98
91
  #
92
+ # @example
99
93
  # require "gcloud"
100
94
  #
101
95
  # gcloud = Gcloud.new
@@ -104,9 +98,7 @@ module Gcloud
104
98
  # index = search.index "books"
105
99
  # index.index_id #=> "books"
106
100
  #
107
- # A new index can be created by providing the desired +index_id+ and the
108
- # +skip_lookup+ option:
109
- #
101
+ # @example A new index can be created with `index_id` and `skip_lookup`:
110
102
  # require "gcloud"
111
103
  #
112
104
  # gcloud = Gcloud.new
@@ -130,23 +122,17 @@ module Gcloud
130
122
  ##
131
123
  # Retrieves the list of indexes belonging to the project.
132
124
  #
133
- # === Parameters
125
+ # @param [String] prefix The prefix of the index name. It is used to list
126
+ # all indexes with names that have this prefix.
127
+ # @param [String] token A previously-returned page token representing part
128
+ # of the larger set of results to view.
129
+ # @param [Integer] max Maximum number of indexes to return. The default is
130
+ # `100`.
134
131
  #
135
- # +prefix+::
136
- # The prefix of the index name. It is used to list all indexes with
137
- # names that have this prefix. (+String+)
138
- # +token+::
139
- # A previously-returned page token representing part of the larger set
140
- # of results to view. (+String+)
141
- # +max+::
142
- # Maximum number of indexes to return. The default is +100+. (+Integer+)
143
- #
144
- # === Returns
145
- #
146
- # Array of Gcloud::Search::Index (See Gcloud::Search::Index::List)
147
- #
148
- # === Examples
132
+ # @return [Array<Gcloud::Search::Index>] (See
133
+ # {Gcloud::Search::Index::List})
149
134
  #
135
+ # @example
150
136
  # require "gcloud"
151
137
  #
152
138
  # gcloud = Gcloud.new
@@ -157,9 +143,7 @@ module Gcloud
157
143
  # puts index.index_id
158
144
  # end
159
145
  #
160
- # If you have a significant number of indexes, you may need to paginate
161
- # through them: (See Gcloud::Search::Index::List)
162
- #
146
+ # @example Using pagination: (See {Gcloud::Search::Index::List})
163
147
  # require "gcloud"
164
148
  #
165
149
  # gcloud = Gcloud.new
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2015 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,31 +12,36 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  require "gcloud/search/result/list"
17
17
  require "gcloud/search/fields"
18
18
 
19
19
  module Gcloud
20
20
  module Search
21
21
  ##
22
- # = Result
22
+ # # Result
23
23
  #
24
- # See Gcloud#search
24
+ # See {Gcloud#search}
25
25
  class Result
26
26
  ##
27
- # Creates a new Result instance.
28
- def initialize #:nodoc:
27
+ # @private Creates a new Result instance.
28
+ def initialize
29
29
  @fields = Fields.new
30
30
  @raw = {}
31
31
  end
32
32
 
33
33
  ##
34
34
  # The unique identifier of the document referenced in the search result.
35
+ #
36
+ # @return [String]
35
37
  def doc_id
36
38
  @raw["docId"]
37
39
  end
38
40
 
39
41
  ##
40
42
  # The token for the next page of results.
43
+ #
44
+ # @return [String]
41
45
  def token
42
46
  @raw["nextPageToken"]
43
47
  end
@@ -45,18 +49,12 @@ module Gcloud
45
49
  ##
46
50
  # Retrieve the field values associated to a field name.
47
51
  #
48
- # === Parameters
49
- #
50
- # +name+::
51
- # The name of the field. New values will be configured with this name.
52
- # (+String+)
53
- #
54
- # === Returns
52
+ # @param [String] name The name of the field. New values will be
53
+ # configured with this name.
55
54
  #
56
- # FieldValue
57
- #
58
- # === Example
55
+ # @return [FieldValue]
59
56
  #
57
+ # @example
60
58
  # require "gcloud"
61
59
  #
62
60
  # gcloud = Gcloud.new
@@ -74,26 +72,21 @@ module Gcloud
74
72
  @fields[name]
75
73
  end
76
74
 
77
- # rubocop:disable Style/TrivialAccessors
78
- # Disable rubocop because we want .fields to be listed with the other
79
- # methods on the class.
75
+ # Trivial accessor because we want .fields to be listed with methods.
80
76
 
81
77
  ##
82
78
  # The fields in the search result. Each field has a name (String) and a
83
- # list of values (FieldValues). (See Fields)
79
+ # list of values ({FieldValues}). (See {Fields})
84
80
  def fields
85
81
  @fields
86
82
  end
87
83
 
88
- # rubocop:enable Style/TrivialAccessors
89
-
90
84
  ##
91
85
  # Calls block once for each field, passing the field name and values pair
92
86
  # as parameters. If no block is given an enumerator is returned instead.
93
- # (See Fields#each)
94
- #
95
- # === Example
87
+ # (See {Fields#each})
96
88
  #
89
+ # @example
97
90
  # require "gcloud"
98
91
  #
99
92
  # gcloud = Gcloud.new
@@ -116,8 +109,11 @@ module Gcloud
116
109
 
117
110
  ##
118
111
  # Returns a new array populated with all the field names.
119
- # (See Fields#names)
112
+ # (See {Fields#names})
113
+ #
114
+ # @return [Array<String>]
120
115
  #
116
+ # @example
121
117
  # require "gcloud"
122
118
  #
123
119
  # gcloud = Gcloud.new
@@ -136,8 +132,8 @@ module Gcloud
136
132
  end
137
133
 
138
134
  ##
139
- # Override to keep working in interactive shells manageable.
140
- def inspect #:nodoc:
135
+ # @private Override to keep working in interactive shells manageable.
136
+ def inspect
141
137
  insp_token = ""
142
138
  if token
143
139
  trunc_token = "#{token[0, 8]}...#{token[-5..-1]}"
@@ -149,8 +145,8 @@ module Gcloud
149
145
  end
150
146
 
151
147
  ##
152
- # New Result from a raw data object.
153
- def self.from_hash hash #:nodoc:
148
+ # @private New Result from a raw data object.
149
+ def self.from_hash hash
154
150
  result = new
155
151
  result.instance_variable_set "@raw", hash
156
152
  result.instance_variable_set "@fields", Fields.from_raw(hash["fields"])
@@ -158,8 +154,8 @@ module Gcloud
158
154
  end
159
155
 
160
156
  ##
161
- # Returns the Result data as a hash
162
- def to_hash #:nodoc:
157
+ # @private Returns the Result data as a hash
158
+ def to_hash
163
159
  hash = @raw.dup
164
160
  hash["fields"] = @fields.to_raw
165
161
  hash
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2015 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,6 +12,7 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  module Gcloud
17
17
  module Search
18
18
  class Result
@@ -28,11 +28,11 @@ module Gcloud
28
28
  # The number of documents that match the query. It is greater than or
29
29
  # equal to the number of documents actually returned. This is an
30
30
  # approximation and not an exact count unless it is less than or equal
31
- # to the Index#search +matched_count_accuracy+ option.
31
+ # to the {Index#search} `matched_count_accuracy` option.
32
32
  attr_reader :matched_count
33
33
 
34
34
  ##
35
- # Create a new Result::List with an array of Result instances.
35
+ # Create a new Result::List with an array of {Result} instances.
36
36
  def initialize arr = []
37
37
  super arr
38
38
  end
@@ -52,7 +52,7 @@ module Gcloud
52
52
  end
53
53
 
54
54
  ##
55
- # Retrieves all results by repeatedly loading pages until #next?
55
+ # Retrieves all results by repeatedly loading pages until {#next?}
56
56
  # returns false. Returns the list instance for method chaining.
57
57
  def all
58
58
  while next?
@@ -64,8 +64,8 @@ module Gcloud
64
64
  end
65
65
 
66
66
  ##
67
- # New Result::List from a response object.
68
- def self.from_response resp, index, query, search_options #:nodoc:
67
+ # @private New Result::List from a response object.
68
+ def self.from_response resp, index, query, search_options
69
69
  data = JSON.parse resp.body
70
70
  results = new(Array(data["results"]).map do |raw|
71
71
  Result.from_hash raw
@@ -1,4 +1,3 @@
1
- #--
2
1
  # Copyright 2014 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,40 +12,34 @@
13
12
  # See the License for the specific language governing permissions and
14
13
  # limitations under the License.
15
14
 
15
+
16
16
  require "gcloud"
17
17
  require "gcloud/storage/project"
18
18
 
19
- #--
20
- # Google Cloud Storage
21
19
  module Gcloud
22
20
  ##
23
21
  # Creates a new object for connecting to the Storage service.
24
22
  # Each call creates a new connection.
25
23
  #
26
- # === Parameters
24
+ # For more information on connecting to Google Cloud see the [Authentication
25
+ # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
27
26
  #
28
- # +project+::
29
- # Project identifier for the Storage service you are connecting to.
30
- # (+String+)
31
- # +keyfile+::
32
- # Keyfile downloaded from Google Cloud. If file path the file must be
33
- # readable. (+String+ or +Hash+)
34
- # +scope+::
35
- # The OAuth 2.0 scopes controlling the set of resources and operations that
36
- # the connection can access. See {Using OAuth 2.0 to Access Google
37
- # APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
38
- # or +Array+)
27
+ # @param [String] project Project identifier for the Storage service you are
28
+ # connecting to.
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).
39
35
  #
40
36
  # The default scope is:
41
37
  #
42
- # * +https://www.googleapis.com/auth/devstorage.full_control+
43
- #
44
- # === Returns
38
+ # * `https://www.googleapis.com/auth/devstorage.full_control`
45
39
  #
46
- # Gcloud::Storage::Project
47
- #
48
- # === Example
40
+ # @return [Gcloud::Storage::Project]
49
41
  #
42
+ # @example
50
43
  # require "gcloud/storage"
51
44
  #
52
45
  # storage = Gcloud.storage "my-todo-project",
@@ -66,7 +59,7 @@ module Gcloud
66
59
  end
67
60
 
68
61
  ##
69
- # = Google Cloud Storage
62
+ # # Google Cloud Storage
70
63
  #
71
64
  # Google Cloud Storage is an Internet service to store data in Google's cloud.
72
65
  # It allows world-wide storage and retrieval of any amount of data and at any
@@ -74,83 +67,95 @@ module Gcloud
74
67
  # infrastructure to perform data operations in a cost effective manner.
75
68
  #
76
69
  # Gcloud's goal is to provide a API that is familiar and comfortable to
77
- # Rubyists. Authentication is handled by Gcloud#storage. You can provide the
70
+ # Rubyists. Authentication is handled by {Gcloud#storage}. You can provide the
78
71
  # project and credential information to connect to the Storage service, or if
79
72
  # you are running on Google Compute Engine this configuration is taken care
80
73
  # of for you.
81
74
  #
82
- # require "gcloud"
75
+ # ```ruby
76
+ # require "gcloud"
83
77
  #
84
- # gcloud = Gcloud.new "my-todo-project",
85
- # "/path/to/keyfile.json"
86
- # storage = gcloud.storage
78
+ # gcloud = Gcloud.new "my-todo-project",
79
+ # "/path/to/keyfile.json"
80
+ # storage = gcloud.storage
87
81
  #
88
- # bucket = storage.bucket "my-bucket"
89
- # file = bucket.file "path/to/my-file.ext"
82
+ # bucket = storage.bucket "my-bucket"
83
+ # file = bucket.file "path/to/my-file.ext"
84
+ # ```
90
85
  #
91
86
  # You can learn more about various options for connection on the
92
- # {Authentication Guide}[link:AUTHENTICATION.md].
87
+ # [Authentication
88
+ # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
93
89
  #
94
90
  # To learn more about Cloud Storage, read the
95
- # {Google Cloud Storage Overview
96
- # }[https://cloud.google.com/storage/docs/overview].
91
+ # [Google Cloud Storage Overview
92
+ # ](https://cloud.google.com/storage/docs/overview).
97
93
  #
98
- # == Retrieving Buckets
94
+ # ## Retrieving Buckets
99
95
  #
100
96
  # A Bucket is the container for your data. There is no limit on the number of
101
97
  # buckets that you can create in a project. You can use buckets to organize
102
98
  # and control access to your data. Each bucket has a unique name, which is how
103
- # they are retrieved: (See Project#bucket)
99
+ # they are retrieved: (See {Gcloud::Storage::Project#bucket})
104
100
  #
105
- # require "gcloud"
101
+ # ```ruby
102
+ # require "gcloud"
106
103
  #
107
- # gcloud = Gcloud.new
108
- # storage = gcloud.storage
104
+ # gcloud = Gcloud.new
105
+ # storage = gcloud.storage
109
106
  #
110
- # bucket = storage.bucket "my-todo-app"
107
+ # bucket = storage.bucket "my-todo-app"
108
+ # ```
111
109
  #
112
- # You can also retrieve all buckets on a project: (See Project#buckets)
110
+ # You can also retrieve all buckets on a project: (See
111
+ # {Gcloud::Storage::Project#buckets})
113
112
  #
114
- # require "gcloud"
113
+ # ```ruby
114
+ # require "gcloud"
115
115
  #
116
- # gcloud = Gcloud.new
117
- # storage = gcloud.storage
116
+ # gcloud = Gcloud.new
117
+ # storage = gcloud.storage
118
118
  #
119
- # all_buckets = storage.buckets
119
+ # all_buckets = storage.buckets
120
+ # ```
120
121
  #
121
122
  # If you have a significant number of buckets, you may need to paginate
122
- # through them: (See Bucket::List#token)
123
- #
124
- # require "gcloud"
125
- #
126
- # gcloud = Gcloud.new
127
- # storage = gcloud.storage
128
- #
129
- # all_buckets = []
130
- # tmp_buckets = storage.buckets
131
- # while tmp_buckets.any? do
132
- # tmp_buckets.each do |bucket|
133
- # all_buckets << bucket
134
- # end
135
- # # break loop if no more buckets available
136
- # break if tmp_buckets.token.nil?
137
- # # get the next group of buckets
138
- # tmp_buckets = storage.buckets token: tmp_buckets.token
123
+ # through them: (See {Gcloud::Storage::Bucket::List#token})
124
+ #
125
+ # ```ruby
126
+ # require "gcloud"
127
+ #
128
+ # gcloud = Gcloud.new
129
+ # storage = gcloud.storage
130
+ #
131
+ # all_buckets = []
132
+ # tmp_buckets = storage.buckets
133
+ # while tmp_buckets.any? do
134
+ # tmp_buckets.each do |bucket|
135
+ # all_buckets << bucket
139
136
  # end
137
+ # # break loop if no more buckets available
138
+ # break if tmp_buckets.token.nil?
139
+ # # get the next group of buckets
140
+ # tmp_buckets = storage.buckets token: tmp_buckets.token
141
+ # end
142
+ # ```
140
143
  #
141
- # == Creating a Bucket
144
+ # ## Creating a Bucket
142
145
  #
143
- # A unique name is all that is needed to create a new bucket:
144
- # (See Project#create_bucket)
146
+ # A unique name is all that is needed to create a new bucket: (See
147
+ # {Gcloud::Storage::Project#create_bucket})
145
148
  #
146
- # require "gcloud"
149
+ # ```ruby
150
+ # require "gcloud"
147
151
  #
148
- # gcloud = Gcloud.new
149
- # storage = gcloud.storage
152
+ # gcloud = Gcloud.new
153
+ # storage = gcloud.storage
150
154
  #
151
- # bucket = storage.create_bucket "my-todo-app-attachments"
155
+ # bucket = storage.create_bucket "my-todo-app-attachments"
156
+ # ```
152
157
  #
153
- # == Retrieving Files
158
+ # ## Retrieving Files
154
159
  #
155
160
  # A File is an individual pieces of data that you store in Google Cloud
156
161
  # Storage. Files contain the data stored as well as metadata describing the
@@ -158,218 +163,247 @@ module Gcloud
158
163
  # no limit on the number of objects that you can create in a bucket.
159
164
  #
160
165
  # Files are retrieved by their name, which is the path of the file in the
161
- # bucket: (See Bucket#file)
166
+ # bucket: (See {Gcloud::Storage::Bucket#file})
162
167
  #
163
- # require "gcloud"
168
+ # ```ruby
169
+ # require "gcloud"
164
170
  #
165
- # gcloud = Gcloud.new
166
- # storage = gcloud.storage
171
+ # gcloud = Gcloud.new
172
+ # storage = gcloud.storage
167
173
  #
168
- # bucket = storage.bucket "my-todo-app"
169
- # file = bucket.file "avatars/heidi/400x400.png"
174
+ # bucket = storage.bucket "my-todo-app"
175
+ # file = bucket.file "avatars/heidi/400x400.png"
176
+ # ```
170
177
  #
171
178
  # You can also retrieve all files in a bucket: (See Bucket#files)
172
179
  #
173
- # require "gcloud"
180
+ # ```ruby
181
+ # require "gcloud"
174
182
  #
175
- # gcloud = Gcloud.new
176
- # storage = gcloud.storage
183
+ # gcloud = Gcloud.new
184
+ # storage = gcloud.storage
177
185
  #
178
- # bucket = storage.bucket "my-todo-app"
179
- # all_files = bucket.files
186
+ # bucket = storage.bucket "my-todo-app"
187
+ # all_files = bucket.files
188
+ # ```
180
189
  #
181
190
  # Or you can retrieve all files in a specified path:
182
191
  #
183
- # require "gcloud"
192
+ # ```ruby
193
+ # require "gcloud"
184
194
  #
185
- # gcloud = Gcloud.new
186
- # storage = gcloud.storage
195
+ # gcloud = Gcloud.new
196
+ # storage = gcloud.storage
187
197
  #
188
- # bucket = storage.bucket "my-todo-app"
189
- # avatar_files = bucket.files prefix: "avatars/"
198
+ # bucket = storage.bucket "my-todo-app"
199
+ # avatar_files = bucket.files prefix: "avatars/"
200
+ # ```
190
201
  #
191
202
  # If you have a significant number of files, you may need to paginate through
192
- # them: (See File::List#token)
203
+ # them: (See {Gcloud::Storage::File::List#token})
193
204
  #
194
- # require "gcloud"
205
+ # ```ruby
206
+ # require "gcloud"
195
207
  #
196
- # gcloud = Gcloud.new
197
- # storage = gcloud.storage
208
+ # gcloud = Gcloud.new
209
+ # storage = gcloud.storage
198
210
  #
199
- # bucket = storage.bucket "my-todo-app"
211
+ # bucket = storage.bucket "my-todo-app"
200
212
  #
201
- # all_files = []
202
- # tmp_files = bucket.files
203
- # while tmp_files.any? do
204
- # tmp_files.each do |file|
205
- # all_files << file
206
- # end
207
- # # break loop if no more files available
208
- # break if tmp_files.token.nil?
209
- # # get the next group of files
210
- # tmp_files = bucket.files token: tmp_files.token
213
+ # all_files = []
214
+ # tmp_files = bucket.files
215
+ # while tmp_files.any? do
216
+ # tmp_files.each do |file|
217
+ # all_files << file
211
218
  # end
219
+ # # break loop if no more files available
220
+ # break if tmp_files.token.nil?
221
+ # # get the next group of files
222
+ # tmp_files = bucket.files token: tmp_files.token
223
+ # end
224
+ # ```
212
225
  #
213
- # == Creating a File
226
+ # ## Creating a File
214
227
  #
215
228
  # A new File can be uploaded by specifying the location of a file on the local
216
229
  # file system, and the name/path that the file should be stored in the bucket.
217
- # (See Bucket#create_file)
230
+ # (See {Gcloud::Storage::Bucket#create_file})
218
231
  #
219
- # require "gcloud"
232
+ # ```ruby
233
+ # require "gcloud"
220
234
  #
221
- # gcloud = Gcloud.new
222
- # storage = gcloud.storage
235
+ # gcloud = Gcloud.new
236
+ # storage = gcloud.storage
223
237
  #
224
- # bucket = storage.bucket "my-todo-app"
225
- # bucket.create_file "/var/todo-app/avatars/heidi/400x400.png",
226
- # "avatars/heidi/400x400.png"
238
+ # bucket = storage.bucket "my-todo-app"
239
+ # bucket.create_file "/var/todo-app/avatars/heidi/400x400.png",
240
+ # "avatars/heidi/400x400.png"
241
+ # ```
227
242
  #
228
- # === A note about large uploads
243
+ # ### A note about large uploads
229
244
  #
230
245
  # You may encounter a Broken pipe (Errno::EPIPE) error when attempting to
231
246
  # upload large files. To avoid this problem, add the
232
- # {httpclient}[https://rubygems.org/gems/httpclient] gem to your project, and
247
+ # [httpclient](https://rubygems.org/gems/httpclient) gem to your project, and
233
248
  # the line (or lines) of configuration shown below. These lines must execute
234
249
  # after you require gcloud but before you make your first gcloud connection.
235
- # The first statement configures {Faraday}[https://rubygems.org/gems/faraday]
250
+ # The first statement configures [Faraday](https://rubygems.org/gems/faraday)
236
251
  # to use httpclient. The second statement, which should only be added if you
237
- # are using a version of Faraday at or above 0.9.2, is a workaround for {this
238
- # gzip issue}[https://github.com/GoogleCloudPlatform/gcloud-ruby/issues/367].
252
+ # are using a version of Faraday at or above 0.9.2, is a workaround for [this
253
+ # gzip issue](https://github.com/GoogleCloudPlatform/gcloud-ruby/issues/367).
239
254
  #
240
- # require "gcloud"
255
+ # ```ruby
256
+ # require "gcloud"
241
257
  #
242
- # # Use httpclient to avoid broken pipe errors with large uploads
243
- # Faraday.default_adapter = :httpclient
258
+ # # Use httpclient to avoid broken pipe errors with large uploads
259
+ # Faraday.default_adapter = :httpclient
244
260
  #
245
- # # Only add the following statement if using Faraday >= 0.9.2
246
- # # Override gzip middleware with no-op for httpclient
247
- # Faraday::Response.register_middleware :gzip =>
248
- # Faraday::Response::Middleware
261
+ # # Only add the following statement if using Faraday >= 0.9.2
262
+ # # Override gzip middleware with no-op for httpclient
263
+ # Faraday::Response.register_middleware :gzip =>
264
+ # Faraday::Response::Middleware
249
265
  #
250
- # gcloud = Gcloud.new
251
- # storage = gcloud.storage
266
+ # gcloud = Gcloud.new
267
+ # storage = gcloud.storage
268
+ # ```
252
269
  #
253
- # == Downloading a File
270
+ # ## Downloading a File
254
271
  #
255
- # Files can be downloaded to the local file system. (See File#download)
272
+ # Files can be downloaded to the local file system. (See
273
+ # {Gcloud::Storage::File#download})
256
274
  #
257
- # require "gcloud"
275
+ # ```ruby
276
+ # require "gcloud"
258
277
  #
259
- # gcloud = Gcloud.new
260
- # storage = gcloud.storage
278
+ # gcloud = Gcloud.new
279
+ # storage = gcloud.storage
261
280
  #
262
- # bucket = storage.bucket "my-todo-app"
263
- # file = bucket.file "avatars/heidi/400x400.png"
264
- # file.download "/var/todo-app/avatars/heidi/400x400.png"
281
+ # bucket = storage.bucket "my-todo-app"
282
+ # file = bucket.file "avatars/heidi/400x400.png"
283
+ # file.download "/var/todo-app/avatars/heidi/400x400.png"
284
+ # ```
265
285
  #
266
- # == Using Signed URLs
286
+ # ## Using Signed URLs
267
287
  #
268
288
  # Access without authentication can be granted to a File for a specified
269
- # period of time. This URL uses a cryptographic signature
270
- # of your credentials to access the file. (See File#signed_url)
289
+ # period of time. This URL uses a cryptographic signature of your credentials
290
+ # to access the file. (See {Gcloud::Storage::File#signed_url})
271
291
  #
272
- # require "gcloud"
292
+ # ```ruby
293
+ # require "gcloud"
273
294
  #
274
- # gcloud = Gcloud.new
275
- # storage = gcloud.storage
295
+ # gcloud = Gcloud.new
296
+ # storage = gcloud.storage
276
297
  #
277
- # bucket = storage.bucket "my-todo-app"
278
- # file = bucket.file "avatars/heidi/400x400.png"
279
- # shared_url = file.signed_url method: "GET",
280
- # expires: 300 # 5 minutes from now
298
+ # bucket = storage.bucket "my-todo-app"
299
+ # file = bucket.file "avatars/heidi/400x400.png"
300
+ # shared_url = file.signed_url method: "GET",
301
+ # expires: 300 # 5 minutes from now
302
+ # ```
281
303
  #
282
- # == Controlling Access to a Bucket
304
+ # ## Controlling Access to a Bucket
283
305
  #
284
- # Access to a bucket is controlled with Bucket#acl. A bucket has owners,
285
- # writers, and readers. Permissions can be granted to an individual user's
286
- # email address, a group's email address, as well as many predefined lists.
287
- # See the
288
- # {Access Control guide}[https://cloud.google.com/storage/docs/access-control]
289
- # for more.
306
+ # Access to a bucket is controlled with {Gcloud::Storage::Bucket#acl}. A
307
+ # bucket has owners, writers, and readers. Permissions can be granted to an
308
+ # individual user's email address, a group's email address, as well as many
309
+ # predefined lists. See the [Access Control
310
+ # guide](https://cloud.google.com/storage/docs/access-control) for more.
290
311
  #
291
- # Access to a bucket can be granted to a user by appending +"user-"+ to the
312
+ # Access to a bucket can be granted to a user by appending `"user-"` to the
292
313
  # email address:
293
314
  #
294
- # require "gcloud"
315
+ # ```ruby
316
+ # require "gcloud"
295
317
  #
296
- # gcloud = Gcloud.new
297
- # storage = gcloud.storage
318
+ # gcloud = Gcloud.new
319
+ # storage = gcloud.storage
298
320
  #
299
- # bucket = storage.bucket "my-todo-app"
321
+ # bucket = storage.bucket "my-todo-app"
300
322
  #
301
- # email = "heidi@example.net"
302
- # bucket.acl.add_reader "user-#{email}"
323
+ # email = "heidi@example.net"
324
+ # bucket.acl.add_reader "user-#{email}"
325
+ # ```
303
326
  #
304
- # Access to a bucket can be granted to a group by appending +"group-"+ to the
327
+ # Access to a bucket can be granted to a group by appending `"group-"` to the
305
328
  # email address:
306
329
  #
307
- # require "gcloud"
330
+ # ```ruby
331
+ # require "gcloud"
308
332
  #
309
- # gcloud = Gcloud.new
310
- # storage = gcloud.storage
333
+ # gcloud = Gcloud.new
334
+ # storage = gcloud.storage
311
335
  #
312
- # bucket = storage.bucket "my-todo-app"
336
+ # bucket = storage.bucket "my-todo-app"
313
337
  #
314
- # email = "authors@example.net"
315
- # bucket.acl.add_reader "group-#{email}"
338
+ # email = "authors@example.net"
339
+ # bucket.acl.add_reader "group-#{email}"
340
+ # ```
316
341
  #
317
342
  # Access to a bucket can also be granted to a predefined list of permissions:
318
343
  #
319
- # require "gcloud"
344
+ # ```ruby
345
+ # require "gcloud"
320
346
  #
321
- # gcloud = Gcloud.new
322
- # storage = gcloud.storage
347
+ # gcloud = Gcloud.new
348
+ # storage = gcloud.storage
323
349
  #
324
- # bucket = storage.bucket "my-todo-app"
350
+ # bucket = storage.bucket "my-todo-app"
325
351
  #
326
- # bucket.acl.public!
352
+ # bucket.acl.public!
353
+ # ```
327
354
  #
328
- # == Controlling Access to a File
355
+ # ## Controlling Access to a File
329
356
  #
330
357
  # Access to a file is controlled in two ways, either by the setting the
331
- # default permissions to all files in a bucket with Bucket#default_acl, or by
332
- # setting permissions to an individual file with File#acl.
358
+ # default permissions to all files in a bucket with
359
+ # {Gcloud::Storage::Bucket#default_acl}, or by setting permissions to an
360
+ # individual file with {Gcloud::Storage::File#acl}.
333
361
  #
334
- # Access to a file can be granted to a user by appending +"user-"+ to the
362
+ # Access to a file can be granted to a user by appending `"user-"` to the
335
363
  # email address:
336
364
  #
337
- # require "gcloud"
365
+ # ```ruby
366
+ # require "gcloud"
338
367
  #
339
- # gcloud = Gcloud.new
340
- # storage = gcloud.storage
368
+ # gcloud = Gcloud.new
369
+ # storage = gcloud.storage
341
370
  #
342
- # bucket = storage.bucket "my-todo-app"
343
- # file = bucket.file "avatars/heidi/400x400.png"
371
+ # bucket = storage.bucket "my-todo-app"
372
+ # file = bucket.file "avatars/heidi/400x400.png"
344
373
  #
345
- # email = "heidi@example.net"
346
- # file.acl.add_reader "user-#{email}"
374
+ # email = "heidi@example.net"
375
+ # file.acl.add_reader "user-#{email}"
376
+ # ```
347
377
  #
348
- # Access to a file can be granted to a group by appending +"group-"+ to the
378
+ # Access to a file can be granted to a group by appending `"group-"` to the
349
379
  # email address:
350
380
  #
351
- # require "gcloud"
381
+ # ```ruby
382
+ # require "gcloud"
352
383
  #
353
- # gcloud = Gcloud.new
354
- # storage = gcloud.storage
384
+ # gcloud = Gcloud.new
385
+ # storage = gcloud.storage
355
386
  #
356
- # bucket = storage.bucket "my-todo-app"
357
- # file = bucket.file "avatars/heidi/400x400.png"
387
+ # bucket = storage.bucket "my-todo-app"
388
+ # file = bucket.file "avatars/heidi/400x400.png"
358
389
  #
359
- # email = "authors@example.net"
360
- # file.acl.add_reader "group-#{email}"
390
+ # email = "authors@example.net"
391
+ # file.acl.add_reader "group-#{email}"
392
+ # ```
361
393
  #
362
394
  # Access to a file can also be granted to a predefined list of permissions:
363
395
  #
364
- # require "gcloud"
396
+ # ```ruby
397
+ # require "gcloud"
365
398
  #
366
- # gcloud = Gcloud.new
367
- # storage = gcloud.storage
399
+ # gcloud = Gcloud.new
400
+ # storage = gcloud.storage
368
401
  #
369
- # bucket = storage.bucket "my-todo-app"
370
- # file = bucket.file "avatars/heidi/400x400.png"
402
+ # bucket = storage.bucket "my-todo-app"
403
+ # file = bucket.file "avatars/heidi/400x400.png"
371
404
  #
372
- # file.acl.public!
405
+ # file.acl.public!
406
+ # ```
373
407
  #
374
408
  module Storage
375
409
  end