Class: OneviewSDK::API500::C7000::Scope

Inherits:
OneviewSDK::API300::C7000::Scope show all
Defined in:
lib/oneview-sdk/resource/api500/c7000/scope.rb

Overview

Scope resource implementation for API500 C7000

Constant Summary

Constants inherited from OneviewSDK::API300::C7000::Scope

OneviewSDK::API300::C7000::Scope::BASE_URI

Constants inherited from Resource

Resource::BASE_URI, Resource::DEFAULT_REQUEST_HEADER, Resource::UNIQUE_IDENTIFIERS

Instance Attribute Summary

Attributes inherited from Resource

#api_version, #client, #data, #logger

Instance Method Summary collapse

Methods inherited from OneviewSDK::API300::C7000::Scope

#delete, #set_resources, #unset_resources, #update

Methods inherited from Resource

#==, #[], #[]=, build_query, #create, #create!, #deep_merge!, #delete, #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) ⇒ Scope

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. Defaults to the client.api_version if it exists, or the OneviewSDK::Client::DEFAULT_API_VERSION.



24
25
26
27
28
# File 'lib/oneview-sdk/resource/api500/c7000/scope.rb', line 24

def initialize(client, params = {}, api_ver = nil)
  @data ||= {}
  @data['type'] ||= 'ScopeV2'
  super
end

Instance Method Details

#change_resource_assignments(add_resources: [], remove_resources: []) ⇒ Object

Modifies scope membership by adding or removing resource assignments

Parameters:

  • resources (Array)

    The array of resources (or any number of resources separated by comma)

Raises:



33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/oneview-sdk/resource/api500/c7000/scope.rb', line 33

def change_resource_assignments(add_resources: [], remove_resources: [])
  if !add_resources.empty? || !remove_resources.empty?
    ensure_uri && ensure_client
    add_uris = ensure_and_get_uris(add_resources)
    remove_uris = ensure_and_get_uris(remove_resources)
    body = []

    add_uris.each do |uri|
      body << { 'op' => 'add', 'path' => '/addedResourceUris/-', 'value' => uri }
    end
    body << { 'op' => 'replace', 'path' => '/removedResourceUris', 'value' => remove_uris }

    response = @client.rest_patch(@data['uri'], { 'Content-Type' => 'application/json-patch+json', 'body' => body }, @api_version)
    @client.response_handler(response)
  end
  self
end

#patch(operation, path, value = nil) ⇒ Object

Note:

This attribute is subject to incompatible changes in future release versions, including redefinition or removal.

Performs a specific patch operation for the given server. If the server supports the particular operation, the operation is performed and a response is returned to the caller with the results.

Parameters:

  • operation (String)

    The operation to be performed

  • path (String)

    The path of operation

  • value (String) (defaults to: nil)

    The value



58
59
60
61
62
63
64
65
66
67
# File 'lib/oneview-sdk/resource/api500/c7000/scope.rb', line 58

def patch(operation, path, value = nil)
  ensure_client && ensure_uri
  body = {
    'op' => operation,
    'path' => path,
    'value' => value
  }
  response = @client.rest_patch(@data['uri'], { 'Content-Type' => 'application/json-patch+json', 'body' => [body] }, @api_version)
  @client.response_handler(response)
end