Class: OneviewSDK::API200::ServerHardwareType

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

Overview

Server hardware type resource implementation

Constant Summary collapse

BASE_URI =
'/rest/server-hardware-types'.freeze

Constants inherited from Resource

Resource::UNIQUE_IDENTIFIERS

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Instance Method Summary collapse

Methods inherited from Resource

#==, #[], #[]=, build_query, #create!, #each, #eql?, #exists?, find_by, from_file, get_all, #like?, #refresh, #retrieve!, schema, #schema, #set, #set_all, #to_file

Constructor Details

#initialize(client, params = {}, api_ver = nil) ⇒ ServerHardwareType

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.


28
29
30
31
32
# File 'lib/oneview-sdk/resource/api200/server_hardware_type.rb', line 28

def initialize(client, params = {}, api_ver = nil)
  super
  # Default values
  @data['type'] ||= 'server-hardware-type-4'
end

Instance Method Details

#createObject

Method is not available

Raises:


36
37
38
# File 'lib/oneview-sdk/resource/api200/server_hardware_type.rb', line 36

def create(*)
  unavailable_method
end

#deleteObject

Method is not available

Raises:


42
43
44
# File 'lib/oneview-sdk/resource/api200/server_hardware_type.rb', line 42

def delete(*)
  unavailable_method
end

#removetrue

Remove resource from OneView

Returns:

  • (true)

    if resource was removed successfully


22
# File 'lib/oneview-sdk/resource/api200/server_hardware_type.rb', line 22

alias remove delete

#update(attributes = {}) ⇒ OneviewSDK::ServerHardwareType

Update resource attributes

Parameters:

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

    attributes to be updated

Options Hash (attributes):

  • :name (String)

    server hardware type name

  • :description (String)

    server hardware type description

Returns:

  • (OneviewSDK::ServerHardwareType)

    self


51
52
53
54
55
56
57
58
# File 'lib/oneview-sdk/resource/api200/server_hardware_type.rb', line 51

def update(attributes = {})
  set_all(attributes)
  ensure_client && ensure_uri
  data = @data.select { |k, _v| %w(name description).include?(k) }
  response = @client.rest_put(@data['uri'], { 'body' => data }, @api_version)
  @client.response_handler(response)
  self
end