Class: Gcloud::Dns::Project
- Inherits:
-
Object
- Object
- Gcloud::Dns::Project
- Defined in:
- lib/gcloud/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](console.developers.google.com).
See Gcloud#dns
Instance Attribute Summary collapse
Class Method Summary collapse
Instance Method Summary collapse
-
#additions_per_change ⇒ Object
Maximum allowed number of records to add per change.
-
#create_zone(zone_name, zone_dns, description: nil, name_server_set: nil) ⇒ Gcloud::Dns::Zone
Creates a new zone.
-
#data_per_record ⇒ Object
Maximum allowed number of data entries per record.
-
#deletions_per_change ⇒ Object
Maximum allowed number of records to delete per change.
-
#initialize(project, credentials) ⇒ Project
constructor
See Gcloud.dns.
-
#number ⇒ Object
The project number.
-
#project ⇒ Object
(also: #id)
The unique ID string for the current project.
-
#records_per_zone ⇒ Object
Maximum allowed number of records per zone in the project.
-
#reload! ⇒ Object
(also: #refresh!)
Reloads the change with updated status from the DNS service.
-
#total_data_per_change ⇒ Object
Maximum allowed total bytes size for all the data in one change.
-
#zone(zone_id) ⇒ Gcloud::Dns::Zone?
(also: #find_zone, #get_zone)
Retrieves an existing zone by name or id.
-
#zones(token: nil, max: nil) ⇒ Array<Gcloud::Dns::Zone>
(also: #find_zones)
Retrieves the list of zones belonging to the project.
-
#zones_quota ⇒ Object
Maximum allowed number of zones in the project.
Constructor Details
#initialize(project, credentials) ⇒ Project
See Gcloud.dns
55 56 57 58 59 60 |
# File 'lib/gcloud/dns/project.rb', line 55 def initialize project, credentials project = project.to_s # Always cast to a string fail ArgumentError, "project is missing" if project.empty? @connection = Connection.new project, credentials @gapi = nil end |
Instance Attribute Details
#connection ⇒ Object
45 46 47 |
# File 'lib/gcloud/dns/project.rb', line 45 def connection @connection end |
#gapi ⇒ Object
49 50 51 |
# File 'lib/gcloud/dns/project.rb', line 49 def gapi @gapi end |
Class Method Details
.default_project ⇒ Object
129 130 131 132 133 134 |
# File 'lib/gcloud/dns/project.rb', line 129 def self.default_project ENV["DNS_PROJECT"] || ENV["GCLOUD_PROJECT"] || ENV["GOOGLE_CLOUD_PROJECT"] || Gcloud::GCE.project_id end |
Instance Method Details
#additions_per_change ⇒ Object
Maximum allowed number of records to add per change.
101 102 103 104 |
# File 'lib/gcloud/dns/project.rb', line 101 def additions_per_change reload! if @gapi.nil? @gapi["quota"]["rrsetAdditionsPerChange"] if @gapi["quota"] end |
#create_zone(zone_name, zone_dns, description: nil, name_server_set: nil) ⇒ Gcloud::Dns::Zone
Creates a new zone.
233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/gcloud/dns/project.rb', line 233 def create_zone zone_name, zone_dns, description: nil, name_server_set: nil ensure_connection! resp = connection.create_zone zone_name, zone_dns, description: description, name_server_set: name_server_set if resp.success? Zone.from_gapi resp.data, connection else fail ApiError.from_response(resp) end end |
#data_per_record ⇒ Object
Maximum allowed number of data entries per record.
94 95 96 97 |
# File 'lib/gcloud/dns/project.rb', line 94 def data_per_record reload! if @gapi.nil? @gapi["quota"]["resourceRecordsPerRrset"] if @gapi["quota"] end |
#deletions_per_change ⇒ Object
Maximum allowed number of records to delete per change.
108 109 110 111 |
# File 'lib/gcloud/dns/project.rb', line 108 def deletions_per_change reload! if @gapi.nil? @gapi["quota"]["rrsetDeletionsPerChange"] if @gapi["quota"] end |
#number ⇒ Object
The project number.
80 81 82 83 |
# File 'lib/gcloud/dns/project.rb', line 80 def number reload! if @gapi.nil? @gapi["number"] end |
#project ⇒ Object Also known as: id
The unique ID string for the current project.
73 74 75 |
# File 'lib/gcloud/dns/project.rb', line 73 def project connection.project end |
#records_per_zone ⇒ Object
Maximum allowed number of records per zone in the project.
115 116 117 118 |
# File 'lib/gcloud/dns/project.rb', line 115 def records_per_zone reload! if @gapi.nil? @gapi["quota"]["rrsetsPerManagedZone"] if @gapi["quota"] end |
#reload! ⇒ Object Also known as: refresh!
Reloads the change with updated status from the DNS service.
248 249 250 251 252 253 254 255 256 |
# File 'lib/gcloud/dns/project.rb', line 248 def reload! ensure_connection! resp = connection.get_project if resp.success? @gapi = resp.data else fail ApiError.from_response(resp) end end |
#total_data_per_change ⇒ Object
Maximum allowed total bytes size for all the data in one change.
122 123 124 125 |
# File 'lib/gcloud/dns/project.rb', line 122 def total_data_per_change reload! if @gapi.nil? @gapi["quota"]["totalRrdataSizePerChange"] if @gapi["quota"] end |
#zone(zone_id) ⇒ Gcloud::Dns::Zone? Also known as: find_zone, get_zone
Retrieves an existing zone by name or id.
152 153 154 155 156 157 158 159 160 |
# File 'lib/gcloud/dns/project.rb', line 152 def zone zone_id ensure_connection! resp = connection.get_zone zone_id if resp.success? Zone.from_gapi resp.data, connection else nil end end |
#zones(token: nil, max: nil) ⇒ Array<Gcloud::Dns::Zone> Also known as: find_zones
Retrieves the list of zones belonging to the project.
197 198 199 200 201 202 203 204 205 |
# File 'lib/gcloud/dns/project.rb', line 197 def zones token: nil, max: nil ensure_connection! resp = connection.list_zones token: token, max: max if resp.success? Zone::List.from_response resp, connection else fail ApiError.from_response(resp) end end |
#zones_quota ⇒ Object
Maximum allowed number of zones in the project.
87 88 89 90 |
# File 'lib/gcloud/dns/project.rb', line 87 def zones_quota reload! if @gapi.nil? @gapi["quota"]["managedZones"] if @gapi["quota"] end |