Module: Dnsimple::Client::Tlds

Included in:
TldsService
Defined in:
lib/dnsimple/client/tlds.rb

Instance Method Summary collapse

Instance Method Details

#all_tlds(options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::Tld>

Lists ALL the TLDs in DNSimple.

This method is similar to Dnsimple::Client#tlds, but instead of returning the results of a specific page it iterates all the pages and returns the entire collection.

Please use this method carefully, as fetching the entire collection will increase the number of requests you send to the API server and you may eventually risk to hit the throttle limit.

Examples:

List all TLDs in DNSimple

client.tlds.all

Parameters:

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

    the filtering and sorting options

Options Hash (options):

  • :page (Integer)

    current page (pagination)

  • :per_page (Integer)

    number of entries to return (pagination)

  • :sort (String)

    sorting policy

Returns:

Raises:

See Also:


53
54
55
# File 'lib/dnsimple/client/tlds.rb', line 53

def all_tlds(options = {})
  paginate(:list_tlds, options)
end

#list_tlds(options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Tld>

Lists the TLDs available for registration

Examples:

List TLDs in the first page

client.tlds.list_tlds

List TLDs, providing a specific page

client.tlds.list_tlds(page: 2)

List TLDs, providing sorting policy

client.tlds.list_tlds(sort: "tld:asc")

Parameters:

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

    the filtering and sorting options

Options Hash (options):

  • :page (Integer)

    current page (pagination)

  • :per_page (Integer)

    number of entries to return (pagination)

  • :sort (String)

    sorting policy

Returns:

Raises:

See Also:


26
27
28
29
30
# File 'lib/dnsimple/client/tlds.rb', line 26

def list_tlds(options = {})
  response = client.get(Client.versioned("/tlds"), Options::ListOptions.new(options))

  Dnsimple::PaginatedResponse.new(response, response["data"].map { |r| Struct::Tld.new(r) })
end

#tld(tld, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Tld>

Gets a TLD details

Examples:

Get information on a specific TLD

client.tlds.tld('com')

Parameters:

  • tld (#to_s)

    The TLD name.

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

Returns:

Raises:

See Also:


70
71
72
73
74
# File 'lib/dnsimple/client/tlds.rb', line 70

def tld(tld, options = {})
  response = client.get(Client.versioned("/tlds/%s" % tld), options)

  Dnsimple::Response.new(response, Struct::Tld.new(response["data"]))
end

#tld_extended_attributes(tld, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::ExtendedAttribute>

Gets the extended attributes for a TLD.

Examples:

Get extended attributes for a specific TLD

client.tlds.tld_extended_attributes('uk')

Parameters:

  • tld (#to_s)

    The TLD name.

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

Returns:

Raises:

See Also:


89
90
91
92
93
# File 'lib/dnsimple/client/tlds.rb', line 89

def tld_extended_attributes(tld, options = {})
  response = client.get(Client.versioned("/tlds/%s/extended_attributes" % tld), options)

  Dnsimple::CollectionResponse.new(response, response["data"].map { |r| Struct::ExtendedAttribute.new(r) })
end