Module: Dnsimple::Client::Services

Included in:
ServicesService
Defined in:
lib/dnsimple/client/services.rb

Instance Method Summary collapse

Instance Method Details

#all_services(options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Service>

Lists ALL the available one-click services.

This method is similar to #services, 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 the one-click services:

client.services.all_services

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:



56
57
58
# File 'lib/dnsimple/client/services.rb', line 56

def all_services(options = {})
  paginate(:services, options)
end

#service(service_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Service>

Gets the service with specified ID.

Examples:

Get service 43:

client.services.service(43)

Parameters:

  • service_id (#to_s)

    The service ID

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

Returns:

Raises:

See Also:



72
73
74
75
76
77
# File 'lib/dnsimple/client/services.rb', line 72

def service(service_id, options = {})
  endpoint = Client.versioned("/services/%s" % [service_id])
  response = client.get(endpoint, options)

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

#services(options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Service> Also known as: list_services

Lists the available one-click services.

Examples:

List one-click services:

client.services.list_services

List one-click services, provide a specific page:

client.services.list_services(page: 2)

List one-click services, provide a sorting policy:

client.services.list_services(sort: "short_name: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:



27
28
29
30
31
32
# File 'lib/dnsimple/client/services.rb', line 27

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

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