Class: Asca::REST::Provisioning::Certificates

Inherits:
Object
  • Object
show all
Defined in:
lib/asca/rest/provisioning/certificates.rb

Class Method Summary collapse

Class Method Details

.list_certificates(options = {}) ⇒ Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/asca/rest/provisioning/certificates.rb', line 8

def list_certificates(options = {})
    # type enum : [ "DEVELOPMENT", "DISTRIBUTION" ]
    type = options[:type]
    types = !type ? "DEVELOPMENT, DISTRIBUTION" : type
    response = HTTP.auth('Bearer ' + Asca::Tools::Token.new_token).get(URI_CERTIFICATES, :params => { 
        "filter[certificateType]" => types
    })
    if response.status.success?
        certificates = JSON.parse(response.body)["data"]
        for certificate in certificates do
            id = certificate["id"]
            name = certificate["attributes"]["name"]
            type = certificate["attributes"]["certificateType"]
            puts "Certificate id: #{id} name: #{name} type: #{type}"
        end
    else 
        puts response.body
    end
    return response.status.success?
end