Module: Idcf::Dns::ClientExtensions::Record

Included in:
Idcf::Dns::Client
Defined in:
lib/idcf/dns/client_extensions/record.rb

Overview

SDK APIs for record resource

Instance Method Summary collapse

Instance Method Details

#create_record(zone_uuid, attributes, headers = {}) ⇒ Response

Create a new record.

Parameters:

  • zone_uuid (String)

    UUID of zone

  • attributes (Hash)

    request attributes

  • headers (Hash) (defaults to: {})

    HTTP request headers

Options Hash (attributes):

  • :name (String)

    name of record

  • :type (String)

    type of record (A, AAAA, CNAME, MX, TXT or SRV)

  • :content (String)

    content of record

  • :ttl (Integer)

    TTL

  • :priority (Integer)

    priority of record

Returns:



18
19
20
21
# File 'lib/idcf/dns/client_extensions/record.rb', line 18

def create_record(zone_uuid, attributes, headers = {})
  Validators::Record.validate_attributes!(attributes, :create)
  post!("zones/#{zone_uuid}/records", attributes, headers)
end

#delete_record(zone_uuid, uuid, headers = {}) ⇒ Response

Delete a record.

Parameters:

  • zone_uuid (String)

    UUID of zone

  • uuid (String)

    UUID of record

  • headers (Hash) (defaults to: {})

    HTTP request headers

Returns:



29
30
31
# File 'lib/idcf/dns/client_extensions/record.rb', line 29

def delete_record(zone_uuid, uuid, headers = {})
  delete!("zones/#{zone_uuid}/records/#{uuid}", {}, headers)
end

#get_record(zone_uuid, uuid, headers = {}) ⇒ Response

Get a record.

Parameters:

  • zone_uuid (String)

    UUID of zone

  • uuid (String)

    UUID of record

  • headers (Hash) (defaults to: {})

    HTTP request headers

Returns:



39
40
41
# File 'lib/idcf/dns/client_extensions/record.rb', line 39

def get_record(zone_uuid, uuid, headers = {})
  get!("zones/#{zone_uuid}/records/#{uuid}", {}, headers)
end

#list_records(zone_uuid, headers = {}) ⇒ Response

Get list of records.

Parameters:

  • zone_uuid (String)

    UUID of zone

Returns:



47
48
49
# File 'lib/idcf/dns/client_extensions/record.rb', line 47

def list_records(zone_uuid, headers = {})
  get!("zones/#{zone_uuid}/records", {}, headers)
end

#record(zone_uuid, uuid, headers = {}) ⇒ Resources::Record

Get a record object.

Parameters:

  • zone_uuid (String)

    UUID of zone

  • uuid (String)

    UUID of record

  • headers (Hash) (defaults to: {})

    HTTP request headers

Returns:



75
76
77
# File 'lib/idcf/dns/client_extensions/record.rb', line 75

def record(zone_uuid, uuid, headers = {})
  Resources::Record.new(self, get_record(uuid, zone_uuid, headers).body)
end

#records(zone_uuid, headers = {}) ⇒ Array<Resource::Record>

Get an array of existing record objects.

Parameters:

  • zone_uuid (String)

    UUID of zone

  • headers (Hash) (defaults to: {})

    HTTP request headers

Returns:

  • (Array<Resource::Record>)

    an array of record objects



84
85
86
# File 'lib/idcf/dns/client_extensions/record.rb', line 84

def records(zone_uuid, headers = {})
  zone(zone_uuid).records
end

#update_record(zone_uuid, uuid, attributes, headers = {}) ⇒ Response

Update a record.

Parameters:

  • zone_uuid (String)

    UUID of zone

  • uuid (String)

    UUID of record

  • attributes (Hash)

    request attributes

  • headers (Hash) (defaults to: {})

    HTTP request headers

Options Hash (attributes):

  • :name (String)

    name of record

  • :type (String)

    type of record (A, AAAA, CNAME, MX, TXT or SRV)

  • :content (String)

    content of record

  • :ttl (Integer)

    TTL

  • :priority (Integer)

    priority of record

Returns:



64
65
66
67
# File 'lib/idcf/dns/client_extensions/record.rb', line 64

def update_record(zone_uuid, uuid, attributes, headers = {})
  Validators::Record.validate_attributes!(attributes, :update)
  put!("zones/#{zone_uuid}/records/#{uuid}", attributes, headers)
end