Class: Google::Cloud::Dns::Project

Inherits:
Object
  • Object
show all
Defined in:
lib/google/cloud/dns/project.rb

Overview

Project

The project is a top level container for resources including Cloud DNS ManagedZones. Projects can be created only in the Google Developers Console.

See Google::Cloud#dns

Examples:

require "google/cloud/dns"

dns = Google::Cloud::Dns.new
zone = dns.zone "example-com"
zone.records.each do |record|
  puts record.name
end

Instance Method Summary collapse

Instance Method Details

#additions_per_changeObject

Maximum allowed number of records to add per change.



102
103
104
105
# File 'lib/google/cloud/dns/project.rb', line 102

def additions_per_change
  reload! if @gapi.nil?
  @gapi.quota.rrset_additions_per_change if @gapi.quota
end

#create_zone(zone_name, zone_dns, description: nil, name_server_set: nil) ⇒ Google::Cloud::Dns::Zone

Creates a new zone.

Examples:

require "google/cloud/dns"

dns = Google::Cloud::Dns.new
zone = dns.create_zone "example-com", "example.com."

Parameters:

  • zone_name (String)

    User assigned name for this resource. Must be unique within the project. The name must be 1-32 characters long, must begin with a letter, end with a letter or digit, and only contain lowercase letters, digits or dashes.

  • zone_dns (String)

    The DNS name of this managed zone, for instance "example.com.".

  • description (String)

    A string of at most 1024 characters associated with this resource for the user's convenience. Has no effect on the managed zone's function.

  • name_server_set (String)

    A NameServerSet is a set of DNS name servers that all host the same ManagedZones. Most users will leave this field unset.

Returns:



221
222
223
224
225
226
227
228
# File 'lib/google/cloud/dns/project.rb', line 221

def create_zone zone_name, zone_dns, description: nil,
                name_server_set: nil
  ensure_service!
  gapi = service.create_zone zone_name, zone_dns,
                             description: description,
                             name_server_set: name_server_set
  Zone.from_gapi gapi, service
end

#data_per_recordObject

Maximum allowed number of data entries per record.



95
96
97
98
# File 'lib/google/cloud/dns/project.rb', line 95

def data_per_record
  reload! if @gapi.nil?
  @gapi.quota.resource_records_per_rrset if @gapi.quota
end

#deletions_per_changeObject

Maximum allowed number of records to delete per change.



109
110
111
112
# File 'lib/google/cloud/dns/project.rb', line 109

def deletions_per_change
  reload! if @gapi.nil?
  @gapi.quota.rrset_deletions_per_change if @gapi.quota
end

#numberObject

The project number.



81
82
83
84
# File 'lib/google/cloud/dns/project.rb', line 81

def number
  reload! if @gapi.nil?
  @gapi.number
end

#projectObject Also known as: id

The unique ID string for the current project.

Examples:

require "google/cloud/dns"

dns = Google::Cloud::Dns.new(
        project: "my-project-id",
        keyfile: "/path/to/keyfile.json"
)

dns.project #=> "my-project-id"


74
75
76
# File 'lib/google/cloud/dns/project.rb', line 74

def project
  service.project
end

#records_per_zoneObject

Maximum allowed number of records per zone in the project.



116
117
118
119
# File 'lib/google/cloud/dns/project.rb', line 116

def records_per_zone
  reload! if @gapi.nil?
  @gapi.quota.rrsets_per_managed_zone if @gapi.quota
end

#reload!Object Also known as: refresh!

Reloads the change with updated status from the DNS service.



232
233
234
235
# File 'lib/google/cloud/dns/project.rb', line 232

def reload!
  ensure_service!
  @gapi = service.get_project
end

#total_data_per_changeObject

Maximum allowed total bytes size for all the data in one change.



123
124
125
126
# File 'lib/google/cloud/dns/project.rb', line 123

def total_data_per_change
  reload! if @gapi.nil?
  @gapi.quota.total_rrdata_size_per_change if @gapi.quota
end

#zone(zone_id) ⇒ Google::Cloud::Dns::Zone? Also known as: find_zone, get_zone

Retrieves an existing zone by name or id.

Examples:

require "google/cloud/dns"

dns = Google::Cloud::Dns.new
zone = dns.zone "example-com"
puts zone.name

Parameters:

  • zone_id (String, Integer)

    The name or id of a zone.

Returns:



152
153
154
155
156
157
158
# File 'lib/google/cloud/dns/project.rb', line 152

def zone zone_id
  ensure_service!
  gapi = service.get_zone zone_id
  Zone.from_gapi gapi, service
rescue Google::Cloud::NotFoundError
  nil
end

#zones(token: nil, max: nil) ⇒ Array<Google::Cloud::Dns::Zone> Also known as: find_zones

Retrieves the list of zones belonging to the project.

Zone::List)

Examples:

require "google/cloud/dns"

dns = Google::Cloud::Dns.new
zones = dns.zones
zones.each do |zone|
  puts zone.name
end

Retrieve all zones: (See Zone::List#all)

require "google/cloud/dns"

dns = Google::Cloud::Dns.new
zones = dns.zones
zones.all do |zone|
  puts zone.name
end

Parameters:

  • token (String)

    A previously-returned page token representing part of the larger set of results to view.

  • max (Integer)

    Maximum number of zones to return.

Returns:



190
191
192
193
194
# File 'lib/google/cloud/dns/project.rb', line 190

def zones token: nil, max: nil
  ensure_service!
  gapi = service.list_zones token: token, max: max
  Zone::List.from_gapi gapi, service, max
end

#zones_quotaObject

Maximum allowed number of zones in the project.



88
89
90
91
# File 'lib/google/cloud/dns/project.rb', line 88

def zones_quota
  reload! if @gapi.nil?
  @gapi.quota.managed_zones if @gapi.quota
end