Class: Fog::OpenStack::DNS::V2::Real

Inherits:
Object
  • Object
show all
Includes:
Core
Defined in:
lib/fog/openstack/dns/v2.rb,
lib/fog/openstack/dns/v2/requests/get_pool.rb,
lib/fog/openstack/dns/v2/requests/get_zone.rb,
lib/fog/openstack/dns/v2/requests/get_quota.rb,
lib/fog/openstack/dns/v2/requests/list_pools.rb,
lib/fog/openstack/dns/v2/requests/list_zones.rb,
lib/fog/openstack/dns/v2/requests/create_zone.rb,
lib/fog/openstack/dns/v2/requests/delete_zone.rb,
lib/fog/openstack/dns/v2/requests/update_zone.rb,
lib/fog/openstack/dns/v2/requests/update_quota.rb,
lib/fog/openstack/dns/v2/requests/get_recordset.rb,
lib/fog/openstack/dns/v2/requests/list_recordsets.rb,
lib/fog/openstack/dns/v2/requests/create_recordset.rb,
lib/fog/openstack/dns/v2/requests/delete_recordset.rb,
lib/fog/openstack/dns/v2/requests/update_recordset.rb,
lib/fog/openstack/dns/v2/requests/get_zone_transfer_accept.rb,
lib/fog/openstack/dns/v2/requests/get_zone_transfer_request.rb,
lib/fog/openstack/dns/v2/requests/list_zone_transfer_accepts.rb,
lib/fog/openstack/dns/v2/requests/create_zone_transfer_accept.rb,
lib/fog/openstack/dns/v2/requests/list_zone_transfer_requests.rb,
lib/fog/openstack/dns/v2/requests/create_zone_transfer_request.rb,
lib/fog/openstack/dns/v2/requests/delete_zone_transfer_request.rb,
lib/fog/openstack/dns/v2/requests/update_zone_transfer_request.rb

Instance Attribute Summary

Attributes included from Core

#auth_token, #auth_token_expiration, #current_tenant, #current_user, #current_user_id, #openstack_cache_ttl, #openstack_domain_id, #openstack_domain_name, #openstack_identity_api_version, #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

Methods included from Core

#credentials, #initialize, #reload

Class Method Details

.not_found_classObject



310
311
312
# File 'lib/fog/openstack/dns/v2.rb', line 310

def self.not_found_class
  Fog::OpenStack::DNS::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/openstack/dns/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/openstack/dns/v2/requests/create_zone.rb', line 6

def create_zone(name, email, options = {})
  data = {
    'name'  => name,
    'email' => email
  }

  vanilla_options = [:ttl, :description, :type, :masters, :attributes]

  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

#create_zone_transfer_accept(key, zone_transfer_request_id, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/fog/openstack/dns/v2/requests/create_zone_transfer_accept.rb', line 6

def create_zone_transfer_accept(key, zone_transfer_request_id, options = {})
  data = {
    :key => key,
    :zone_transfer_request_id => zone_transfer_request_id
  }

  headers, _options = Fog::OpenStack::DNS::V2.setup_headers(options)

  request(
    :headers => headers,
    :body    => Fog::JSON.encode(data),
    :expects => 200,
    :method  => 'POST',
    :path    => "zones/tasks/transfer_accepts"
  )
end

#create_zone_transfer_request(zone_id, options = {}) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/fog/openstack/dns/v2/requests/create_zone_transfer_request.rb', line 7

def create_zone_transfer_request(zone_id, options = {})
  vanilla_options = [:target_project_id, :description, :project_id]
  data = vanilla_options.inject({}) do |result,option|
    result[option] = options[option] if options[option]
    result
  end

  request(
    :body    => Fog::JSON.encode(data),
    :expects => 201,
    :method  => 'POST',
    :path    => "zones/#{zone_id}/tasks/transfer_requests"
  )
end

#default_path_prefixObject



314
315
316
# File 'lib/fog/openstack/dns/v2.rb', line 314

def default_path_prefix
  'v2'
end

#default_service_typeObject



318
319
320
# File 'lib/fog/openstack/dns/v2.rb', line 318

def default_service_type
  %w[dns]
end

#delete_recordset(zone_id, id, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/fog/openstack/dns/v2/requests/delete_recordset.rb', line 6

def delete_recordset(zone_id, id, options = {})
  headers, _options = Fog::OpenStack::DNS::V2.setup_headers(options)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :path    => "zones/#{zone_id}/recordsets/#{id}",
    :headers => headers
  )
end

#delete_zone(id, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/fog/openstack/dns/v2/requests/delete_zone.rb', line 6

def delete_zone(id, options = {})
  headers, _options = Fog::OpenStack::DNS::V2.setup_headers(options)
  request(
    :expects => 202,
    :method  => 'DELETE',
    :path    => "zones/#{id}",
    :headers => headers
  )
end

#delete_zone_transfer_request(zone_transfer_request_id) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/fog/openstack/dns/v2/requests/delete_zone_transfer_request.rb', line 7

def delete_zone_transfer_request(zone_transfer_request_id)
  request(
    :expects => 204,
    :method  => 'DELETE',
    :path    => "zones/tasks/transfer_requests/#{zone_transfer_request_id}"
  )
end

#get_pool(id, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/fog/openstack/dns/v2/requests/get_pool.rb', line 6

def get_pool(id, options = {})
  headers, _options = Fog::OpenStack::DNS::V2.setup_headers(options)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "pools/#{id}",
    :headers => headers
  )
end

#get_quota(project_id = nil) ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/fog/openstack/dns/v2/requests/get_quota.rb', line 6

def get_quota(project_id = nil)
  headers, _options = Fog::OpenStack::DNS::V2.setup_headers(:all_projects => !project_id.nil?)

  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "quotas/#{project_id}",
    :headers => headers
  )
end

#get_recordset(zone_id, id, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/fog/openstack/dns/v2/requests/get_recordset.rb', line 6

def get_recordset(zone_id, id, options = {})
  headers, _options = Fog::OpenStack::DNS::V2.setup_headers(options)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "zones/#{zone_id}/recordsets/#{id}",
    :headers => headers
  )
end

#get_zone(id, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
# File 'lib/fog/openstack/dns/v2/requests/get_zone.rb', line 6

def get_zone(id, options = {})
  headers, _options = Fog::OpenStack::DNS::V2.setup_headers(options)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "zones/#{id}",
    :headers => headers
  )
end

#get_zone_transfer_accept(zone_transfer_accept_id) ⇒ Object



6
7
8
9
10
11
12
# File 'lib/fog/openstack/dns/v2/requests/get_zone_transfer_accept.rb', line 6

def get_zone_transfer_accept(zone_transfer_accept_id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "zones/tasks/transfer_requests/#{zone_transfer_accept_id}"
  )
end

#get_zone_transfer_request(zone_transfer_request_id) ⇒ Object



7
8
9
10
11
12
13
# File 'lib/fog/openstack/dns/v2/requests/get_zone_transfer_request.rb', line 7

def get_zone_transfer_request(zone_transfer_request_id)
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "zones/tasks/transfer_requests/#{zone_transfer_request_id}"
  )
end

#list_pools(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/openstack/dns/v2/requests/list_pools.rb', line 6

def list_pools(options = {})
  headers, options = Fog::OpenStack::DNS::V2.setup_headers(options)

  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'pools',
    :query   => options,
    :headers => headers
  )
end

#list_recordsets(zone_id = nil, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
# File 'lib/fog/openstack/dns/v2/requests/list_recordsets.rb', line 6

def list_recordsets(zone_id = nil, options = {})
  # for backward compatability: consider removing the zone_id param (breaking change)
  unless zone_id.nil?
    if zone_id.kind_of?(Hash)
      options = zone_id
      zone_id = nil
    else
      Fog::Logger.deprecation(
        'Calling list_recordsets(zone_id) is deprecated, use .list_recordsets(zone_id: value) instead'
      )
    end
  end

  zone_id = options.delete(:zone_id) if zone_id.nil?
  path = zone_id.nil? ? 'recordsets' : "zones/#{zone_id}/recordsets"

  headers, options = Fog::OpenStack::DNS::V2.setup_headers(options)

  request(
    :expects => 200,
    :method  => 'GET',
    :path    => path,
    :query   => options,
    :headers => headers
  )
end

#list_zone_transfer_accepts(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/dns/v2/requests/list_zone_transfer_accepts.rb', line 6

def list_zone_transfer_accepts(options={})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "zones/tasks/transfer_accepts",
    :query   => options
  )
end

#list_zone_transfer_requests(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
# File 'lib/fog/openstack/dns/v2/requests/list_zone_transfer_requests.rb', line 6

def list_zone_transfer_requests(options={})
  request(
    :expects => 200,
    :method  => 'GET',
    :path    => "zones/tasks/transfer_requests",
    :query   => options
  )
end

#list_zones(options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/openstack/dns/v2/requests/list_zones.rb', line 6

def list_zones(options = {})
  headers, options = Fog::OpenStack::DNS::V2.setup_headers(options)

  request(
    :expects => 200,
    :method  => 'GET',
    :path    => 'zones',
    :query   => options,
    :headers => headers
  )
end

#update_quota(project_id, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/openstack/dns/v2/requests/update_quota.rb', line 6

def update_quota(project_id, options = {})
  headers, options = Fog::OpenStack::DNS::V2.setup_headers(options)

  request(
    :body    => Fog::JSON.encode(options),
    :expects => 200,
    :method  => 'PATCH',
    :path    => "quotas/#{project_id}",
    :headers => headers
  )
end

#update_recordset(zone_id, id, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/openstack/dns/v2/requests/update_recordset.rb', line 6

def update_recordset(zone_id, id, options = {})
  headers, options = Fog::OpenStack::DNS::V2.setup_headers(options)

  request(
    :body    => Fog::JSON.encode(options),
    :expects => 202,
    :method  => 'PUT',
    :path    => "zones/#{zone_id}/recordsets/#{id}",
    :headers => headers
  )
end

#update_zone(id, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
# File 'lib/fog/openstack/dns/v2/requests/update_zone.rb', line 6

def update_zone(id, options = {})
  headers, options = Fog::OpenStack::DNS::V2.setup_headers(options)

  request(
    :body    => Fog::JSON.encode(options),
    :expects => 202,
    :method  => 'PATCH',
    :path    => "zones/#{id}",
    :headers => headers
  )
end

#update_zone_transfer_request(zone_transfer_request_id, description, options = {}) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/fog/openstack/dns/v2/requests/update_zone_transfer_request.rb', line 6

def update_zone_transfer_request(zone_transfer_request_id,description,options={})
  vanilla_options = [:target_project_id]
  data = vanilla_options.inject({}) do |result,option|
    result[option] = options[option] if options[option]
    result
  end

  request(
    :expects => 200,
    :method  => 'PATCH',
    :path    => "zones/tasks/transfer_requests/#{zone_transfer_request_id}",
    :body    => Fog::JSON.encode(data)
  )
end