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
@@ -1,128 +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 "stringio"
17
-
18
- module Gcloud
19
- module Datastore
20
- ##
21
- # # Properties
22
- #
23
- # Hash-like data structure for Datastore properties.
24
- #
25
- # See {Entity#properties}
26
- class Properties
27
- def initialize properties = {}
28
- @hash = {}
29
- properties.each do |key, value|
30
- key = ensure_key_type key
31
- value = ensure_value_type value
32
- @hash[key] = value
33
- end
34
- end
35
-
36
- def [] key
37
- key = ensure_key_type key
38
- @hash[key]
39
- end
40
- alias_method :read, :[]
41
-
42
- def []= key, value
43
- key = ensure_key_type key
44
- value = ensure_value_type value
45
- @hash[key] = value
46
- end
47
- alias_method :write, :[]=
48
-
49
- def exist? key
50
- key = ensure_key_type key
51
- @hash.key? key
52
- end
53
-
54
- def fetch key, &_block
55
- key = ensure_key_type key
56
- @hash[key] = yield unless exist? key
57
- @hash[key]
58
- end
59
-
60
- def each &block
61
- @hash.each(&block)
62
- end
63
-
64
- def delete key, &block
65
- key = ensure_key_type key
66
- @hash.delete key, &block
67
- end
68
-
69
- def to_h
70
- @hash.dup
71
- end
72
- alias_method :to_hash, :to_h
73
-
74
- def to_grpc
75
- Hash[@hash.map { |(k, v)| [k.to_s, GRPCUtils.to_value(v)] }]
76
- end
77
-
78
- def self.from_grpc grpc_map
79
- # For some reason Google::Protobuf::Map#map isn't returning the value.
80
- # It returns nil every time. COnvert to Hash to get actual objects.
81
- grpc_hash = GRPCUtils.map_to_hash grpc_map
82
- new Hash[grpc_hash.map { |(k, v)| [k.to_s, GRPCUtils.from_value(v)] }]
83
- end
84
-
85
- protected
86
-
87
- ##
88
- # Ensures the key is the proper type,
89
- # otherwise a PropertyError is raised.
90
- def ensure_key_type key
91
- return key.to_str if key.respond_to? :to_str
92
- fail "Property key #{key} must be a String."
93
- end
94
-
95
- # rubocop:disable all
96
- # Disabled rubocop because this needs to match GRPCUtils.to_value
97
-
98
- ##
99
- # Ensures the value is a type that can be persisted,
100
- # otherwise a PropertyError is raised.
101
- def ensure_value_type value
102
- if Gcloud::Datastore::Key === value ||
103
- Gcloud::Datastore::Entity === value ||
104
- NilClass === value ||
105
- TrueClass === value ||
106
- FalseClass === value ||
107
- Float === value ||
108
- Integer === value ||
109
- String === value ||
110
- Array === value
111
- return value
112
- elsif value.respond_to?(:to_time)
113
- return value
114
- elsif value.respond_to?(:to_hash) && value.keys.sort == [:latitude, :longitude]
115
- return value
116
- elsif value.respond_to?(:read) && value.respond_to?(:rewind)
117
- # Always convert an IO object to a StringIO when storing.
118
- value.rewind
119
- return StringIO.new(value.read.force_encoding("ASCII-8BIT"))
120
- elsif defined?(BigDecimal) && BigDecimal === value
121
- return value
122
- end
123
- fail PropertyError, "A property of type #{value.class} is not supported."
124
- end
125
- # rubocop:enable all
126
- end
127
- end
128
- end
@@ -1,348 +0,0 @@
1
- # Copyright 2014 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/datastore/entity"
17
- require "gcloud/datastore/key"
18
-
19
- module Gcloud
20
- module Datastore
21
- ##
22
- # # Query
23
- #
24
- # Represents the search criteria against a Datastore.
25
- #
26
- # @see https://cloud.google.com/datastore/docs/concepts/queries Datastore
27
- # Queries
28
- # @see https://cloud.google.com/datastore/docs/concepts/metadataqueries
29
- # Datastore Metadata
30
- #
31
- # @example
32
- # query = Gcloud::Datastore::Query.new
33
- # query.kind("Task").
34
- # where("done", "=", false).
35
- # where("priority", ">=", 4).
36
- # order("priority", :desc)
37
- #
38
- # tasks = datastore.run query
39
- #
40
- class Query
41
- ##
42
- # Returns a new query object.
43
- #
44
- # @example
45
- # query = Gcloud::Datastore::Query.new
46
- #
47
- def initialize
48
- @grpc = Google::Datastore::V1beta3::Query.new
49
- end
50
-
51
- ##
52
- # Add the kind of entities to query.
53
- #
54
- # Special entity kinds such as `__namespace__`, `__kind__`, and
55
- # `__property__` can be used for [metadata
56
- # queries](https://cloud.google.com/datastore/docs/concepts/metadataqueries).
57
- #
58
- # @example
59
- # query = Gcloud::Datastore::Query.new
60
- # query.kind "Task"
61
- #
62
- # tasks = datastore.run query
63
- #
64
- def kind *kinds
65
- kinds.each do |kind|
66
- grpc_kind = Google::Datastore::V1beta3::KindExpression.new(name: kind)
67
- @grpc.kind << grpc_kind
68
- end
69
-
70
- self
71
- end
72
-
73
- ##
74
- # Add a property filter to the query.
75
- #
76
- # @example
77
- # query = Gcloud::Datastore::Query.new
78
- # query.kind("Task").
79
- # where("done", "=", false)
80
- #
81
- # tasks = datastore.run query
82
- #
83
- # @example Add a composite property filter:
84
- # query = Gcloud::Datastore::Query.new
85
- # query.kind("Task").
86
- # where("done", "=", false).
87
- # where("priority", ">=", 4)
88
- #
89
- # tasks = datastore.run query
90
- #
91
- # @example Add an inequality filter on a **single** property only:
92
- # query = Gcloud::Datastore::Query.new
93
- # query.kind("Task").
94
- # where("created", ">=", Time.utc(1990, 1, 1)).
95
- # where("created", "<", Time.utc(2000, 1, 1))
96
- #
97
- # tasks = datastore.run query
98
- #
99
- # @example Add a composite filter on an array property:
100
- # query = Gcloud::Datastore::Query.new
101
- # query.kind("Task").
102
- # where("tag", "=", "fun").
103
- # where("tag", "=", "programming")
104
- #
105
- # tasks = datastore.run query
106
- #
107
- # @example Add an inequality filter on an array property :
108
- # query = Gcloud::Datastore::Query.new
109
- # query.kind("Task").
110
- # where("tag", ">", "learn").
111
- # where("tag", "<", "math")
112
- #
113
- # tasks = datastore.run query
114
- #
115
- # @example Add a key filter using the special property `__key__`:
116
- # query = Gcloud::Datastore::Query.new
117
- # query.kind("Task").
118
- # where("__key__", ">", datastore.key("Task", "someTask"))
119
- #
120
- # tasks = datastore.run query
121
- #
122
- # @example Add a key filter to a *kindless* query:
123
- # last_seen_key = datastore.key "Task", "a"
124
- # query = Gcloud::Datastore::Query.new
125
- # query.where("__key__", ">", last_seen_key)
126
- #
127
- # tasks = datastore.run query
128
- #
129
- def where name, operator, value
130
- @grpc.filter ||= Google::Datastore::V1beta3::Filter.new(
131
- composite_filter: Google::Datastore::V1beta3::CompositeFilter.new(
132
- op: :AND
133
- )
134
- )
135
- @grpc.filter.composite_filter.filters << \
136
- Google::Datastore::V1beta3::Filter.new(
137
- property_filter: Google::Datastore::V1beta3::PropertyFilter.new(
138
- property: Google::Datastore::V1beta3::PropertyReference.new(
139
- name: name),
140
- op: GRPCUtils.to_prop_filter_op(operator),
141
- value: GRPCUtils.to_value(value)
142
- )
143
- )
144
-
145
- self
146
- end
147
- alias_method :filter, :where
148
-
149
- ##
150
- # Add a filter for entities that inherit from a key.
151
- #
152
- # @example
153
- # task_list_key = datastore.key "TaskList", "default"
154
- #
155
- # query = Gcloud::Datastore::Query.new
156
- # query.kind("Task").
157
- # ancestor(task_list_key)
158
- #
159
- # tasks = datastore.run query
160
- #
161
- def ancestor parent
162
- # Use key if given an entity
163
- parent = parent.key if parent.respond_to? :key
164
- where "__key__", "~", parent
165
- end
166
-
167
- ##
168
- # Sort the results by a property name.
169
- # By default, an ascending sort order will be used.
170
- # To sort in descending order, provide a second argument
171
- # of a string or symbol that starts with "d".
172
- #
173
- # @example With ascending sort order:
174
- # query = Gcloud::Datastore::Query.new
175
- # query.kind("Task").
176
- # order("created")
177
- #
178
- # tasks = datastore.run query
179
- #
180
- # @example With descending sort order:
181
- # query = Gcloud::Datastore::Query.new
182
- # query.kind("Task").
183
- # order("created", :desc)
184
- #
185
- # tasks = datastore.run query
186
- #
187
- # @example With multiple sort orders:
188
- # query = Gcloud::Datastore::Query.new
189
- # query.kind("Task").
190
- # order("priority", :desc).
191
- # order("created")
192
- #
193
- # tasks = datastore.run query
194
- #
195
- # @example A property used in an inequality filter must be ordered first:
196
- # query = Gcloud::Datastore::Query.new
197
- # query.kind("Task").
198
- # where("priority", ">", 3).
199
- # order("priority").
200
- # order("created")
201
- #
202
- # tasks = datastore.run query
203
- #
204
- def order name, direction = :asc
205
- @grpc.order << Google::Datastore::V1beta3::PropertyOrder.new(
206
- property: Google::Datastore::V1beta3::PropertyReference.new(
207
- name: name),
208
- direction: prop_order_direction(direction)
209
- )
210
-
211
- self
212
- end
213
-
214
- ##
215
- # Set a limit on the number of results to be returned.
216
- #
217
- # @example
218
- # query = Gcloud::Datastore::Query.new
219
- # query.kind("Task").
220
- # limit(5)
221
- #
222
- # tasks = datastore.run query
223
- #
224
- def limit num
225
- @grpc.limit = Google::Protobuf::Int32Value.new(value: num)
226
-
227
- self
228
- end
229
-
230
- ##
231
- # Set an offset for the results to be returned.
232
- #
233
- # @example
234
- # query = Gcloud::Datastore::Query.new
235
- # query.kind("Task").
236
- # limit(5).
237
- # offset(10)
238
- #
239
- # tasks = datastore.run query
240
- #
241
- def offset num
242
- @grpc.offset = num
243
-
244
- self
245
- end
246
-
247
- ##
248
- # Set the cursor to start the results at.
249
- #
250
- # @example
251
- # query = Gcloud::Datastore::Query.new
252
- # query.kind("Task").
253
- # limit(page_size).
254
- # start(page_cursor)
255
- #
256
- # tasks = datastore.run query
257
- #
258
- def start cursor
259
- if cursor.is_a? Cursor
260
- @grpc.start_cursor = cursor.to_grpc
261
- elsif cursor.is_a? String
262
- @grpc.start_cursor = GRPCUtils.decode_bytes cursor
263
- else
264
- fail ArgumentError, "Can't set a cursor using a #{cursor.class}."
265
- end
266
-
267
- self
268
- end
269
- alias_method :cursor, :start
270
-
271
- ##
272
- # Retrieve only select properties from the matched entities.
273
- #
274
- # @example
275
- # query = Gcloud::Datastore::Query.new
276
- # query.kind("Task").
277
- # select("priority", "percent_complete")
278
- #
279
- # priorities = []
280
- # percent_completes = []
281
- # datastore.run(query).each do |task|
282
- # priorities << task["priority"]
283
- # percent_completes << task["percent_complete"]
284
- # end
285
- #
286
- # @example A keys-only query using the special property `__key__`:
287
- # query = Gcloud::Datastore::Query.new
288
- # query.kind("Task").
289
- # select("__key__")
290
- #
291
- # keys = datastore.run(query).map(&:key)
292
- #
293
- def select *names
294
- names.each do |name|
295
- grpc_projection = Google::Datastore::V1beta3::Projection.new(
296
- property: Google::Datastore::V1beta3::PropertyReference.new(
297
- name: name))
298
- @grpc.projection << grpc_projection
299
- end
300
-
301
- self
302
- end
303
- alias_method :projection, :select
304
-
305
- ##
306
- # Group results by a list of properties.
307
- #
308
- # @example
309
- # query = Gcloud::Datastore::Query.new
310
- # query.kind("Task").
311
- # distinct_on("type", "priority").
312
- # order("type").
313
- # order("priority")
314
- #
315
- # tasks = datastore.run query
316
- #
317
- def group_by *names
318
- names.each do |name|
319
- grpc_property = Google::Datastore::V1beta3::PropertyReference.new(
320
- name: name)
321
- @grpc.distinct_on << grpc_property
322
- end
323
-
324
- self
325
- end
326
- alias_method :distinct_on, :group_by
327
-
328
- # @private
329
- def to_grpc
330
- @grpc
331
- end
332
-
333
- protected
334
-
335
- ##
336
- # @private Get the property order direction for a string.
337
- def prop_order_direction direction
338
- if direction.to_s.downcase.start_with? "a"
339
- :ASCENDING
340
- elsif direction.to_s.downcase.start_with? "d"
341
- :DESCENDING
342
- else
343
- :DIRECTION_UNSPECIFIED
344
- end
345
- end
346
- end
347
- end
348
- end