gcloud 0.6.3 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/AUTHENTICATION.md +13 -9
- data/CHANGELOG.md +8 -3
- data/OVERVIEW.md +46 -8
- data/lib/gcloud.rb +123 -117
- data/lib/gcloud/backoff.rb +43 -15
- data/lib/gcloud/bigquery.rb +211 -195
- data/lib/gcloud/bigquery/connection.rb +9 -9
- data/lib/gcloud/bigquery/copy_job.rb +15 -16
- data/lib/gcloud/bigquery/credentials.rb +3 -3
- data/lib/gcloud/bigquery/data.rb +12 -11
- data/lib/gcloud/bigquery/dataset.rb +162 -216
- data/lib/gcloud/bigquery/dataset/access.rb +59 -43
- data/lib/gcloud/bigquery/dataset/list.rb +3 -3
- data/lib/gcloud/bigquery/errors.rb +9 -5
- data/lib/gcloud/bigquery/extract_job.rb +18 -18
- data/lib/gcloud/bigquery/insert_response.rb +7 -4
- data/lib/gcloud/bigquery/job.rb +48 -44
- data/lib/gcloud/bigquery/job/list.rb +3 -3
- data/lib/gcloud/bigquery/load_job.rb +24 -25
- data/lib/gcloud/bigquery/project.rb +145 -204
- data/lib/gcloud/bigquery/query_data.rb +10 -9
- data/lib/gcloud/bigquery/query_job.rb +23 -32
- data/lib/gcloud/bigquery/table.rb +238 -280
- data/lib/gcloud/bigquery/table/list.rb +3 -3
- data/lib/gcloud/bigquery/table/schema.rb +79 -87
- data/lib/gcloud/bigquery/view.rb +69 -82
- data/lib/gcloud/credentials.rb +3 -9
- data/lib/gcloud/datastore.rb +194 -170
- data/lib/gcloud/datastore/connection.rb +12 -8
- data/lib/gcloud/datastore/credentials.rb +6 -4
- data/lib/gcloud/datastore/dataset.rb +74 -141
- data/lib/gcloud/datastore/dataset/lookup_results.rb +6 -4
- data/lib/gcloud/datastore/dataset/query_results.rb +6 -4
- data/lib/gcloud/datastore/entity.rb +81 -76
- data/lib/gcloud/datastore/errors.rb +10 -8
- data/lib/gcloud/datastore/key.rb +41 -77
- data/lib/gcloud/datastore/properties.rb +3 -3
- data/lib/gcloud/datastore/proto.rb +7 -4
- data/lib/gcloud/datastore/query.rb +26 -3
- data/lib/gcloud/datastore/transaction.rb +12 -8
- data/lib/gcloud/dns.rb +180 -152
- data/lib/gcloud/dns/change.rb +16 -16
- data/lib/gcloud/dns/change/list.rb +3 -3
- data/lib/gcloud/dns/connection.rb +9 -10
- data/lib/gcloud/dns/credentials.rb +3 -3
- data/lib/gcloud/dns/errors.rb +9 -5
- data/lib/gcloud/dns/importer.rb +17 -23
- data/lib/gcloud/dns/project.rb +42 -64
- data/lib/gcloud/dns/record.rb +58 -46
- data/lib/gcloud/dns/record/list.rb +6 -7
- data/lib/gcloud/dns/zone.rb +198 -289
- data/lib/gcloud/dns/zone/list.rb +3 -3
- data/lib/gcloud/dns/zone/transaction.rb +56 -72
- data/lib/gcloud/errors.rb +174 -3
- data/lib/gcloud/gce.rb +3 -4
- data/lib/gcloud/grpc_utils.rb +76 -0
- data/lib/gcloud/logging.rb +308 -0
- data/lib/gcloud/logging/credentials.rb +29 -0
- data/lib/gcloud/logging/entry.rb +303 -0
- data/lib/gcloud/logging/entry/http_request.rb +141 -0
- data/lib/gcloud/logging/entry/list.rb +111 -0
- data/lib/gcloud/logging/entry/operation.rb +90 -0
- data/lib/gcloud/logging/logger.rb +307 -0
- data/lib/gcloud/logging/metric.rb +175 -0
- data/lib/gcloud/logging/metric/list.rb +98 -0
- data/lib/gcloud/logging/project.rb +650 -0
- data/lib/gcloud/logging/resource.rb +95 -0
- data/lib/gcloud/logging/resource_descriptor.rb +140 -0
- data/lib/gcloud/logging/resource_descriptor/list.rb +78 -0
- data/lib/gcloud/logging/service.rb +258 -0
- data/lib/gcloud/logging/sink.rb +233 -0
- data/lib/gcloud/logging/sink/list.rb +97 -0
- data/lib/gcloud/pubsub.rb +241 -199
- data/lib/gcloud/pubsub/credentials.rb +3 -3
- data/lib/gcloud/pubsub/message.rb +26 -20
- data/lib/gcloud/pubsub/project.rb +166 -233
- data/lib/gcloud/pubsub/received_message.rb +28 -38
- data/lib/gcloud/pubsub/service.rb +323 -0
- data/lib/gcloud/pubsub/subscription.rb +172 -242
- data/lib/gcloud/pubsub/subscription/list.rb +11 -9
- data/lib/gcloud/pubsub/topic.rb +152 -271
- data/lib/gcloud/pubsub/topic/batch.rb +66 -0
- data/lib/gcloud/pubsub/topic/list.rb +9 -7
- data/lib/gcloud/resource_manager.rb +158 -138
- data/lib/gcloud/resource_manager/connection.rb +6 -5
- data/lib/gcloud/resource_manager/credentials.rb +3 -3
- data/lib/gcloud/resource_manager/errors.rb +9 -5
- data/lib/gcloud/resource_manager/manager.rb +54 -86
- data/lib/gcloud/resource_manager/project.rb +69 -88
- data/lib/gcloud/resource_manager/project/list.rb +4 -5
- data/lib/gcloud/resource_manager/project/updater.rb +12 -14
- data/lib/gcloud/search.rb +158 -135
- data/lib/gcloud/search/api_client.rb +7 -7
- data/lib/gcloud/search/connection.rb +8 -8
- data/lib/gcloud/search/credentials.rb +3 -3
- data/lib/gcloud/search/document.rb +64 -87
- data/lib/gcloud/search/document/list.rb +5 -5
- data/lib/gcloud/search/errors.rb +9 -5
- data/lib/gcloud/search/field_value.rb +32 -38
- data/lib/gcloud/search/field_values.rb +50 -80
- data/lib/gcloud/search/fields.rb +44 -65
- data/lib/gcloud/search/index.rb +163 -204
- data/lib/gcloud/search/index/list.rb +5 -5
- data/lib/gcloud/search/project.rb +31 -47
- data/lib/gcloud/search/result.rb +27 -31
- data/lib/gcloud/search/result/list.rb +6 -6
- data/lib/gcloud/storage.rb +224 -190
- data/lib/gcloud/storage/bucket.rb +202 -227
- data/lib/gcloud/storage/bucket/acl.rb +83 -170
- data/lib/gcloud/storage/bucket/cors.rb +31 -34
- data/lib/gcloud/storage/bucket/list.rb +3 -3
- data/lib/gcloud/storage/connection.rb +11 -7
- data/lib/gcloud/storage/credentials.rb +3 -3
- data/lib/gcloud/storage/errors.rb +11 -8
- data/lib/gcloud/storage/file.rb +129 -171
- data/lib/gcloud/storage/file/acl.rb +51 -99
- data/lib/gcloud/storage/file/list.rb +3 -3
- data/lib/gcloud/storage/file/verifier.rb +3 -2
- data/lib/gcloud/storage/project.rb +111 -132
- data/lib/gcloud/upload.rb +4 -7
- data/lib/gcloud/version.rb +2 -4
- data/lib/google/api/annotations.rb +14 -0
- data/lib/google/api/http.rb +30 -0
- data/lib/google/api/label.rb +24 -0
- data/lib/google/api/monitored_resource.rb +25 -0
- data/lib/google/datastore/v1beta3/datastore.rb +115 -0
- data/lib/google/datastore/v1beta3/datastore_services.rb +33 -0
- data/lib/google/datastore/v1beta3/entity.rb +63 -0
- data/lib/google/datastore/v1beta3/query.rb +128 -0
- data/lib/google/devtools/cloudtrace/v1/trace.rb +78 -0
- data/lib/google/devtools/cloudtrace/v1/trace_services.rb +32 -0
- data/lib/google/example/library/v1/library.rb +91 -0
- data/lib/google/example/library/v1/library_services.rb +40 -0
- data/lib/google/iam/v1/iam_policy.rb +33 -0
- data/lib/google/iam/v1/iam_policy_services.rb +30 -0
- data/lib/google/iam/v1/policy.rb +25 -0
- data/lib/google/logging/type/http_request.rb +28 -0
- data/lib/google/logging/type/log_severity.rb +27 -0
- data/lib/google/logging/v2/log_entry.rb +44 -0
- data/lib/google/logging/v2/logging.rb +56 -0
- data/lib/google/logging/v2/logging_config.rb +59 -0
- data/lib/google/logging/v2/logging_config_services.rb +32 -0
- data/lib/google/logging/v2/logging_metrics.rb +51 -0
- data/lib/google/logging/v2/logging_metrics_services.rb +32 -0
- data/lib/google/logging/v2/logging_services.rb +31 -0
- data/lib/google/longrunning/operations.rb +50 -0
- data/lib/google/longrunning/operations_services.rb +29 -0
- data/lib/google/protobuf/any.rb +17 -0
- data/lib/google/protobuf/api.rb +31 -0
- data/lib/google/protobuf/descriptor.rb +0 -0
- data/lib/google/protobuf/duration.rb +17 -0
- data/lib/google/protobuf/empty.rb +15 -0
- data/lib/google/protobuf/field_mask.rb +16 -0
- data/lib/google/protobuf/source_context.rb +16 -0
- data/lib/google/protobuf/struct.rb +35 -0
- data/lib/google/protobuf/timestamp.rb +17 -0
- data/lib/google/protobuf/type.rb +79 -0
- data/lib/google/protobuf/wrappers.rb +48 -0
- data/lib/google/pubsub/v1/pubsub.rb +129 -0
- data/lib/google/pubsub/v1/pubsub_services.rb +56 -0
- data/lib/google/pubsub/v1beta2/pubsub.rb +126 -0
- data/lib/google/pubsub/v1beta2/pubsub_services.rb +56 -0
- data/lib/google/rpc/code.rb +32 -0
- data/lib/google/rpc/error_details.rb +61 -0
- data/lib/google/rpc/status.rb +19 -0
- data/lib/google/type/color.rb +20 -0
- data/lib/google/type/date.rb +18 -0
- data/lib/google/type/dayofweek.rb +23 -0
- data/lib/google/type/latlng.rb +17 -0
- data/lib/google/type/money.rb +18 -0
- data/lib/google/type/timeofday.rb +19 -0
- metadata +101 -4
- data/lib/gcloud/pubsub/connection.rb +0 -295
- 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
|
-
#
|
19
|
+
# # Transaction
|
20
20
|
#
|
21
21
|
# Special Connection instance for running transactions.
|
22
22
|
#
|
23
|
-
# See Gcloud::Datastore::Dataset
|
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
|
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
|
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
|
21
|
+
# Creates a new `Project` instance connected to the DNS service.
|
23
22
|
# Each call creates a new connection.
|
24
23
|
#
|
25
|
-
#
|
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
|
-
#
|
28
|
-
#
|
29
|
-
#
|
30
|
-
#
|
31
|
-
#
|
32
|
-
#
|
33
|
-
#
|
34
|
-
#
|
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
|
-
# *
|
42
|
-
#
|
43
|
-
# === Returns
|
44
|
-
#
|
45
|
-
# Gcloud::Dns::Project
|
38
|
+
# * `https://www.googleapis.com/auth/ndev.clouddns.readwrite`
|
46
39
|
#
|
47
|
-
#
|
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
|
-
#
|
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
|
74
|
-
# 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
|
-
#
|
79
|
-
#
|
80
|
-
#
|
81
|
-
#
|
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
|
-
#
|
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
|
87
|
-
# domain name for which you can
|
88
|
-
# ownership
|
89
|
-
# a domain name of your own (ending with a dot to signify that it is
|
90
|
-
# qualified
|
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
|
-
#
|
88
|
+
# ```ruby
|
89
|
+
# require "gcloud"
|
94
90
|
#
|
95
|
-
#
|
96
|
-
#
|
97
|
-
#
|
98
|
-
#
|
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
|
101
|
-
# Zones
|
97
|
+
# For more information, see [Managing
|
98
|
+
# Zones](https://cloud.google.com/dns/zones/).
|
102
99
|
#
|
103
|
-
#
|
100
|
+
# ## Listing Zones
|
104
101
|
#
|
105
102
|
# You can retrieve all the zones in your project.
|
106
103
|
#
|
107
|
-
#
|
104
|
+
# ```ruby
|
105
|
+
# require "gcloud"
|
108
106
|
#
|
109
|
-
#
|
110
|
-
#
|
111
|
-
#
|
112
|
-
#
|
113
|
-
#
|
114
|
-
#
|
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
|
-
#
|
117
|
+
# ```ruby
|
118
|
+
# require "gcloud"
|
119
119
|
#
|
120
|
-
#
|
121
|
-
#
|
122
|
-
#
|
120
|
+
# gcloud = Gcloud.new
|
121
|
+
# dns = gcloud.dns
|
122
|
+
# zone = dns.zone "example-com"
|
123
|
+
# ```
|
123
124
|
#
|
124
|
-
#
|
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
|
-
#
|
131
|
+
# ```ruby
|
132
|
+
# require "gcloud"
|
131
133
|
#
|
132
|
-
#
|
133
|
-
#
|
134
|
-
#
|
135
|
-
#
|
136
|
-
#
|
137
|
-
#
|
138
|
-
#
|
139
|
-
#
|
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
|
142
|
-
# the zone to have one Record instance for each name and type
|
143
|
-
# supports multiple "resource records" (in this case, the four
|
144
|
-
# addresses) via this
|
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
|
-
#
|
149
|
+
# ## Managing Records
|
147
150
|
#
|
148
|
-
# You can easily add your own records to the zone. Each call to
|
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
|
-
#
|
154
|
+
# ```ruby
|
155
|
+
# require "gcloud"
|
152
156
|
#
|
153
|
-
#
|
154
|
-
#
|
155
|
-
#
|
156
|
-
#
|
157
|
-
#
|
158
|
-
#
|
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.,
|
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
|
-
#
|
175
|
+
# ```ruby
|
176
|
+
# require "gcloud"
|
171
177
|
#
|
172
|
-
#
|
173
|
-
#
|
174
|
-
#
|
175
|
-
#
|
176
|
-
#
|
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
|
185
|
+
# You can use {Gcloud::Dns::Zone#replace} to update the `ttl` and `data` for a
|
186
|
+
# record.
|
179
187
|
#
|
180
|
-
#
|
188
|
+
# ```ruby
|
189
|
+
# require "gcloud"
|
181
190
|
#
|
182
|
-
#
|
183
|
-
#
|
184
|
-
#
|
185
|
-
#
|
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
|
188
|
-
# risk of inadvertently changing values that you wish to
|
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
|
-
#
|
201
|
+
# ```ruby
|
202
|
+
# require "gcloud"
|
191
203
|
#
|
192
|
-
#
|
193
|
-
#
|
194
|
-
#
|
195
|
-
#
|
196
|
-
#
|
197
|
-
#
|
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
|
-
#
|
214
|
+
# ```ruby
|
215
|
+
# require "gcloud"
|
202
216
|
#
|
203
|
-
#
|
204
|
-
#
|
205
|
-
#
|
206
|
-
#
|
207
|
-
#
|
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
|
-
#
|
211
|
-
# with a block. See
|
212
|
-
#
|
213
|
-
#
|
214
|
-
#
|
215
|
-
#
|
216
|
-
#
|
217
|
-
#
|
218
|
-
#
|
219
|
-
#
|
220
|
-
#
|
221
|
-
#
|
222
|
-
#
|
223
|
-
#
|
224
|
-
#
|
225
|
-
#
|
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
|
246
|
+
# Finally, you can add and delete records by reference, using
|
247
|
+
# {Gcloud::Dns::Zone#update}.
|
229
248
|
#
|
230
|
-
#
|
249
|
+
# ```ruby
|
250
|
+
# require "gcloud"
|
231
251
|
#
|
232
|
-
#
|
233
|
-
#
|
234
|
-
#
|
235
|
-
#
|
236
|
-
#
|
237
|
-
#
|
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
|
-
#
|
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
|
-
#
|
265
|
+
# ```ruby
|
266
|
+
# require "gcloud"
|
245
267
|
#
|
246
|
-
#
|
247
|
-
#
|
248
|
-
#
|
249
|
-
#
|
250
|
-
#
|
251
|
-
#
|
252
|
-
#
|
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
|
-
#
|
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
|
281
|
+
# lines may be merged as needed into records with multiple `data` values.
|
259
282
|
#
|
260
|
-
#
|
283
|
+
# ```ruby
|
284
|
+
# require "gcloud"
|
261
285
|
#
|
262
|
-
#
|
263
|
-
#
|
264
|
-
#
|
265
|
-
#
|
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
|
-
#
|
294
|
+
# ```ruby
|
295
|
+
# require "gcloud"
|
270
296
|
#
|
271
|
-
#
|
272
|
-
#
|
273
|
-
#
|
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
|