Class: OneviewSDK::API200::ClientCertificate
- Defined in:
- lib/oneview-sdk/resource/api200/client_certificate.rb
Overview
Client certificate resource implementation
Direct Known Subclasses
OneviewSDK::API300::C7000::ClientCertificate, OneviewSDK::API300::Synergy::ClientCertificate
Constant Summary collapse
- BASE_URI =
'/rest/certificates'.freeze
- DEFAULT_REQUEST_HEADER =
{ 'requestername' => 'DEFAULT' }.freeze
Constants inherited from Resource
Instance Attribute Summary
Attributes inherited from Resource
#api_version, #client, #data, #logger
Class Method Summary collapse
-
.import(client, certificates, header = self::DEFAULT_REQUEST_HEADER) ⇒ Array<ClientCertificate>
Imports the given list of SSL certificates into the appliance trust store.
-
.remove(client, alias_names, force = false, header = self::DEFAULT_REQUEST_HEADER) ⇒ Object
Removes a list of SSL certificates based on the list of alias names provided as filter criteria.
-
.replace(client, certificates, force = false, header = self::DEFAULT_REQUEST_HEADER) ⇒ Array<ClientCertificate>
Replaces a list of existing SSL certificates with a new list of certificates.
Instance Method Summary collapse
-
#create ⇒ Object
Method is not available.
-
#delete ⇒ Object
Method is not available.
-
#import ⇒ ClientCertificate
Imports the given SSL certificate into the appliance trust store.
-
#initialize(client, params = {}, api_ver = nil) ⇒ ClientCertificate
constructor
Create a resource object, associate it with a client, and set its properties.
-
#remove ⇒ true
Removes the SSL certificate.
-
#validate(header = self.class::DEFAULT_REQUEST_HEADER) ⇒ OneviewSDK::ClientCertificate
Validates the input certificate by verifying if it is X509 compliant.
Methods inherited from Resource
#==, #[], #[]=, build_query, #create!, #deep_merge!, #each, #eql?, #exists?, find_by, find_with_pagination, from_file, get_all, #like?, #refresh, #retrieve!, #schema, schema, #set, #set_all, #to_file, #update
Constructor Details
#initialize(client, params = {}, api_ver = nil) ⇒ ClientCertificate
Create a resource object, associate it with a client, and set its properties.
39 40 41 42 43 44 |
# File 'lib/oneview-sdk/resource/api200/client_certificate.rb', line 39 def initialize(client, params = {}, api_ver = nil) super # Default values @data['type'] ||= 'SSLCertificateDTO' @data['uri'] ||= "#{self.class::BASE_URI}/#{@data['aliasName']}" if @data['aliasName'] end |
Class Method Details
.import(client, certificates, header = self::DEFAULT_REQUEST_HEADER) ⇒ Array<ClientCertificate>
Imports the given list of SSL certificates into the appliance trust store.
68 69 70 71 72 73 74 75 |
# File 'lib/oneview-sdk/resource/api200/client_certificate.rb', line 68 def self.import(client, certificates, header = self::DEFAULT_REQUEST_HEADER) raise ArgumentError, 'the certificates list should be valid' if certificates.nil? || certificates.empty? = {}.merge(header) ['body'] = certificates.map(&:data) response = client.rest_post(self::BASE_URI + '?multiResource=true', ) body = client.response_handler(response) body.map { |data| new(client, data) } end |
.remove(client, alias_names, force = false, header = self::DEFAULT_REQUEST_HEADER) ⇒ Object
Removes a list of SSL certificates based on the list of alias names provided as filter criteria.
107 108 109 110 111 112 113 |
# File 'lib/oneview-sdk/resource/api200/client_certificate.rb', line 107 def self.remove(client, alias_names, force = false, header = self::DEFAULT_REQUEST_HEADER) raise ArgumentError, 'the certificates list should be valid' if alias_names.nil? || alias_names.empty? uri = self::BASE_URI + build_query(multi_resource: true, force: force) uri += '&filter=' + alias_names.join('&filter=') response = client.rest_delete(uri, header) client.response_handler(response) end |
.replace(client, certificates, force = false, header = self::DEFAULT_REQUEST_HEADER) ⇒ Array<ClientCertificate>
Replaces a list of existing SSL certificates with a new list of certificates.
87 88 89 90 91 92 93 94 95 |
# File 'lib/oneview-sdk/resource/api200/client_certificate.rb', line 87 def self.replace(client, certificates, force = false, header = self::DEFAULT_REQUEST_HEADER) raise ArgumentError, 'the certificates list should be valid' if certificates.nil? || certificates.empty? = {}.merge(header) ['body'] = certificates.map(&:data) uri = self::BASE_URI + build_query(multi_resource: true, force: force) response = client.rest_put(uri, ) body = client.response_handler(response) body.map { |data| new(client, data) } end |
Instance Method Details
#create ⇒ Object
Method is not available
48 49 50 |
# File 'lib/oneview-sdk/resource/api200/client_certificate.rb', line 48 def create(*) unavailable_method end |
#delete ⇒ Object
Method is not available
54 55 56 |
# File 'lib/oneview-sdk/resource/api200/client_certificate.rb', line 54 def delete(*) unavailable_method end |
#import ⇒ ClientCertificate
Imports the given SSL certificate into the appliance trust store
26 |
# File 'lib/oneview-sdk/resource/api200/client_certificate.rb', line 26 alias import create |
#remove ⇒ true
Removes the SSL certificate
33 |
# File 'lib/oneview-sdk/resource/api200/client_certificate.rb', line 33 alias remove delete |
#validate(header = self.class::DEFAULT_REQUEST_HEADER) ⇒ OneviewSDK::ClientCertificate
Validates the input certificate by verifying if it is X509 compliant.
123 124 125 126 127 128 129 130 131 |
# File 'lib/oneview-sdk/resource/api200/client_certificate.rb', line 123 def validate(header = self.class::DEFAULT_REQUEST_HEADER) ensure_client && ensure_uri = {}.merge(header) ['body'] = @data response = @client.rest_post(self.class::BASE_URI + '/validator', , @api_version) body = @client.response_handler(response) set_all(body) self end |