Class: OneviewSDK::API200::ClientCertificate

Inherits:
Resource show all
Defined in:
lib/oneview-sdk/resource/api200/client_certificate.rb

Overview

Client certificate resource implementation

Constant Summary collapse

BASE_URI =
'/rest/certificates'.freeze
DEFAULT_REQUEST_HEADER =
{ 'requestername' => 'DEFAULT' }.freeze

Constants inherited from Resource

Resource::UNIQUE_IDENTIFIERS

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Resource

#==, #[], #[]=, build_query, #create!, #deep_merge!, #each, #eql?, #exists?, find_by, find_with_pagination, from_file, get_all, get_all_with_query, #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.

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance

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

    The options for this resource (key-value pairs)

  • api_ver (Integer) (defaults to: nil)

    The api version to use when interracting with this resource.



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.

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance

  • certificates (Array<ClientCertificate>)

    The Client Certificate list

  • header (Hash) (defaults to: self::DEFAULT_REQUEST_HEADER)

    The header options of request (key-value pairs)

Options Hash (header):

  • :requestername (String)

    Used to identify requester to allow querying of proper trust store. Default value is “DEFAULT”. List of valid input values are { “DEFAULT”, “AUTHN”, “RABBITMQ”, “ILOOA” }.

  • :Accept-Language (String)

    The language code requested in the response. If a suitable match to the requested language is not available, en-US or the appliance locale is used.

Returns:

Raises:

  • (ArgumentError)

    if the certificates list is nil or empty



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?
  options = {}.merge(header)
  options['body'] = certificates.map(&:data)
  response = client.rest_post(self::BASE_URI + '?multiResource=true', options)
  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.

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance

  • alias_names (Array<String>)

    The alias names list used as filter to remove the client certificates

  • force (Boolean) (defaults to: false)

    If set to true, the operation completes despite any problems with network connectivity or errors on the resource itself

  • header (Hash) (defaults to: self::DEFAULT_REQUEST_HEADER)

    The header options of request (key-value pairs)

Options Hash (header):

  • :requestername (String)

    Used to identify requester to allow querying of proper trust store. Default value is “DEFAULT”. List of valid input values are { “DEFAULT”, “AUTHN”, “RABBITMQ”, “ILOOA” }.

  • :Accept-Language (String)

    The language code requested in the response. If a suitable match to the requested language is not available, en-US or the appliance locale is used.

Raises:

  • (ArgumentError)

    if the certificates list is nil or empty



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.

Parameters:

  • client (OneviewSDK::Client)

    The client object for the OneView appliance

  • certificates (Array<ClientCertificate>)

    The Client Certificate list

  • force (Boolean) (defaults to: false)

    If set to true, the operation completes despite any problems with network connectivity or errors on the resource itself

  • header (Hash) (defaults to: self::DEFAULT_REQUEST_HEADER)

    The header options of request (key-value pairs)

Options Hash (header):

  • :requestername (String)

    Used to identify requester to allow querying of proper trust store. Default value is “DEFAULT”. List of valid input values are { “DEFAULT”, “AUTHN”, “RABBITMQ”, “ILOOA” }.

  • :Accept-Language (String)

    The language code requested in the response. If a suitable match to the requested language is not available, en-US or the appliance locale is used.

Returns:

Raises:

  • (ArgumentError)


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?
  options = {}.merge(header)
  options['body'] = certificates.map(&:data)
  uri = self::BASE_URI + build_query(multi_resource: true, force: force)
  response = client.rest_put(uri, options)
  body = client.response_handler(response)
  body.map { |data| new(client, data) }
end

Instance Method Details

#createObject

Method is not available

Raises:



48
49
50
# File 'lib/oneview-sdk/resource/api200/client_certificate.rb', line 48

def create(*)
  unavailable_method
end

#deleteObject

Method is not available

Raises:



54
55
56
# File 'lib/oneview-sdk/resource/api200/client_certificate.rb', line 54

def delete(*)
  unavailable_method
end

#importClientCertificate

Imports the given SSL certificate into the appliance trust store

Parameters:

  • header (Hash)

    The header options of request (key-value pairs)

Returns:



26
# File 'lib/oneview-sdk/resource/api200/client_certificate.rb', line 26

alias import create

#removetrue

Removes the SSL certificate

Parameters:

  • header (Hash)

    The header options of request (key-value pairs)

Returns:

  • (true)

    if resource was deleted successfully



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.

Parameters:

  • header (Hash) (defaults to: self.class::DEFAULT_REQUEST_HEADER)

    The header options of request (key-value pairs)

Options Hash (header):

  • :requestername (String)

    Used to identify requester to allow querying of proper trust store. Default value is “DEFAULT”. List of valid input values are { “DEFAULT”, “AUTHN”, “RABBITMQ”, “ILOOA” }.

  • :Accept-Language (String)

    The language code requested in the response. If a suitable match to the requested language is not available, en-US or the appliance locale is used.

Returns:

  • (OneviewSDK::ClientCertificate)

    self

Raises:



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
  options = {}.merge(header)
  options['body'] = @data
  response = @client.rest_post(self.class::BASE_URI + '/validator', options, @api_version)
  body = @client.response_handler(response)
  set_all(body)
  self
end