Class: CloudflareClient::Certificate

Inherits:
CloudflareClient show all
Defined in:
lib/cloudflare_client/certificate.rb

Constant Summary collapse

VALID_REQUESTED_VALIDITIES =
[7, 30, 90, 365, 730, 1095, 5475].freeze
VALID_REQUEST_TYPES =
%w[origin-rsa origin-ecc keyless-certificate].freeze

Constants inherited from CloudflareClient

API_BASE, POSSIBLE_API_SETTINGS, VALID_BUNDLE_METHODS, VALID_DIRECTIONS, VALID_MATCHES, VERSION

Instance Method Summary collapse

Methods inherited from CloudflareClient

#initialize

Constructor Details

This class inherits a constructor from CloudflareClient

Instance Method Details

#create(hostnames:, requested_validity: 5475, request_type: 'origin-rsa', csr: nil) ⇒ Object

create a certificate



16
17
18
19
20
21
22
23
24
25
# File 'lib/cloudflare_client/certificate.rb', line 16

def create(hostnames:, requested_validity: 5475, request_type: 'origin-rsa', csr: nil)
  non_empty_array_check(:hostnames, hostnames)
  valid_value_check(:requested_validity, requested_validity, VALID_REQUESTED_VALIDITIES)
  valid_value_check(:request_type, request_type, VALID_REQUEST_TYPES)

  data       = {hostnames: hostnames, requested_validity: requested_validity, request_type: request_type}
  data[:csr] = csr unless csr.nil?

  cf_post(path: '/certificates', data: data)
end

#list(zone_id: nil) ⇒ Object

list certificates



10
11
12
# File 'lib/cloudflare_client/certificate.rb', line 10

def list(zone_id: nil)
  cf_get(path: '/certificates', params: {zone_id: zone_id})
end

#revoke(id:) ⇒ Object

revoke a cert



36
37
38
39
# File 'lib/cloudflare_client/certificate.rb', line 36

def revoke(id:)
  id_check(:id, id)
  cf_delete(path: "/certificates/#{id}")
end

#show(id:) ⇒ Object

details of a certificate



29
30
31
32
# File 'lib/cloudflare_client/certificate.rb', line 29

def show(id:)
  id_check(:id, id)
  cf_get(path: "/certificates/#{id}")
end