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 2014 Google Inc. All rights reserved.
3
2
  #
4
3
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,21 +12,22 @@
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 Datastore
18
18
  ##
19
- # = Transaction
19
+ # # Transaction
20
20
  #
21
21
  # Special Connection instance for running transactions.
22
22
  #
23
- # See Gcloud::Datastore::Dataset.transaction
23
+ # See {Gcloud::Datastore::Dataset#transaction}
24
24
  class Transaction < Dataset
25
25
  attr_reader :id
26
26
 
27
27
  ##
28
- # Creates a new Transaction instance.
28
+ # @private Creates a new Transaction instance.
29
29
  # Takes a Connection instead of project and Credentials.
30
- def initialize connection #:nodoc:
30
+ def initialize connection
31
31
  @connection = connection
32
32
  reset!
33
33
  start
@@ -36,11 +36,13 @@ module Gcloud
36
36
  ##
37
37
  # Persist entities in a transaction.
38
38
  #
39
+ # @example
39
40
  # dataset.transaction do |tx|
40
41
  # if tx.find(user.key).nil?
41
42
  # tx.save task1, task2
42
43
  # end
43
44
  # end
45
+ #
44
46
  def save *entities
45
47
  save_entities_to_mutation entities, shared_mutation
46
48
  # Do not save or assign auto_ids yet
@@ -50,11 +52,13 @@ module Gcloud
50
52
  ##
51
53
  # Remove entities in a transaction.
52
54
  #
55
+ # @example
53
56
  # dataset.transaction do |tx|
54
57
  # if tx.find(user.key).nil?
55
58
  # tx.delete task1, task2
56
59
  # end
57
60
  # end
61
+ #
58
62
  def delete *entities
59
63
  shared_mutation.tap do |m|
60
64
  m.delete = entities.map { |entity| entity.key.to_proto }
@@ -99,7 +103,7 @@ module Gcloud
99
103
 
100
104
  ##
101
105
  # Reset the transaction.
102
- # Transaction#start must be called afterwards.
106
+ # {Transaction#start} must be called afterwards.
103
107
  def reset!
104
108
  @shared_mutation = nil
105
109
  @id = nil
@@ -109,9 +113,9 @@ module Gcloud
109
113
  protected
110
114
 
111
115
  ##
112
- # Mutation to be shared across save, delete, and commit calls.
116
+ # @private Mutation to be shared across save, delete, and commit calls.
113
117
  # This enables updates to happen when commit is called.
114
- def shared_mutation #:nodoc:
118
+ def shared_mutation
115
119
  @shared_mutation ||= Proto.new_mutation
116
120
  end
117
121
  end
data/lib/gcloud/dns.rb CHANGED
@@ -12,40 +12,34 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+
15
16
  require "gcloud"
16
17
  require "gcloud/dns/project"
17
18
 
18
- #--
19
- # Google Cloud DNS
20
19
  module Gcloud
21
20
  ##
22
- # Creates a new +Project+ instance connected to the DNS service.
21
+ # Creates a new `Project` instance connected to the DNS service.
23
22
  # Each call creates a new connection.
24
23
  #
25
- # === Parameters
24
+ # For more information on connecting to Google Cloud see the [Authentication
25
+ # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
26
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
- # +scope+::
34
- # The OAuth 2.0 scopes controlling the set of resources and operations that
35
- # the connection can access. See {Using OAuth 2.0 to Access Google
36
- # APIs}[https://developers.google.com/identity/protocols/OAuth2]. (+String+
37
- # or +Array+)
27
+ # @param [String] project Identifier for a DNS project. If not present, the
28
+ # default project for the credentials is used.
29
+ # @param [String, Hash] keyfile Keyfile downloaded from Google Cloud. If file
30
+ # path the file must be readable.
31
+ # @param [String, Array<String>] scope The OAuth 2.0 scopes controlling the
32
+ # set of resources and operations that the connection can access. See [Using
33
+ # OAuth 2.0 to Access Google
34
+ # APIs](https://developers.google.com/identity/protocols/OAuth2).
38
35
  #
39
36
  # The default scope is:
40
37
  #
41
- # * +https://www.googleapis.com/auth/ndev.clouddns.readwrite+
42
- #
43
- # === Returns
44
- #
45
- # Gcloud::Dns::Project
38
+ # * `https://www.googleapis.com/auth/ndev.clouddns.readwrite`
46
39
  #
47
- # === Example
40
+ # @return [Gcloud::Dns::Project]
48
41
  #
42
+ # @example
49
43
  # require "gcloud"
50
44
  #
51
45
  # dns = Gcloud.dns "my-dns-project",
@@ -64,215 +58,249 @@ module Gcloud
64
58
  end
65
59
 
66
60
  ##
67
- # = Google Cloud DNS
61
+ # # Google Cloud DNS
68
62
  #
69
63
  # Google Cloud DNS is a high-performance, resilient, global DNS service that
70
64
  # provides a cost-effective way to make your applications and services
71
65
  # available to your users. This programmable, authoritative DNS service can be
72
66
  # used to easily publish and manage DNS records using the same infrastructure
73
- # relied upon by Google. To learn more, read {What is Google Cloud
74
- # DNS?}[https://cloud.google.com/dns/what-is-cloud-dns].
67
+ # relied upon by Google. To learn more, read [What is Google Cloud
68
+ # DNS?](https://cloud.google.com/dns/what-is-cloud-dns).
75
69
  #
76
70
  # Gcloud's goal is to provide an API that is familiar and comfortable to
77
- # Rubyists. Authentication is handled by Gcloud#dns. You can provide
78
- # the project and credential information to connect to the Cloud DNS service,
79
- # or if you are running on Google Compute Engine this configuration is taken
80
- # care of for you. You can read more about the options for connecting in the
81
- # {Authentication Guide}[link:AUTHENTICATION.md].
71
+ # Rubyists. Authentication is handled by {Gcloud#dns}. You can provide the
72
+ # project and credential information to connect to the Cloud DNS service, or
73
+ # if you are running on Google Compute Engine this configuration is taken care
74
+ # of for you. You can read more about the options for connecting in the
75
+ # [Authentication
76
+ # Guide](https://googlecloudplatform.github.io/gcloud-ruby/#/docs/guides/authentication).
82
77
  #
83
- # == Creating Zones
78
+ # ## Creating Zones
84
79
  #
85
80
  # To get started with Google Cloud DNS, use your DNS Project to create a new
86
- # Zone. The second argument to Project#create_zone must be a unique
87
- # domain name for which you can {verify
88
- # ownership}[https://www.google.com/webmasters/verification/home]. Substitute
89
- # a domain name of your own (ending with a dot to signify that it is {fully
90
- # qualified}[https://en.wikipedia.org/wiki/Fully_qualified_domain_name]) as
81
+ # Zone. The second argument to {Gcloud::Dns::Project#create_zone} must be a
82
+ # unique domain name for which you can [verify
83
+ # ownership](https://www.google.com/webmasters/verification/home). Substitute
84
+ # a domain name of your own (ending with a dot to signify that it is [fully
85
+ # qualified](https://en.wikipedia.org/wiki/Fully_qualified_domain_name)) as
91
86
  # you follow along with these examples.
92
87
  #
93
- # require "gcloud"
88
+ # ```ruby
89
+ # require "gcloud"
94
90
  #
95
- # gcloud = Gcloud.new
96
- # dns = gcloud.dns
97
- # zone = dns.create_zone "example-com", "example.com."
98
- # puts zone.id # unique identifier defined by the server
91
+ # gcloud = Gcloud.new
92
+ # dns = gcloud.dns
93
+ # zone = dns.create_zone "example-com", "example.com."
94
+ # puts zone.id # unique identifier defined by the server
95
+ # ```
99
96
  #
100
- # For more information, see {Managing
101
- # Zones}[https://cloud.google.com/dns/zones/].
97
+ # For more information, see [Managing
98
+ # Zones](https://cloud.google.com/dns/zones/).
102
99
  #
103
- # == Listing Zones
100
+ # ## Listing Zones
104
101
  #
105
102
  # You can retrieve all the zones in your project.
106
103
  #
107
- # require "gcloud"
104
+ # ```ruby
105
+ # require "gcloud"
108
106
  #
109
- # gcloud = Gcloud.new
110
- # dns = gcloud.dns
111
- # zones = dns.zones
112
- # zones.each do |zone|
113
- # puts "#{zone.name} - #{zone.dns}"
114
- # end
107
+ # gcloud = Gcloud.new
108
+ # dns = gcloud.dns
109
+ # zones = dns.zones
110
+ # zones.each do |zone|
111
+ # puts "#{zone.name} - #{zone.dns}"
112
+ # end
113
+ # ```
115
114
  #
116
115
  # You can also retrieve a single zone by either name or id.
117
116
  #
118
- # require "gcloud"
117
+ # ```ruby
118
+ # require "gcloud"
119
119
  #
120
- # gcloud = Gcloud.new
121
- # dns = gcloud.dns
122
- # zone = dns.zone "example-com"
120
+ # gcloud = Gcloud.new
121
+ # dns = gcloud.dns
122
+ # zone = dns.zone "example-com"
123
+ # ```
123
124
  #
124
- # == Listing Records
125
+ # ## Listing Records
125
126
  #
126
127
  # When you create a zone, the Cloud DNS service automatically creates two
127
128
  # Record instances for it, providing configuration for Cloud DNS nameservers.
128
129
  # Let's take a look at these records.
129
130
  #
130
- # require "gcloud"
131
+ # ```ruby
132
+ # require "gcloud"
131
133
  #
132
- # gcloud = Gcloud.new
133
- # dns = gcloud.dns
134
- # zone = dns.zone "example-com"
135
- # records = zone.records
136
- # records.count #=> 2
137
- # records.map &:type #=> ["NS", "SOA"]
138
- # zone.records.first.data.count #=> 4
139
- # zone.records.first.data #=> ["ns-cloud-d1.googledomains.com.", ...]
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
+ # ```
140
143
  #
141
- # Note that Record#data returns an array. The Cloud DNS service only allows
142
- # the zone to have one Record instance for each name and type combination. It
143
- # supports multiple "resource records" (in this case, the four nameserver
144
- # addresses) via this +data+ collection.
144
+ # Note that {Gcloud::Dns::Record#data} returns an array. The Cloud DNS service
145
+ # only allows the zone to have one Record instance for each name and type
146
+ # combination. It supports multiple "resource records" (in this case, the four
147
+ # nameserver addresses) via this `data` collection.
145
148
  #
146
- # == Managing Records
149
+ # ## Managing Records
147
150
  #
148
- # You can easily add your own records to the zone. Each call to Zone#add
149
- # results in a new Cloud DNS Change instance.
151
+ # You can easily add your own records to the zone. Each call to
152
+ # {Gcloud::Dns::Zone#add} results in a new Cloud DNS Change instance.
150
153
  #
151
- # require "gcloud"
154
+ # ```ruby
155
+ # require "gcloud"
152
156
  #
153
- # gcloud = Gcloud.new
154
- # dns = gcloud.dns
155
- # zone = dns.zone "example-com"
156
- # change = zone.add "www", "A", 86400, ["1.2.3.4"]
157
- # change.additions.map &:type #=> ["A", "SOA"]
158
- # change.deletions.map &:type #=> ["SOA"]
157
+ # gcloud = Gcloud.new
158
+ # dns = gcloud.dns
159
+ # zone = dns.zone "example-com"
160
+ # change = zone.add "www", "A", 86400, ["1.2.3.4"]
161
+ # change.additions.map &:type #=> ["A", "SOA"]
162
+ # change.deletions.map &:type #=> ["SOA"]
163
+ # ```
159
164
  #
160
165
  # Whenever you change the set of records belonging to a zone, the zone's start
161
166
  # of authority (SOA) record should be updated with a higher serial number. The
162
167
  # gcloud library automates this update for you, deleting the old SOA record
163
168
  # and adding an updated one, as shown in the example above. You can disable or
164
- # modify this behavior, of course. See Zone#update for details.
169
+ # modify this behavior, of course. See {Gcloud::Dns::Zone#update} for details.
165
170
  #
166
171
  # You can retrieve records by name and type. The name argument can be a
167
- # subdomain (e.g., +www+) fragment for convenience, but notice that the
172
+ # subdomain (e.g., `www`) fragment for convenience, but notice that the
168
173
  # retrieved record's domain name is always fully-qualified.
169
174
  #
170
- # require "gcloud"
175
+ # ```ruby
176
+ # require "gcloud"
171
177
  #
172
- # gcloud = Gcloud.new
173
- # dns = gcloud.dns
174
- # zone = dns.zone "example-com"
175
- # records = zone.records "www", "A"
176
- # records.first.name #=> "www.example.com."
178
+ # gcloud = Gcloud.new
179
+ # dns = gcloud.dns
180
+ # zone = dns.zone "example-com"
181
+ # records = zone.records "www", "A"
182
+ # records.first.name #=> "www.example.com."
183
+ # ```
177
184
  #
178
- # You can use Zone#replace to update the +ttl+ and +data+ for a record.
185
+ # You can use {Gcloud::Dns::Zone#replace} to update the `ttl` and `data` for a
186
+ # record.
179
187
  #
180
- # require "gcloud"
188
+ # ```ruby
189
+ # require "gcloud"
181
190
  #
182
- # gcloud = Gcloud.new
183
- # dns = gcloud.dns
184
- # zone = dns.zone "example-com"
185
- # change = zone.replace "www", "A", 86400, ["5.6.7.8"]
191
+ # gcloud = Gcloud.new
192
+ # dns = gcloud.dns
193
+ # zone = dns.zone "example-com"
194
+ # change = zone.replace "www", "A", 86400, ["5.6.7.8"]
195
+ # ```
186
196
  #
187
- # Or, you can use Zone#modify to update just the +ttl+ or +data+, without the
188
- # risk of inadvertently changing values that you wish to leave unchanged.
197
+ # Or, you can use {Gcloud::Dns::Zone#modify} to update just the `ttl` or
198
+ # `data`, without the risk of inadvertently changing values that you wish to
199
+ # leave unchanged.
189
200
  #
190
- # require "gcloud"
201
+ # ```ruby
202
+ # require "gcloud"
191
203
  #
192
- # gcloud = Gcloud.new
193
- # dns = gcloud.dns
194
- # zone = dns.zone "example-com"
195
- # change = zone.modify "www", "A" do |r|
196
- # r.ttl = 3600 # change only the TTL
197
- # end
204
+ # gcloud = Gcloud.new
205
+ # dns = gcloud.dns
206
+ # zone = dns.zone "example-com"
207
+ # change = zone.modify "www", "A" do |r|
208
+ # r.ttl = 3600 # change only the TTL
209
+ # end
210
+ # ```
198
211
  #
199
212
  # You can also delete records by name and type.
200
213
  #
201
- # require "gcloud"
214
+ # ```ruby
215
+ # require "gcloud"
202
216
  #
203
- # gcloud = Gcloud.new
204
- # dns = gcloud.dns
205
- # zone = dns.zone "example-com"
206
- # change = zone.remove "www", "A"
207
- # record = change.deletions.first
217
+ # gcloud = Gcloud.new
218
+ # dns = gcloud.dns
219
+ # zone = dns.zone "example-com"
220
+ # change = zone.remove "www", "A"
221
+ # record = change.deletions.first
222
+ # ```
208
223
  #
209
224
  # The best way to add, remove, and update multiple records in a single
210
- # {transaction}[https://cloud.google.com/dns/records] is to call Zone#update
211
- # with a block. See Zone::Transaction.
212
- #
213
- # require "gcloud"
214
- #
215
- # gcloud = Gcloud.new
216
- # dns = gcloud.dns
217
- # zone = dns.zone "example-com"
218
- # change = zone.update do |tx|
219
- # tx.add "www", "A", 86400, "1.2.3.4"
220
- # tx.remove "example.com.", "TXT"
221
- # tx.replace "example.com.", "MX", 86400, ["10 mail1.example.com.",
222
- # "20 mail2.example.com."]
223
- # tx.modify "www.example.com.", "CNAME" do |r|
224
- # r.ttl = 86400 # only change the TTL
225
- # end
225
+ # [transaction](https://cloud.google.com/dns/records) is to call
226
+ # {Gcloud::Dns::Zone#update} with a block. See
227
+ # {Gcloud::Dns::Zone::Transaction}.
228
+ #
229
+ # ```ruby
230
+ # require "gcloud"
231
+ #
232
+ # gcloud = Gcloud.new
233
+ # dns = gcloud.dns
234
+ # zone = dns.zone "example-com"
235
+ # change = zone.update do |tx|
236
+ # tx.add "www", "A", 86400, "1.2.3.4"
237
+ # tx.remove "example.com.", "TXT"
238
+ # tx.replace "example.com.", "MX", 86400, ["10 mail1.example.com.",
239
+ # "20 mail2.example.com."]
240
+ # tx.modify "www.example.com.", "CNAME" do |r|
241
+ # r.ttl = 86400 # only change the TTL
226
242
  # end
243
+ # end
244
+ # ```
227
245
  #
228
- # Finally, you can add and delete records by reference, using Zone#update.
246
+ # Finally, you can add and delete records by reference, using
247
+ # {Gcloud::Dns::Zone#update}.
229
248
  #
230
- # require "gcloud"
249
+ # ```ruby
250
+ # require "gcloud"
231
251
  #
232
- # gcloud = Gcloud.new
233
- # dns = gcloud.dns
234
- # zone = dns.zone "example-com"
235
- # to_add = zone.record "www", "AAAA", 86400, ["2607:f8b0:400a:801::1005"]
236
- # to_delete = zone.records "www", "A"
237
- # change = zone.update to_add, to_delete
252
+ # gcloud = Gcloud.new
253
+ # dns = gcloud.dns
254
+ # zone = dns.zone "example-com"
255
+ # to_add = zone.record "www", "AAAA", 86400, ["2607:f8b0:400a:801::1005"]
256
+ # to_delete = zone.records "www", "A"
257
+ # change = zone.update to_add, to_delete
258
+ # ```
238
259
  #
239
- # == Listing Changes
260
+ # ## Listing Changes
240
261
  #
241
262
  # Because the transactions you execute against your zone do not always
242
263
  # complete immediately, you can retrieve and inspect changes.
243
264
  #
244
- # require "gcloud"
265
+ # ```ruby
266
+ # require "gcloud"
245
267
  #
246
- # gcloud = Gcloud.new
247
- # dns = gcloud.dns
248
- # zone = dns.zone "example-com"
249
- # changes = zone.changes
250
- # changes.each do |change|
251
- # puts "#{change.id} - #{change.started_at} - #{change.status}"
252
- # end
268
+ # gcloud = Gcloud.new
269
+ # dns = gcloud.dns
270
+ # zone = dns.zone "example-com"
271
+ # changes = zone.changes
272
+ # changes.each do |change|
273
+ # puts "#{change.id} - #{change.started_at} - #{change.status}"
274
+ # end
275
+ # ```
253
276
  #
254
- # == Importing and exporting zone files
277
+ # ## Importing and exporting zone files
255
278
  #
256
279
  # You can import from a zone file. Because the Cloud DNS service only allows
257
280
  # the zone to have one Record instance for each name and type combination,
258
- # lines may be merged as needed into records with multiple +data+ values.
281
+ # lines may be merged as needed into records with multiple `data` values.
259
282
  #
260
- # require "gcloud"
283
+ # ```ruby
284
+ # require "gcloud"
261
285
  #
262
- # gcloud = Gcloud.new
263
- # dns = gcloud.dns
264
- # zone = dns.zone "example-com"
265
- # change = zone.import "path/to/db.example.com"
286
+ # gcloud = Gcloud.new
287
+ # dns = gcloud.dns
288
+ # zone = dns.zone "example-com"
289
+ # change = zone.import "path/to/db.example.com"
290
+ # ```
266
291
  #
267
292
  # You can also export to a zone file.
268
293
  #
269
- # require "gcloud"
294
+ # ```ruby
295
+ # require "gcloud"
270
296
  #
271
- # gcloud = Gcloud.new
272
- # dns = gcloud.dns
273
- # zone = dns.zone "example-com"
297
+ # gcloud = Gcloud.new
298
+ # dns = gcloud.dns
299
+ # zone = dns.zone "example-com"
300
+ #
301
+ # zone.export "path/to/db.example.com"
302
+ # ```
274
303
  #
275
- # zone.export "path/to/db.example.com"
276
304
  module Dns
277
305
  end
278
306
  end