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.



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

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:



211
212
213
214
215
216
217
218
# File 'lib/google/cloud/dns/project.rb', line 211

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.



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

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.



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

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

#numberObject

The project number.



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

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

#project_idObject Also known as: project, id

The unique ID string for the current project.

Examples:

require "google/cloud/dns"

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

dns.project_id #=> "my-project"


72
73
74
# File 'lib/google/cloud/dns/project.rb', line 72

def project_id
  service.project
end

#records_per_zoneObject

Maximum allowed number of records per zone in the project.



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

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.



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

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.



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

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:



142
143
144
145
146
147
148
# File 'lib/google/cloud/dns/project.rb', line 142

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:



180
181
182
183
184
# File 'lib/google/cloud/dns/project.rb', line 180

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.



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

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