Module: Dnsimple::Client::Certificates

Included in:
CertificatesService
Defined in:
lib/dnsimple/client/certificates.rb

Instance Method Summary collapse

Instance Method Details

#all_certificates(account_id, domain_name, options = {}) ⇒ Dnsimple::CollectionResponse<Dnsimple::Struct::Certificate>

Lists ALL the certificates for the domain.

This method is similar to #certificates, 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.

Parameters:

  • account_id (Integer)

    the account ID

  • domain_name (#to_s)

    The domain ID or domain name

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

    the filtering and sorting option

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/certificates.rb', line 53

def all_certificates(, domain_name, options = {})
  paginate(:certificates, , domain_name, options)
end

#certificate(account_id, domain_id, certificate_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::Certificate>

Gets a certificate associated to the domain.

Parameters:

  • account_id (Integer)

    the account ID

  • domain_id (#to_s)

    the domain ID or domain name

  • certificate_id (Integer)

    the certificate ID

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

Returns:

Raises:

See Also:



69
70
71
72
73
# File 'lib/dnsimple/client/certificates.rb', line 69

def certificate(, domain_id, certificate_id, options = {})
  response = client.get(Client.versioned("/%s/domains/%s/certificates/%s" % [, domain_id, certificate_id]), options)

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

#certificate_private_key(account_id, domain_id, certificate_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::CertificateBundle>

Get certificate private key associated to the domain.

Parameters:

  • account_id (Integer)

    the account ID

  • domain_id (#to_s)

    the domain ID or domain name

  • certificate_id (Integer)

    the certificate ID

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

Returns:

Raises:

See Also:



105
106
107
108
109
# File 'lib/dnsimple/client/certificates.rb', line 105

def certificate_private_key(, domain_id, certificate_id, options = {})
  response = client.get(Client.versioned("/%s/domains/%s/certificates/%s/private_key" % [, domain_id, certificate_id]), options)

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

#certificates(account_id, domain_name, options = {}) ⇒ Dnsimple::PaginatedResponse<Dnsimple::Struct::Certificate>

Lists the certificates associated to the domain.

Examples:

List certificates in the first page

client.certificates.list(1010, "example.com")

List certificates, provide a specific page

client.certificates.list(1010, "example.com", page: 2)

List certificates, provide a sorting policy

client.certificates.list(1010, "example.com", sort: "email:asc")

Parameters:

  • account_id (Integer)

    the account ID

  • domain_name (#to_s)

    the domain name

  • 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)

Returns:

Raises:

See Also:



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

def certificates(, domain_name, options = {})
  response = client.get(Client.versioned("/%s/domains/%s/certificates" % [, domain_name]), Options::ListOptions.new(options))

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

#download_certificate(account_id, domain_id, certificate_id, options = {}) ⇒ Dnsimple::Response<Dnsimple::Struct::CertificateBundle>

Downloads a certificate associated to the domain.

Parameters:

  • account_id (Integer)

    the account ID

  • domain_id (#to_s)

    the domain ID or domain name

  • certificate_id (Integer)

    the certificate ID

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

Returns:

Raises:

See Also:



87
88
89
90
91
# File 'lib/dnsimple/client/certificates.rb', line 87

def download_certificate(, domain_id, certificate_id, options = {})
  response = client.get(Client.versioned("/%s/domains/%s/certificates/%s/download" % [, domain_id, certificate_id]), options)

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