gcloud 0.3.1 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- MzczYWVlN2JlNmY4YzI0MTBiNGM4ZjY5YjZlMjkzMDVmZjQ3MGQwNg==
4
+ Nzc3MzUzZjk2YTg0MTg0NDc5ZTUyOGQwZTUxNmQ4YmRhNmRjY2QwMQ==
5
5
  data.tar.gz: !binary |-
6
- YmNkZGUyNzljMjY1YjlhMWQyZjliMGNhZGY2OTdhYjJiOTBiZTNhNw==
6
+ YmQ0N2Q3ZWFlZmY2ZGJlZmE5ZWQzYzc2MWM0NzM5ZTEzNTVkNzRhMA==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- MzE5YjkzYmJmNmNmODY4NThhMjdlOTM2YmUxOTZmYWE4MDZjYjBhZDVmN2U1
10
- NDMxMjY4NjlkZmZiNGJkNmYyNzczM2RhZWY3YmI4ODY5MmU0N2FiNjI5ZDNi
11
- NzBhZGJmNDc4NDU2MWNkMmNkMTA5MzE3MjU0N2Y2N2ZiY2YzYmE=
9
+ ZWRjNGM0MzNmZmM4NjQ5YmE0OTY3ZTUxNzRlZjIxYzIyZmJhZTcyZDhmMGFk
10
+ N2Q2OWI2YzcyMGM1NDM5YjRiMzM0N2ZlZTNkY2VkNTI1N2Y3YjUzMDUzNGMw
11
+ NWI1YTMzNzA5NGVkZTU4ZjAwNGNmZjNhNjRkM2NjOTZmNDk2OWQ=
12
12
  data.tar.gz: !binary |-
13
- OGU0MTQzYzRiOGU0NzJlZDllOGFmZWMzYTcwZDc3NTgwMTMxZTIxMjAxOTc4
14
- MDQ0M2I2YWQyZGIyZmYyMzQ0MThmMTQ2ZjQ2NzJlNTAzMDI1Y2I2MWY3Y2U2
15
- NjdjMjJjZGNlN2EyZmFmNDg3MTcwY2JiZmVkYzExYzZiNTZmZTY=
13
+ YzJkY2FiNDEzZWRlOGViMGU1ZmZiZmM2NGM2YWMyZmRiN2NiNjUyY2JkNGRi
14
+ YzAwMTM3NzdmNjNjNzY4MGY3ZmU3MDVmN2MxNzhlODk3YjY1MmRiODliZmRi
15
+ NjQxMzBmZmEyNWVjZDUwYjc2MmU5NjFmZmYzMTdiZWRkNjY4MWQ=
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Release History
2
2
 
3
+ ### 0.4.0 / 2015-10-12
4
+
5
+ #### Major changes
6
+
7
+ * Add DNS Service
8
+
9
+ #### Minor changes
10
+
11
+ * Improved BigQuery table recognition from a string (vitaliel)
12
+ * Add missing options from BigQuery `Table#load` (gramos74)
13
+ * Add missing options from BigQuery `Table#extract`
14
+
3
15
  ### 0.3.1 / 2015-09-08
4
16
 
5
17
  #### Changes
data/OVERVIEW.md CHANGED
@@ -67,6 +67,34 @@ query = Gcloud::Datastore::Query.new.kind("Task").
67
67
  completed_tasks = dataset.run query
68
68
  ```
69
69
 
70
+ # DNS
71
+
72
+ [Google Cloud DNS](https://cloud.google.com/dns/) ([docs](https://cloud.google.com/dns/docs)) is a high-performance, resilient, global DNS service that provides a cost-effective way to make your applications and services available to your users. This programmable, authoritative DNS service can be used to easily publish and manage DNS records using the same infrastructure relied upon by Google. To learn more, read [What is Google Cloud DNS?](https://cloud.google.com/dns/what-is-cloud-dns).
73
+
74
+ See the [gcloud-ruby DNS API documentation](rdoc-ref:Gcloud::Dns) to learn how to connect to Cloud DNS using this library.
75
+
76
+ ```ruby
77
+ require "gcloud"
78
+
79
+ gcloud = Gcloud.new
80
+ dns = gcloud.dns
81
+
82
+ # Retrieve a zone
83
+ zone = dns.zone "example-com"
84
+
85
+ # Update records in the zone
86
+ change = zone.update do |tx|
87
+ tx.add "www", "A", 86400, "1.2.3.4"
88
+ tx.remove "example.com.", "TXT"
89
+ tx.replace "example.com.", "MX", 86400, ["10 mail1.example.com.",
90
+ "20 mail2.example.com."]
91
+ tx.modify "www.example.com.", "CNAME" do |r|
92
+ r.ttl = 86400 # only change the TTL
93
+ end
94
+ end
95
+
96
+ ```
97
+
70
98
  # Pub/Sub
71
99
 
72
100
  [Google Cloud Pub/Sub](https://cloud.google.com/pubsub/) ([docs](https://cloud.google.com/pubsub/reference/rest/)) is designed to provide reliable, many-to-many, asynchronous messaging between applications. Publisher applications can send messages to a “topic” and other applications can subscribe to that topic to receive the messages. By decoupling senders and receivers, Google Cloud Pub/Sub allows developers to communicate between independently written applications.
data/lib/gcloud.rb CHANGED
@@ -253,4 +253,50 @@ module Gcloud
253
253
  require "gcloud/bigquery"
254
254
  Gcloud.bigquery @project, @keyfile, options
255
255
  end
256
+
257
+ ##
258
+ # Creates a new object for connecting to the DNS service.
259
+ # Each call creates a new connection.
260
+ #
261
+ # === Parameters
262
+ #
263
+ # +options+::
264
+ # An optional Hash for controlling additional behavior. (+Hash+)
265
+ # <code>options[:scope]</code>::
266
+ # The OAuth 2.0 scopes controlling the set of resources and operations that
267
+ # the connection can access. See {Using OAuth 2.0 to Access Google
268
+ # APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
269
+ # or +Array+)
270
+ #
271
+ # The default scope is:
272
+ #
273
+ # * +https://www.googleapis.com/auth/ndev.clouddns.readwrite+
274
+ #
275
+ # === Returns
276
+ #
277
+ # Gcloud::Dns::Project
278
+ #
279
+ # === Examples
280
+ #
281
+ # require "gcloud"
282
+ #
283
+ # gcloud = Gcloud.new
284
+ # dns = gcloud.dns
285
+ # zone = dns.zone "example-zone"
286
+ # zone.records.each do |record|
287
+ # puts record.name
288
+ # end
289
+ #
290
+ # The default scope can be overridden with the +scope+ option:
291
+ #
292
+ # require "gcloud"
293
+ #
294
+ # gcloud = Gcloud.new
295
+ # readonly_scope = "https://www.googleapis.com/auth/ndev.clouddns.readonly"
296
+ # dns = gcloud.dns scope: readonly_scope
297
+ #
298
+ def dns options = {}
299
+ require "gcloud/dns"
300
+ Gcloud.dns @project, @keyfile, options
301
+ end
256
302
  end
@@ -303,19 +303,28 @@ module Gcloud
303
303
  #
304
304
  # === A note about large uploads
305
305
  #
306
- # You may encounter a broken pipe error while attempting to upload large
307
- # files. To avoid this problem, add
308
- # {httpclient}[https://rubygems.org/gems/httpclient] as a dependency to your
309
- # project, and configure {Faraday}[https://rubygems.org/gems/faraday] to use
310
- # it, after requiring Gcloud, but before initiating your Gcloud connection.
306
+ # You may encounter a Broken pipe (Errno::EPIPE) error when attempting to
307
+ # upload large files. To avoid this problem, add the
308
+ # {httpclient}[https://rubygems.org/gems/httpclient] gem to your project, and
309
+ # the line (or lines) of configuration shown below. These lines must execute
310
+ # after you require gcloud but before you make your first gcloud connection.
311
+ # The first statement configures {Faraday}[https://rubygems.org/gems/faraday]
312
+ # to use httpclient. The second statement, which should only be added if you
313
+ # are using a version of Faraday at or above 0.9.2, is a workaround for {this
314
+ # gzip issue}[https://github.com/GoogleCloudPlatform/gcloud-ruby/issues/367].
311
315
  #
312
316
  # require "gcloud"
313
317
  #
318
+ # # Use httpclient to avoid broken pipe errors with large uploads
314
319
  # Faraday.default_adapter = :httpclient
315
320
  #
321
+ # # Only add the following statement if using Faraday >= 0.9.2
322
+ # # Override gzip middleware with no-op for httpclient
323
+ # Faraday::Response.register_middleware :gzip =>
324
+ # Faraday::Response::Middleware
325
+ #
316
326
  # gcloud = Gcloud.new
317
327
  # bigquery = gcloud.bigquery
318
- # dataset = bigquery.dataset "my_dataset"
319
328
  #
320
329
  # == Exporting query results to Google Cloud Storage
321
330
  #
@@ -332,9 +332,10 @@ module Gcloud
332
332
  unless m
333
333
  fail ArgumentError, "unable to identify table from #{str.inspect}"
334
334
  end
335
- default_table_ref.merge("projectId" => m["prj"],
336
- "datasetId" => m["dts"],
337
- "tableId" => m["tbl"])
335
+ str_table_ref = { "projectId" => m["prj"],
336
+ "datasetId" => m["dts"],
337
+ "tableId" => m["tbl"] }.delete_if { |_, v| v.nil? }
338
+ default_table_ref.merge str_table_ref
338
339
  end
339
340
 
340
341
  def inspect #:nodoc:
@@ -526,9 +527,12 @@ module Gcloud
526
527
  {
527
528
  "configuration" => {
528
529
  "extract" => {
529
- "destinationUris" => Array(storage_urls),
530
- "sourceTable" => table,
531
- "destinationFormat" => dest_format
530
+ "destinationUris" => Array(storage_urls),
531
+ "sourceTable" => table,
532
+ "destinationFormat" => dest_format,
533
+ "compression" => options[:compression],
534
+ "fieldDelimiter" => options[:delimiter],
535
+ "printHeader" => options[:header]
532
536
  }.delete_if { |_, v| v.nil? },
533
537
  "dryRun" => options[:dryrun]
534
538
  }.delete_if { |_, v| v.nil? }
@@ -541,12 +545,21 @@ module Gcloud
541
545
  {
542
546
  "configuration" => {
543
547
  "load" => {
544
- "sourceUris" => Array(urls),
545
- "destinationTable" => table,
546
- "createDisposition" => create_disposition(options[:create]),
547
- "writeDisposition" => write_disposition(options[:write]),
548
- "sourceFormat" => source_format(path, options[:format]),
549
- "projectionFields" => projection_fields(options[:projection_fields])
548
+ "sourceUris" => Array(urls),
549
+ "destinationTable" => table,
550
+ "createDisposition" => create_disposition(options[:create]),
551
+ "writeDisposition" => write_disposition(options[:write]),
552
+ "sourceFormat" => source_format(path, options[:format]),
553
+ "projectionFields" => projection_fields(options[:projection_fields]),
554
+ "allowJaggedRows" => options[:jagged_rows],
555
+ "allowQuotedNewlines" => options[:quoted_newlines],
556
+ "encoding" => options[:encoding],
557
+ "fieldDelimiter" => options[:delimiter],
558
+ "ignoreUnknownValues" => options[:ignore_unknown],
559
+ "maxBadRecords" => options[:max_bad_records],
560
+ "quote" => options[:quote],
561
+ "schema" => options[:schema],
562
+ "skipLeadingRows" => options[:skip_leading]
550
563
  }.delete_if { |_, v| v.nil? },
551
564
  "dryRun" => options[:dryrun]
552
565
  }.delete_if { |_, v| v.nil? }
@@ -583,6 +583,15 @@ module Gcloud
583
583
  # * +csv+ - CSV
584
584
  # * +json+ - {Newline-delimited JSON}[http://jsonlines.org/]
585
585
  # * +avro+ - {Avro}[http://avro.apache.org/]
586
+ # <code>options[:compression]</code>::
587
+ # The compression type to use for exported files. Possible values
588
+ # include +GZIP+ and +NONE+. The default value is +NONE+. (+String+)
589
+ # <code>options[:delimiter]</code>::
590
+ # Delimiter to use between fields in the exported data. Default is
591
+ # <code>,</code>. (+String+)
592
+ # <code>options[:header]</code>::
593
+ # Whether to print out a header row in the results. Default is +true+.
594
+ # (+Boolean+)
586
595
  #
587
596
  # === Returns
588
597
  #
@@ -653,6 +662,55 @@ module Gcloud
653
662
  # names are case sensitive and must be top-level properties. If not set,
654
663
  # BigQuery loads all properties. If any named property isn't found in
655
664
  # the Cloud Datastore backup, an invalid error is returned. (+Array+)
665
+ # <code>options[:jagged_rows]</code>::
666
+ # Accept rows that are missing trailing optional columns. The missing
667
+ # values are treated as nulls. If +false+, records with missing trailing
668
+ # columns are treated as bad records, and if there are too many bad
669
+ # records, an invalid error is returned in the job result. The default
670
+ # value is +false+. Only applicable to CSV, ignored for other formats.
671
+ # (+Boolean+)
672
+ # <code>options[:quoted_newlines]</code>::
673
+ # Indicates if BigQuery should allow quoted data sections that contain
674
+ # newline characters in a CSV file. The default value is +false+.
675
+ # (+Boolean+)
676
+ # <code>options[:encoding]</code>::
677
+ # The character encoding of the data. The supported values are +UTF-8+
678
+ # or +ISO-8859-1+. The default value is +UTF-8+. (+String+)
679
+ # <code>options[:delimiter]</code>::
680
+ # Specifices the separator for fields in a CSV file. BigQuery converts
681
+ # the string to +ISO-8859-1+ encoding, and then uses the first byte of
682
+ # the encoded string to split the data in its raw, binary state. Default
683
+ # is <code>,</code>. (+String+)
684
+ # <code>options[:ignore_unknown]</code>::
685
+ # Indicates if BigQuery should allow extra values that are not
686
+ # represented in the table schema. If true, the extra values are
687
+ # ignored. If false, records with extra columns are treated as bad
688
+ # records, and if there are too many bad records, an invalid error is
689
+ # returned in the job result. The default value is +false+. (+Boolean+)
690
+ #
691
+ # The +format+ property determines what BigQuery treats as an extra
692
+ # value:
693
+ #
694
+ # * +CSV+: Trailing columns
695
+ # * +JSON+: Named values that don't match any column names
696
+ # <code>options[:max_bad_records]</code>::
697
+ # The maximum number of bad records that BigQuery can ignore when
698
+ # running the job. If the number of bad records exceeds this value, an
699
+ # invalid error is returned in the job result. The default value is +0+,
700
+ # which requires that all records are valid. (+Integer+)
701
+ # <code>options[:quote]</code>::
702
+ # The value that is used to quote data sections in a CSV file. BigQuery
703
+ # converts the string to ISO-8859-1 encoding, and then uses the first
704
+ # byte of the encoded string to split the data in its raw, binary state.
705
+ # The default value is a double-quote <code>"</code>. If your data does
706
+ # not contain quoted sections, set the property value to an empty
707
+ # string. If your data contains quoted newline characters, you must also
708
+ # set the allowQuotedNewlines property to true. (+String+)
709
+ # <code>options[:skip_leading]</code>::
710
+ # The number of rows at the top of a CSV file that BigQuery will skip
711
+ # when loading the data. The default value is +0+. This property is
712
+ # useful if you have header rows in the file that should be skipped.
713
+ # (+Integer+)
656
714
  #
657
715
  # === Returns
658
716
  #
@@ -700,20 +758,29 @@ module Gcloud
700
758
  #
701
759
  # === A note about large direct uploads
702
760
  #
703
- # You may encounter a broken pipe error while attempting to upload large
704
- # files. To avoid this problem, add
705
- # {httpclient}[https://rubygems.org/gems/httpclient] as a dependency to
706
- # your project, and configure {Faraday}[https://rubygems.org/gems/faraday]
707
- # to use it, after requiring Gcloud, but before initiating your Gcloud
708
- # connection.
761
+ # You may encounter a Broken pipe (Errno::EPIPE) error when attempting to
762
+ # upload large files. To avoid this problem, add the
763
+ # {httpclient}[https://rubygems.org/gems/httpclient] gem to your project,
764
+ # and the line (or lines) of configuration shown below. These lines must
765
+ # execute after you require gcloud but before you make your first gcloud
766
+ # connection. The first statement configures
767
+ # {Faraday}[https://rubygems.org/gems/faraday] to use httpclient. The
768
+ # second statement, which should only be added if you are using a version
769
+ # of Faraday at or above 0.9.2, is a workaround for {this gzip
770
+ # issue}[https://github.com/GoogleCloudPlatform/gcloud-ruby/issues/367].
709
771
  #
710
772
  # require "gcloud"
711
773
  #
774
+ # # Use httpclient to avoid broken pipe errors with large uploads
712
775
  # Faraday.default_adapter = :httpclient
713
776
  #
777
+ # # Only add the following statement if using Faraday >= 0.9.2
778
+ # # Override gzip middleware with no-op for httpclient
779
+ # Faraday::Response.register_middleware :gzip =>
780
+ # Faraday::Response::Middleware
781
+ #
714
782
  # gcloud = Gcloud.new
715
783
  # bigquery = gcloud.bigquery
716
- # dataset = bigquery.dataset "my_dataset"
717
784
  #
718
785
  # :category: Data
719
786
  #
data/lib/gcloud/dns.rb ADDED
@@ -0,0 +1,280 @@
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
+ require "gcloud"
16
+ require "gcloud/dns/project"
17
+
18
+ #--
19
+ # Google Cloud DNS
20
+ module Gcloud
21
+ ##
22
+ # Creates a new +Project+ instance connected to the DNS service.
23
+ # Each call creates a new connection.
24
+ #
25
+ # === Parameters
26
+ #
27
+ # +project+::
28
+ # Identifier for a DNS project. If not present, the default project for
29
+ # the credentials is used. (+String+)
30
+ # +keyfile+::
31
+ # Keyfile downloaded from Google Cloud. If file path the file must be
32
+ # readable. (+String+ or +Hash+)
33
+ # +options+::
34
+ # An optional Hash for controlling additional behavior. (+Hash+)
35
+ # <code>options[:scope]</code>::
36
+ # The OAuth 2.0 scopes controlling the set of resources and operations that
37
+ # the connection can access. See {Using OAuth 2.0 to Access Google
38
+ # APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
39
+ # or +Array+)
40
+ #
41
+ # The default scope is:
42
+ #
43
+ # * +https://www.googleapis.com/auth/ndev.clouddns.readwrite+
44
+ #
45
+ # === Returns
46
+ #
47
+ # Gcloud::Dns::Project
48
+ #
49
+ # === Example
50
+ #
51
+ # require "gcloud"
52
+ #
53
+ # dns = Gcloud.dns "my-dns-project",
54
+ # "/path/to/keyfile.json"
55
+ #
56
+ # zone = dns.zone "example-com"
57
+ #
58
+ def self.dns project = nil, keyfile = nil, options = {}
59
+ project ||= Gcloud::Dns::Project.default_project
60
+ if keyfile.nil?
61
+ credentials = Gcloud::Dns::Credentials.default options
62
+ else
63
+ credentials = Gcloud::Dns::Credentials.new keyfile, options
64
+ end
65
+ Gcloud::Dns::Project.new project, credentials
66
+ end
67
+
68
+ ##
69
+ # = Google Cloud DNS
70
+ #
71
+ # Google Cloud DNS is a high-performance, resilient, global DNS service that
72
+ # provides a cost-effective way to make your applications and services
73
+ # available to your users. This programmable, authoritative DNS service can be
74
+ # used to easily publish and manage DNS records using the same infrastructure
75
+ # relied upon by Google. To learn more, read {What is Google Cloud
76
+ # DNS?}[https://cloud.google.com/dns/what-is-cloud-dns].
77
+ #
78
+ # Gcloud's goal is to provide an API that is familiar and comfortable to
79
+ # Rubyists. Authentication is handled by Gcloud#dns. You can provide
80
+ # the project and credential information to connect to the Cloud DNS service,
81
+ # or if you are running on Google Compute Engine this configuration is taken
82
+ # care of for you. You can read more about the options for connecting in the
83
+ # {Authentication Guide}[link:AUTHENTICATION.md].
84
+ #
85
+ # == Creating Zones
86
+ #
87
+ # To get started with Google Cloud DNS, use your DNS Project to create a new
88
+ # Zone. The second argument to Project#create_zone must be a unique
89
+ # domain name for which you can {verify
90
+ # ownership}[https://www.google.com/webmasters/verification/home]. Substitute
91
+ # a domain name of your own (ending with a dot to signify that it is {fully
92
+ # qualified}[https://en.wikipedia.org/wiki/Fully_qualified_domain_name]) as
93
+ # you follow along with these examples.
94
+ #
95
+ # require "gcloud"
96
+ #
97
+ # gcloud = Gcloud.new
98
+ # dns = gcloud.dns
99
+ # zone = dns.create_zone "example-com", "example.com."
100
+ # puts zone.id # unique identifier defined by the server
101
+ #
102
+ # For more information, see {Managing
103
+ # Zones}[https://cloud.google.com/dns/zones/].
104
+ #
105
+ # == Listing Zones
106
+ #
107
+ # You can retrieve all the zones in your project.
108
+ #
109
+ # require "gcloud"
110
+ #
111
+ # gcloud = Gcloud.new
112
+ # dns = gcloud.dns
113
+ # zones = dns.zones
114
+ # zones.each do |zone|
115
+ # puts "#{zone.name} - #{zone.dns}"
116
+ # end
117
+ #
118
+ # You can also retrieve a single zone by either name or id.
119
+ #
120
+ # require "gcloud"
121
+ #
122
+ # gcloud = Gcloud.new
123
+ # dns = gcloud.dns
124
+ # zone = dns.zone "example-com"
125
+ #
126
+ # == Listing Records
127
+ #
128
+ # When you create a zone, the Cloud DNS service automatically creates two
129
+ # Record instances for it, providing configuration for Cloud DNS nameservers.
130
+ # Let's take a look at these records.
131
+ #
132
+ # require "gcloud"
133
+ #
134
+ # gcloud = Gcloud.new
135
+ # dns = gcloud.dns
136
+ # zone = dns.zone "example-com"
137
+ # records = zone.records
138
+ # records.count #=> 2
139
+ # records.map &:type #=> ["NS", "SOA"]
140
+ # zone.records.first.data.count #=> 4
141
+ # zone.records.first.data #=> ["ns-cloud-d1.googledomains.com.", ...]
142
+ #
143
+ # Note that Record#data returns an array. The Cloud DNS service only allows
144
+ # the zone to have one Record instance for each name and type combination. It
145
+ # supports multiple "resource records" (in this case, the four nameserver
146
+ # addresses) via this +data+ collection.
147
+ #
148
+ # == Managing Records
149
+ #
150
+ # You can easily add your own records to the zone. Each call to Zone#add
151
+ # results in a new Cloud DNS Change instance.
152
+ #
153
+ # require "gcloud"
154
+ #
155
+ # gcloud = Gcloud.new
156
+ # dns = gcloud.dns
157
+ # zone = dns.zone "example-com"
158
+ # change = zone.add "www", "A", 86400, ["1.2.3.4"]
159
+ # change.additions.map &:type #=> ["A", "SOA"]
160
+ # change.deletions.map &:type #=> ["SOA"]
161
+ #
162
+ # Whenever you change the set of records belonging to a zone, the zone's start
163
+ # of authority (SOA) record should be updated with a higher serial number. The
164
+ # gcloud library automates this update for you, deleting the old SOA record
165
+ # and adding an updated one, as shown in the example above. You can disable or
166
+ # modify this behavior, of course. See Zone#update for details.
167
+ #
168
+ # You can retrieve records by name and type. The name argument can be a
169
+ # subdomain (e.g., +www+) fragment for convenience, but notice that the
170
+ # retrieved record's domain name is always fully-qualified.
171
+ #
172
+ # require "gcloud"
173
+ #
174
+ # gcloud = Gcloud.new
175
+ # dns = gcloud.dns
176
+ # zone = dns.zone "example-com"
177
+ # records = zone.records "www", "A"
178
+ # records.first.name #=> "www.example.com."
179
+ #
180
+ # You can use Zone#replace to update the +ttl+ and +data+ for a record.
181
+ #
182
+ # require "gcloud"
183
+ #
184
+ # gcloud = Gcloud.new
185
+ # dns = gcloud.dns
186
+ # zone = dns.zone "example-com"
187
+ # change = zone.replace "www", "A", 86400, ["5.6.7.8"]
188
+ #
189
+ # Or, you can use Zone#modify to update just the +ttl+ or +data+, without the
190
+ # risk of inadvertently changing values that you wish to leave unchanged.
191
+ #
192
+ # require "gcloud"
193
+ #
194
+ # gcloud = Gcloud.new
195
+ # dns = gcloud.dns
196
+ # zone = dns.zone "example-com"
197
+ # change = zone.modify "www", "A" do |r|
198
+ # r.ttl = 3600 # change only the TTL
199
+ # end
200
+ #
201
+ # You can also delete records by name and type.
202
+ #
203
+ # require "gcloud"
204
+ #
205
+ # gcloud = Gcloud.new
206
+ # dns = gcloud.dns
207
+ # zone = dns.zone "example-com"
208
+ # change = zone.remove "www", "A"
209
+ # record = change.deletions.first
210
+ #
211
+ # The best way to add, remove, and update multiple records in a single
212
+ # {transaction}[https://cloud.google.com/dns/records] is to call Zone#update
213
+ # with a block. See Zone::Transaction.
214
+ #
215
+ # require "gcloud"
216
+ #
217
+ # gcloud = Gcloud.new
218
+ # dns = gcloud.dns
219
+ # zone = dns.zone "example-com"
220
+ # change = zone.update do |tx|
221
+ # tx.add "www", "A", 86400, "1.2.3.4"
222
+ # tx.remove "example.com.", "TXT"
223
+ # tx.replace "example.com.", "MX", 86400, ["10 mail1.example.com.",
224
+ # "20 mail2.example.com."]
225
+ # tx.modify "www.example.com.", "CNAME" do |r|
226
+ # r.ttl = 86400 # only change the TTL
227
+ # end
228
+ # end
229
+ #
230
+ # Finally, you can add and delete records by reference, using Zone#update.
231
+ #
232
+ # require "gcloud"
233
+ #
234
+ # gcloud = Gcloud.new
235
+ # dns = gcloud.dns
236
+ # zone = dns.zone "example-com"
237
+ # to_add = zone.record "www", "AAAA", 86400, ["2607:f8b0:400a:801::1005"]
238
+ # to_delete = zone.records "www", "A"
239
+ # change = zone.update to_add, to_delete
240
+ #
241
+ # == Listing Changes
242
+ #
243
+ # Because the transactions you execute against your zone do not always
244
+ # complete immediately, you can retrieve and inspect changes.
245
+ #
246
+ # require "gcloud"
247
+ #
248
+ # gcloud = Gcloud.new
249
+ # dns = gcloud.dns
250
+ # zone = dns.zone "example-com"
251
+ # changes = zone.changes
252
+ # changes.each do |change|
253
+ # puts "#{change.id} - #{change.started_at} - #{change.status}"
254
+ # end
255
+ #
256
+ # == Importing and exporting zone files
257
+ #
258
+ # You can import from a zone file. Because the Cloud DNS service only allows
259
+ # the zone to have one Record instance for each name and type combination,
260
+ # lines may be merged as needed into records with multiple +data+ values.
261
+ #
262
+ # require "gcloud"
263
+ #
264
+ # gcloud = Gcloud.new
265
+ # dns = gcloud.dns
266
+ # zone = dns.zone "example-com"
267
+ # change = zone.import "path/to/db.example.com"
268
+ #
269
+ # You can also export to a zone file.
270
+ #
271
+ # require "gcloud"
272
+ #
273
+ # gcloud = Gcloud.new
274
+ # dns = gcloud.dns
275
+ # zone = dns.zone "example-com"
276
+ #
277
+ # zone.export "path/to/db.example.com"
278
+ module Dns
279
+ end
280
+ end