Class: Fog::DNS::OpenStack::V2::Real
- Inherits:
-
Object
- Object
- Fog::DNS::OpenStack::V2::Real
show all
- Includes:
- OpenStack::Core
- Defined in:
- lib/fog/dns/openstack/v2.rb,
lib/fog/dns/openstack/v2/requests/get_zone.rb,
lib/fog/dns/openstack/v2/requests/get_quota.rb,
lib/fog/dns/openstack/v2/requests/list_zones.rb,
lib/fog/dns/openstack/v2/requests/create_zone.rb,
lib/fog/dns/openstack/v2/requests/delete_zone.rb,
lib/fog/dns/openstack/v2/requests/update_zone.rb,
lib/fog/dns/openstack/v2/requests/update_quota.rb,
lib/fog/dns/openstack/v2/requests/get_recordset.rb,
lib/fog/dns/openstack/v2/requests/list_recordsets.rb,
lib/fog/dns/openstack/v2/requests/create_recordset.rb,
lib/fog/dns/openstack/v2/requests/delete_recordset.rb,
lib/fog/dns/openstack/v2/requests/update_recordset.rb
Instance Attribute Summary
#auth_token, #auth_token_expiration, #current_tenant, #current_user, #current_user_id, #openstack_cache_ttl, #openstack_domain_id, #openstack_domain_name, #openstack_identity_prefix, #openstack_project_domain, #openstack_project_domain_id, #openstack_project_id, #openstack_user_domain, #openstack_user_domain_id, #unscoped_token
Class Method Summary
collapse
Instance Method Summary
collapse
-
#create_recordset(zone_id, name, type, records, options = {}) ⇒ Object
-
#create_zone(name, email, options = {}) ⇒ Object
-
#delete_recordset(zone_id, id) ⇒ Object
-
#delete_zone(id) ⇒ Object
-
#get_quota(project_id = nil) ⇒ Object
-
#get_recordset(zone_id, id) ⇒ Object
-
#get_zone(id) ⇒ Object
-
#initialize(options = {}) ⇒ Real
constructor
-
#list_recordsets(zone_id, options = {}) ⇒ Object
-
#list_zones(options = {}) ⇒ Object
-
#set_api_path ⇒ Object
-
#update_quota(project_id, options = {}) ⇒ Object
-
#update_recordset(zone_id, id, options = {}) ⇒ Object
-
#update_zone(id, options = {}) ⇒ Object
#credentials, #initialize_identity, #reload
Constructor Details
#initialize(options = {}) ⇒ Real
Returns a new instance of Real.
158
159
160
161
162
163
164
165
166
167
168
169
170
|
# File 'lib/fog/dns/openstack/v2.rb', line 158
def initialize(options = {})
initialize_identity options
@openstack_service_type = options[:openstack_service_type] || ['dns']
@openstack_service_name = options[:openstack_service_name]
@connection_options = options[:connection_options] || {}
authenticate
set_api_path
@persistent = options[:persistent] || false
@connection = Fog::Core::Connection.new("#{@scheme}://#{@host}:#{@port}/", @persistent, @connection_options)
end
|
Class Method Details
.not_found_class ⇒ Object
154
155
156
|
# File 'lib/fog/dns/openstack/v2.rb', line 154
def self.not_found_class
Fog::DNS::OpenStack::NotFound
end
|
Instance Method Details
#create_recordset(zone_id, name, type, records, options = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
|
# File 'lib/fog/dns/openstack/v2/requests/create_recordset.rb', line 6
def create_recordset(zone_id, name, type, records, options = {})
data = {
'name' => name,
'type' => type,
'records' => records
}
vanilla_options = [:ttl, :description]
vanilla_options.select { |o| options[o] }.each do |key|
data[key] = options[key]
end
request(
:body => Fog::JSON.encode(data),
:expects => 202,
:method => 'POST',
:path => "zones/#{zone_id}/recordsets"
)
end
|
#create_zone(name, email, options = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
# File 'lib/fog/dns/openstack/v2/requests/create_zone.rb', line 6
def create_zone(name, email, options = {})
data = {
'name' => name,
'email' => email
}
vanilla_options = [:ttl, :description, :type, :masters]
vanilla_options.select { |o| options[o] }.each do |key|
data[key] = options[key]
end
request(
:body => Fog::JSON.encode(data),
:expects => 202,
:method => 'POST',
:path => "zones"
)
end
|
#delete_recordset(zone_id, id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/dns/openstack/v2/requests/delete_recordset.rb', line 6
def delete_recordset(zone_id, id)
request(
:expects => 202,
:method => 'DELETE',
:path => "zones/#{zone_id}/recordsets/#{id}"
)
end
|
#delete_zone(id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/dns/openstack/v2/requests/delete_zone.rb', line 6
def delete_zone(id)
request(
:expects => 202,
:method => 'DELETE',
:path => "zones/#{id}"
)
end
|
#get_quota(project_id = nil) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/fog/dns/openstack/v2/requests/get_quota.rb', line 6
def get_quota(project_id = nil)
request(
:headers => {"X-Auth-All-Projects" => !project_id.nil?},
:expects => 200,
:method => 'GET',
:path => "quotas/#{project_id}"
)
end
|
#get_recordset(zone_id, id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/dns/openstack/v2/requests/get_recordset.rb', line 6
def get_recordset(zone_id, id)
request(
:expects => 200,
:method => 'GET',
:path => "zones/#{zone_id}/recordsets/#{id}"
)
end
|
#get_zone(id) ⇒ Object
6
7
8
9
10
11
12
|
# File 'lib/fog/dns/openstack/v2/requests/get_zone.rb', line 6
def get_zone(id)
request(
:expects => 200,
:method => 'GET',
:path => "zones/#{id}"
)
end
|
#list_recordsets(zone_id, options = {}) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/fog/dns/openstack/v2/requests/list_recordsets.rb', line 6
def list_recordsets(zone_id, options = {})
request(
:expects => 200,
:method => 'GET',
:path => "zones/#{zone_id}/recordsets",
:query => options
)
end
|
#list_zones(options = {}) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/fog/dns/openstack/v2/requests/list_zones.rb', line 6
def list_zones(options = {})
request(
:expects => 200,
:method => 'GET',
:path => 'zones',
:query => options
)
end
|
#set_api_path ⇒ Object
172
173
174
175
176
177
178
179
180
181
|
# File 'lib/fog/dns/openstack/v2.rb', line 172
def set_api_path
unless @path.match(SUPPORTED_VERSIONS)
@path = Fog::OpenStack.get_supported_version_path(
SUPPORTED_VERSIONS,
@openstack_management_uri,
@auth_token,
@connection_options
)
end
end
|
#update_quota(project_id, options = {}) ⇒ Object
6
7
8
9
10
11
12
13
14
15
|
# File 'lib/fog/dns/openstack/v2/requests/update_quota.rb', line 6
def update_quota(project_id, options = {})
all_projects = options.key?(:all_projects) ? options.delete(:all_projects) : false
request(
:headers => {"X-Auth-All-Projects" => all_projects},
:body => Fog::JSON.encode(options),
:expects => 200,
:method => 'PATCH',
:path => "quotas/#{project_id}"
)
end
|
#update_recordset(zone_id, id, options = {}) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/fog/dns/openstack/v2/requests/update_recordset.rb', line 6
def update_recordset(zone_id, id, options = {})
request(
:body => Fog::JSON.encode(options),
:expects => 202,
:method => 'PUT',
:path => "zones/#{zone_id}/recordsets/#{id}"
)
end
|
#update_zone(id, options = {}) ⇒ Object
6
7
8
9
10
11
12
13
|
# File 'lib/fog/dns/openstack/v2/requests/update_zone.rb', line 6
def update_zone(id, options = {})
request(
:body => Fog::JSON.encode(options),
:expects => 202,
:method => 'PATCH',
:path => "zones/#{id}"
)
end
|