gcloud 0.5.0 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +8 -8
- data/CHANGELOG.md +8 -0
- data/lib/gcloud.rb +48 -30
- data/lib/gcloud/bigquery.rb +4 -6
- data/lib/gcloud/bigquery/connection.rb +2 -14
- data/lib/gcloud/bigquery/dataset.rb +41 -42
- data/lib/gcloud/bigquery/project.rb +50 -46
- data/lib/gcloud/bigquery/query_job.rb +7 -8
- data/lib/gcloud/bigquery/table.rb +54 -55
- data/lib/gcloud/bigquery/table/schema.rb +30 -40
- data/lib/gcloud/bigquery/view.rb +10 -11
- data/lib/gcloud/credentials.rb +19 -25
- data/lib/gcloud/datastore.rb +4 -6
- data/lib/gcloud/datastore/dataset.rb +3 -5
- data/lib/gcloud/dns.rb +4 -6
- data/lib/gcloud/dns/connection.rb +17 -16
- data/lib/gcloud/dns/importer.rb +5 -11
- data/lib/gcloud/dns/project.rb +11 -12
- data/lib/gcloud/dns/zone.rb +52 -92
- data/lib/gcloud/dns/zone/transaction.rb +2 -2
- data/lib/gcloud/pubsub.rb +4 -6
- data/lib/gcloud/pubsub/connection.rb +1 -12
- data/lib/gcloud/pubsub/project.rb +30 -36
- data/lib/gcloud/pubsub/subscription.rb +18 -26
- data/lib/gcloud/pubsub/topic.rb +16 -26
- data/lib/gcloud/resource_manager.rb +5 -6
- data/lib/gcloud/resource_manager/connection.rb +4 -4
- data/lib/gcloud/resource_manager/manager.rb +10 -14
- data/lib/gcloud/resource_manager/project.rb +3 -5
- data/lib/gcloud/search.rb +295 -0
- data/lib/gcloud/search/api_client.rb +144 -0
- data/lib/gcloud/search/connection.rb +146 -0
- data/lib/gcloud/search/credentials.rb +30 -0
- data/lib/gcloud/search/document.rb +301 -0
- data/lib/gcloud/search/document/list.rb +85 -0
- data/lib/gcloud/search/errors.rb +67 -0
- data/lib/gcloud/search/field_value.rb +164 -0
- data/lib/gcloud/search/field_values.rb +263 -0
- data/lib/gcloud/search/fields.rb +267 -0
- data/lib/gcloud/search/index.rb +613 -0
- data/lib/gcloud/search/index/list.rb +90 -0
- data/lib/gcloud/search/project.rb +197 -0
- data/lib/gcloud/search/result.rb +169 -0
- data/lib/gcloud/search/result/list.rb +95 -0
- data/lib/gcloud/storage.rb +4 -6
- data/lib/gcloud/storage/bucket.rb +55 -43
- data/lib/gcloud/storage/bucket/cors.rb +5 -7
- data/lib/gcloud/storage/file.rb +35 -30
- data/lib/gcloud/storage/file/acl.rb +12 -16
- data/lib/gcloud/storage/project.rb +56 -22
- data/lib/gcloud/version.rb +1 -1
- metadata +20 -3
@@ -79,15 +79,13 @@ module Gcloud
|
|
79
79
|
# The field name. The name must contain only letters (a-z, A-Z),
|
80
80
|
# numbers (0-9), or underscores (_), and must start with a letter or
|
81
81
|
# underscore. The maximum length is 128 characters. (+String+)
|
82
|
-
# +
|
83
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
84
|
-
# <code>options[:description]</code>::
|
82
|
+
# +description+::
|
85
83
|
# A description of the field. (+String+)
|
86
|
-
#
|
84
|
+
# +mode+::
|
87
85
|
# The field's mode. The possible values are +:nullable+, +:required+,
|
88
86
|
# and +:repeated+. The default value is +:nullable+. (+Symbol+)
|
89
|
-
def string name,
|
90
|
-
add_field name, :string, nil,
|
87
|
+
def string name, description: nil, mode: nil
|
88
|
+
add_field name, :string, nil, description: description, mode: mode
|
91
89
|
end
|
92
90
|
|
93
91
|
##
|
@@ -99,15 +97,13 @@ module Gcloud
|
|
99
97
|
# The field name. The name must contain only letters (a-z, A-Z),
|
100
98
|
# numbers (0-9), or underscores (_), and must start with a letter or
|
101
99
|
# underscore. The maximum length is 128 characters. (+String+)
|
102
|
-
# +
|
103
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
104
|
-
# <code>options[:description]</code>::
|
100
|
+
# +description+::
|
105
101
|
# A description of the field. (+String+)
|
106
|
-
#
|
102
|
+
# +mode+::
|
107
103
|
# The field's mode. The possible values are +:nullable+, +:required+,
|
108
104
|
# and +:repeated+. The default value is +:nullable+. (+Symbol+)
|
109
|
-
def integer name,
|
110
|
-
add_field name, :integer, nil,
|
105
|
+
def integer name, description: nil, mode: nil
|
106
|
+
add_field name, :integer, nil, description: description, mode: mode
|
111
107
|
end
|
112
108
|
|
113
109
|
##
|
@@ -119,15 +115,13 @@ module Gcloud
|
|
119
115
|
# The field name. The name must contain only letters (a-z, A-Z),
|
120
116
|
# numbers (0-9), or underscores (_), and must start with a letter or
|
121
117
|
# underscore. The maximum length is 128 characters. (+String+)
|
122
|
-
# +
|
123
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
124
|
-
# <code>options[:description]</code>::
|
118
|
+
# +description+::
|
125
119
|
# A description of the field. (+String+)
|
126
|
-
#
|
120
|
+
# +mode+::
|
127
121
|
# The field's mode. The possible values are +:nullable+, +:required+,
|
128
122
|
# and +:repeated+. The default value is +:nullable+. (+Symbol+)
|
129
|
-
def float name,
|
130
|
-
add_field name, :float, nil,
|
123
|
+
def float name, description: nil, mode: nil
|
124
|
+
add_field name, :float, nil, description: description, mode: mode
|
131
125
|
end
|
132
126
|
|
133
127
|
##
|
@@ -139,15 +133,13 @@ module Gcloud
|
|
139
133
|
# The field name. The name must contain only letters (a-z, A-Z),
|
140
134
|
# numbers (0-9), or underscores (_), and must start with a letter or
|
141
135
|
# underscore. The maximum length is 128 characters. (+String+)
|
142
|
-
# +
|
143
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
144
|
-
# <code>options[:description]</code>::
|
136
|
+
# +description+::
|
145
137
|
# A description of the field. (+String+)
|
146
|
-
#
|
138
|
+
# +mode+::
|
147
139
|
# The field's mode. The possible values are +:nullable+, +:required+,
|
148
140
|
# and +:repeated+. The default value is +:nullable+. (+Symbol+)
|
149
|
-
def boolean name,
|
150
|
-
add_field name, :boolean, nil,
|
141
|
+
def boolean name, description: nil, mode: nil
|
142
|
+
add_field name, :boolean, nil, description: description, mode: mode
|
151
143
|
end
|
152
144
|
|
153
145
|
##
|
@@ -159,15 +151,13 @@ module Gcloud
|
|
159
151
|
# The field name. The name must contain only letters (a-z, A-Z),
|
160
152
|
# numbers (0-9), or underscores (_), and must start with a letter or
|
161
153
|
# underscore. The maximum length is 128 characters. (+String+)
|
162
|
-
# +
|
163
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
164
|
-
# <code>options[:description]</code>::
|
154
|
+
# +description+::
|
165
155
|
# A description of the field. (+String+)
|
166
|
-
#
|
156
|
+
# +mode+::
|
167
157
|
# The field's mode. The possible values are +:nullable+, +:required+,
|
168
158
|
# and +:repeated+. The default value is +:nullable+. (+Symbol+)
|
169
|
-
def timestamp name,
|
170
|
-
add_field name, :timestamp, nil,
|
159
|
+
def timestamp name, description: nil, mode: nil
|
160
|
+
add_field name, :timestamp, nil, description: description, mode: mode
|
171
161
|
end
|
172
162
|
|
173
163
|
##
|
@@ -182,11 +172,9 @@ module Gcloud
|
|
182
172
|
# The field name. The name must contain only letters (a-z, A-Z),
|
183
173
|
# numbers (0-9), or underscores (_), and must start with a letter or
|
184
174
|
# underscore. The maximum length is 128 characters. (+String+)
|
185
|
-
# +
|
186
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
187
|
-
# <code>options[:description]</code>::
|
175
|
+
# +description+::
|
188
176
|
# A description of the field. (+String+)
|
189
|
-
#
|
177
|
+
# +mode+::
|
190
178
|
# The field's mode. The possible values are +:nullable+, +:required+,
|
191
179
|
# and +:repeated+. The default value is +:nullable+. (+Symbol+)
|
192
180
|
#
|
@@ -207,12 +195,13 @@ module Gcloud
|
|
207
195
|
# end
|
208
196
|
# end
|
209
197
|
#
|
210
|
-
def record name,
|
198
|
+
def record name, description: nil, mode: nil
|
211
199
|
fail ArgumentError, "nested RECORD type is not permitted" if @nested
|
212
200
|
fail ArgumentError, "a block is required" unless block_given?
|
213
201
|
nested_schema = self.class.new nil, true
|
214
202
|
yield nested_schema
|
215
|
-
add_field name, :record, nested_schema.fields,
|
203
|
+
add_field name, :record, nested_schema.fields,
|
204
|
+
description: description, mode: mode
|
216
205
|
end
|
217
206
|
|
218
207
|
protected
|
@@ -234,16 +223,17 @@ module Gcloud
|
|
234
223
|
upcase_mode
|
235
224
|
end
|
236
225
|
|
237
|
-
def add_field name, type, nested_fields,
|
226
|
+
def add_field name, type, nested_fields, description: nil,
|
227
|
+
mode: :nullable
|
238
228
|
# Remove any existing field of this name
|
239
229
|
@fields.reject! { |h| h["name"] == name }
|
240
230
|
field = {
|
241
231
|
"name" => name,
|
242
232
|
"type" => upcase_type(type)
|
243
233
|
}
|
244
|
-
field["
|
245
|
-
field["description"] =
|
246
|
-
field["
|
234
|
+
field["fields"] = nested_fields if nested_fields
|
235
|
+
field["description"] = description if description
|
236
|
+
field["mode"] = upcase_mode(mode) if mode
|
247
237
|
@fields << field
|
248
238
|
end
|
249
239
|
end
|
data/lib/gcloud/bigquery/view.rb
CHANGED
@@ -286,33 +286,31 @@ module Gcloud
|
|
286
286
|
#
|
287
287
|
# === Parameters
|
288
288
|
#
|
289
|
-
# +
|
290
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
291
|
-
# <code>options[:max]</code>::
|
289
|
+
# +max+::
|
292
290
|
# The maximum number of rows of data to return per page of results.
|
293
291
|
# Setting this flag to a small value such as 1000 and then paging
|
294
292
|
# through results might improve reliability when the query result set is
|
295
293
|
# large. In addition to this limit, responses are also limited to 10 MB.
|
296
294
|
# By default, there is no maximum row count, and only the byte limit
|
297
295
|
# applies. (+Integer+)
|
298
|
-
#
|
296
|
+
# +timeout+::
|
299
297
|
# How long to wait for the query to complete, in milliseconds, before
|
300
298
|
# the request times out and returns. Note that this is only a timeout
|
301
299
|
# for the request, not the query. If the query takes longer to run than
|
302
300
|
# the timeout value, the call returns without any results and with
|
303
301
|
# QueryData#complete? set to false. The default value is 10000
|
304
302
|
# milliseconds (10 seconds). (+Integer+)
|
305
|
-
#
|
306
|
-
# If set to +true+, BigQuery doesn't run the job. Instead, if the query
|
307
|
-
# is valid, BigQuery returns statistics about the job such as how many
|
308
|
-
# bytes would be processed. If the query is invalid, an error returns.
|
309
|
-
# The default value is +false+. (+Boolean+)
|
310
|
-
# <code>options[:cache]</code>::
|
303
|
+
# +cache+::
|
311
304
|
# Whether to look for the result in the query cache. The query cache is
|
312
305
|
# a best-effort cache that will be flushed whenever tables in the query
|
313
306
|
# are modified. The default value is true. For more information, see
|
314
307
|
# {query caching}[https://developers.google.com/bigquery/querying-data].
|
315
308
|
# (+Boolean+)
|
309
|
+
# +dryrun+::
|
310
|
+
# If set to +true+, BigQuery doesn't run the job. Instead, if the query
|
311
|
+
# is valid, BigQuery returns statistics about the job such as how many
|
312
|
+
# bytes would be processed. If the query is invalid, an error returns.
|
313
|
+
# The default value is +false+. (+Boolean+)
|
316
314
|
#
|
317
315
|
# === Returns
|
318
316
|
#
|
@@ -335,9 +333,10 @@ module Gcloud
|
|
335
333
|
#
|
336
334
|
# :category: Data
|
337
335
|
#
|
338
|
-
def data
|
336
|
+
def data max: nil, timeout: nil, cache: nil, dryrun: nil
|
339
337
|
sql = "SELECT * FROM #{@gapi['id']}"
|
340
338
|
ensure_connection!
|
339
|
+
options = { max: max, timeout: timeout, cache: cache, dryrun: dryrun }
|
341
340
|
resp = connection.query sql, options
|
342
341
|
if resp.success?
|
343
342
|
QueryData.from_gapi resp.data, connection
|
data/lib/gcloud/credentials.rb
CHANGED
@@ -42,15 +42,19 @@ module Gcloud
|
|
42
42
|
:token_credential_uri, :audience,
|
43
43
|
:scope, :issuer, :signing_key
|
44
44
|
|
45
|
-
def initialize keyfile,
|
45
|
+
def initialize keyfile, scope: nil
|
46
46
|
verify_keyfile_provided! keyfile
|
47
47
|
if keyfile.is_a? Signet::OAuth2::Client
|
48
48
|
@client = keyfile
|
49
49
|
elsif keyfile.is_a? Hash
|
50
|
-
|
50
|
+
hash = stringify_hash_keys keyfile
|
51
|
+
hash["scope"] ||= scope
|
52
|
+
@client = init_client hash
|
51
53
|
else
|
52
54
|
verify_keyfile_exists! keyfile
|
53
|
-
|
55
|
+
json = JSON.parse ::File.read(keyfile)
|
56
|
+
json["scope"] ||= scope
|
57
|
+
@client = init_client json
|
54
58
|
end
|
55
59
|
@client.fetch_access_token!
|
56
60
|
end
|
@@ -61,25 +65,25 @@ module Gcloud
|
|
61
65
|
##
|
62
66
|
# Returns the default credentials.
|
63
67
|
#
|
64
|
-
def self.default
|
68
|
+
def self.default scope: nil
|
65
69
|
env = ->(v) { ENV[v] }
|
66
70
|
json = ->(v) { JSON.parse ENV[v] rescue nil unless ENV[v].nil? }
|
67
71
|
path = ->(p) { ::File.file? p }
|
68
72
|
|
69
73
|
# First try to find keyfile file from environment variables.
|
70
74
|
self::PATH_ENV_VARS.map(&env).reject(&:nil?).select(&path).each do |file|
|
71
|
-
return new file,
|
75
|
+
return new file, scope: scope
|
72
76
|
end
|
73
77
|
# Second try to find keyfile json from environment variables.
|
74
78
|
self::JSON_ENV_VARS.map(&json).reject(&:nil?).each do |hash|
|
75
|
-
return new hash,
|
79
|
+
return new hash, scope: scope
|
76
80
|
end
|
77
81
|
# Third try to find keyfile file from known file paths.
|
78
82
|
self::DEFAULT_PATHS.select(&path).each do |file|
|
79
|
-
return new file,
|
83
|
+
return new file, scope: scope
|
80
84
|
end
|
81
85
|
# Finally get instantiated client from Google::Auth.
|
82
|
-
scope
|
86
|
+
scope ||= self::SCOPE
|
83
87
|
client = Google::Auth.get_application_default scope
|
84
88
|
new client
|
85
89
|
end
|
@@ -103,8 +107,8 @@ module Gcloud
|
|
103
107
|
|
104
108
|
##
|
105
109
|
# Initializes the Signet client.
|
106
|
-
def init_client keyfile
|
107
|
-
client_opts = client_options keyfile
|
110
|
+
def init_client keyfile
|
111
|
+
client_opts = client_options keyfile
|
108
112
|
Signet::OAuth2::Client.new client_opts
|
109
113
|
end
|
110
114
|
|
@@ -114,21 +118,11 @@ module Gcloud
|
|
114
118
|
Hash[hash.map { |(k, v)| [k.to_s, v] }]
|
115
119
|
end
|
116
120
|
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
"scope" => self.class::SCOPE }
|
123
|
-
end
|
124
|
-
|
125
|
-
def client_options keyfile, options
|
126
|
-
# Turn keys to strings
|
127
|
-
options = stringify_hash_keys options
|
128
|
-
# Constructor options override default options
|
129
|
-
options = default_options.merge options
|
130
|
-
# Keyfile options override everything
|
131
|
-
options = options.merge keyfile
|
121
|
+
def client_options options
|
122
|
+
# Keyfile options have higher priority over constructor defaults
|
123
|
+
options["token_credential_uri"] ||= self.class::TOKEN_CREDENTIAL_URI
|
124
|
+
options["audience"] ||= self.class::AUDIENCE
|
125
|
+
options["scope"] ||= self.class::SCOPE
|
132
126
|
|
133
127
|
# client options for initializing signet client
|
134
128
|
{ token_credential_uri: options["token_credential_uri"],
|
data/lib/gcloud/datastore.rb
CHANGED
@@ -33,9 +33,7 @@ module Gcloud
|
|
33
33
|
# +keyfile+::
|
34
34
|
# Keyfile downloaded from Google Cloud. If file path the file must be
|
35
35
|
# readable. (+String+ or +Hash+)
|
36
|
-
# +
|
37
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
38
|
-
# <code>options[:scope]</code>::
|
36
|
+
# +scope+::
|
39
37
|
# The OAuth 2.0 scopes controlling the set of resources and operations that
|
40
38
|
# the connection can access. See {Using OAuth 2.0 to Access Google
|
41
39
|
# APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
|
@@ -64,12 +62,12 @@ module Gcloud
|
|
64
62
|
#
|
65
63
|
# dataset.save entity
|
66
64
|
#
|
67
|
-
def self.datastore project = nil, keyfile = nil,
|
65
|
+
def self.datastore project = nil, keyfile = nil, scope: nil
|
68
66
|
project ||= Gcloud::Datastore::Dataset.default_project
|
69
67
|
if keyfile.nil?
|
70
|
-
credentials = Gcloud::Datastore::Credentials.default
|
68
|
+
credentials = Gcloud::Datastore::Credentials.default scope: scope
|
71
69
|
else
|
72
|
-
credentials = Gcloud::Datastore::Credentials.new keyfile,
|
70
|
+
credentials = Gcloud::Datastore::Credentials.new keyfile, scope: scope
|
73
71
|
end
|
74
72
|
Gcloud::Datastore::Dataset.new project, credentials
|
75
73
|
end
|
@@ -241,9 +241,7 @@ module Gcloud
|
|
241
241
|
#
|
242
242
|
# +query+::
|
243
243
|
# The Query object with the search criteria. (+Query+)
|
244
|
-
# +
|
245
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
246
|
-
# <code>options[:namespace]</code>::
|
244
|
+
# +namespace+::
|
247
245
|
# The namespace the query is to run within. (+String+)
|
248
246
|
#
|
249
247
|
# === Returns
|
@@ -263,8 +261,8 @@ module Gcloud
|
|
263
261
|
# where("completed", "=", true)
|
264
262
|
# tasks = dataset.run query, namespace: "ns~todo-project"
|
265
263
|
#
|
266
|
-
def run query,
|
267
|
-
partition = optional_partition_id
|
264
|
+
def run query, namespace: nil
|
265
|
+
partition = optional_partition_id namespace
|
268
266
|
response = connection.run_query query.to_proto, partition
|
269
267
|
entities = to_gcloud_entities response.batch.entity_result
|
270
268
|
cursor = Proto.encode_cursor response.batch.end_cursor
|
data/lib/gcloud/dns.rb
CHANGED
@@ -30,9 +30,7 @@ module Gcloud
|
|
30
30
|
# +keyfile+::
|
31
31
|
# Keyfile downloaded from Google Cloud. If file path the file must be
|
32
32
|
# readable. (+String+ or +Hash+)
|
33
|
-
# +
|
34
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
35
|
-
# <code>options[:scope]</code>::
|
33
|
+
# +scope+::
|
36
34
|
# The OAuth 2.0 scopes controlling the set of resources and operations that
|
37
35
|
# the connection can access. See {Using OAuth 2.0 to Access Google
|
38
36
|
# APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
|
@@ -55,12 +53,12 @@ module Gcloud
|
|
55
53
|
#
|
56
54
|
# zone = dns.zone "example-com"
|
57
55
|
#
|
58
|
-
def self.dns project = nil, keyfile = nil,
|
56
|
+
def self.dns project = nil, keyfile = nil, scope: nil
|
59
57
|
project ||= Gcloud::Dns::Project.default_project
|
60
58
|
if keyfile.nil?
|
61
|
-
credentials = Gcloud::Dns::Credentials.default
|
59
|
+
credentials = Gcloud::Dns::Credentials.default scope: scope
|
62
60
|
else
|
63
|
-
credentials = Gcloud::Dns::Credentials.new keyfile,
|
61
|
+
credentials = Gcloud::Dns::Credentials.new keyfile, scope: scope
|
64
62
|
end
|
65
63
|
Gcloud::Dns::Project.new project, credentials
|
66
64
|
end
|
@@ -52,10 +52,10 @@ module Gcloud
|
|
52
52
|
)
|
53
53
|
end
|
54
54
|
|
55
|
-
def list_zones
|
55
|
+
def list_zones token: nil, max: nil
|
56
56
|
params = { project: @project,
|
57
|
-
pageToken:
|
58
|
-
maxResults:
|
57
|
+
pageToken: token,
|
58
|
+
maxResults: max
|
59
59
|
}.delete_if { |_, v| v.nil? }
|
60
60
|
|
61
61
|
@client.execute(
|
@@ -64,11 +64,12 @@ module Gcloud
|
|
64
64
|
)
|
65
65
|
end
|
66
66
|
|
67
|
-
def create_zone zone_name, zone_dns,
|
67
|
+
def create_zone zone_name, zone_dns, description: nil,
|
68
|
+
name_server_set: nil
|
68
69
|
body = { kind: "dns#managedZone",
|
69
70
|
name: zone_name, dnsName: zone_dns,
|
70
|
-
description: (
|
71
|
-
nameServerSet:
|
71
|
+
description: (description || ""),
|
72
|
+
nameServerSet: name_server_set
|
72
73
|
}.delete_if { |_, v| v.nil? }
|
73
74
|
|
74
75
|
@client.execute(
|
@@ -93,12 +94,12 @@ module Gcloud
|
|
93
94
|
)
|
94
95
|
end
|
95
96
|
|
96
|
-
def list_changes zone_id,
|
97
|
+
def list_changes zone_id, token: nil, max: nil, order: nil, sort: nil
|
97
98
|
params = { project: @project, managedZone: zone_id,
|
98
|
-
pageToken:
|
99
|
-
maxResults:
|
100
|
-
sortBy:
|
101
|
-
sortOrder:
|
99
|
+
pageToken: token,
|
100
|
+
maxResults: max,
|
101
|
+
sortBy: sort,
|
102
|
+
sortOrder: order
|
102
103
|
}.delete_if { |_, v| v.nil? }
|
103
104
|
|
104
105
|
@client.execute(
|
@@ -119,12 +120,12 @@ module Gcloud
|
|
119
120
|
)
|
120
121
|
end
|
121
122
|
|
122
|
-
def list_records zone_id,
|
123
|
+
def list_records zone_id, name = nil, type = nil, token: nil, max: nil
|
123
124
|
params = { project: @project, managedZone: zone_id,
|
124
|
-
pageToken:
|
125
|
-
maxResults:
|
126
|
-
name:
|
127
|
-
type:
|
125
|
+
pageToken: token,
|
126
|
+
maxResults: max,
|
127
|
+
name: name,
|
128
|
+
type: type
|
128
129
|
}.delete_if { |_, v| v.nil? }
|
129
130
|
|
130
131
|
@client.execute(
|
data/lib/gcloud/dns/importer.rb
CHANGED
@@ -61,30 +61,24 @@ module Gcloud
|
|
61
61
|
#
|
62
62
|
# === Parameters
|
63
63
|
#
|
64
|
-
# +
|
65
|
-
# An optional Hash for controlling additional behavior. (+Hash+)
|
66
|
-
# <code>options[:only]</code>::
|
64
|
+
# +only+::
|
67
65
|
# Include only records of this type or types. (+String+ or +Array+)
|
68
|
-
#
|
66
|
+
# +except+::
|
69
67
|
# Exclude records of this type or types. (+String+ or +Array+)
|
70
68
|
#
|
71
69
|
# === Returns
|
72
70
|
#
|
73
71
|
# An array of unsaved Record instances.
|
74
72
|
#
|
75
|
-
def records
|
76
|
-
filtered_records options[:only], options[:except]
|
77
|
-
end
|
78
|
-
|
79
|
-
protected
|
80
|
-
|
81
|
-
def filtered_records only, except
|
73
|
+
def records only: nil, except: nil
|
82
74
|
ret = @records
|
83
75
|
ret = ret.select { |r| Array(only).include? r.type } if only
|
84
76
|
ret = ret.reject { |r| Array(except).include? r.type } if except
|
85
77
|
ret
|
86
78
|
end
|
87
79
|
|
80
|
+
protected
|
81
|
+
|
88
82
|
##
|
89
83
|
# The zonefile library returns a two-element array in which the first
|
90
84
|
# element is a symbol type (:a, :mx, and so on), and the second element
|