class OneviewSDK::API500::C7000::Scope

Scope resource implementation for API500 C7000

Public Class Methods

new(client, params = {}, api_ver = nil) click to toggle source

Create a resource object, associate it with a client, and set its properties. @param [OneviewSDK::Client] client The client object for the OneView appliance @param [Hash] params The options for this resource (key-value pairs) @param [Integer] api_ver 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.
Calls superclass method OneviewSDK::API300::C7000::Scope::new
# File lib/oneview-sdk/resource/api500/c7000/scope.rb, line 24
def initialize(client, params = {}, api_ver = nil)
  @data ||= {}
  @data['type'] ||= 'ScopeV2'
  super
end

Public Instance Methods

change_resource_assignments(add_resources: [], remove_resources: []) click to toggle source

Modifies scope membership by adding or removing resource assignments @param [Array] resources The array of resources (or any number of resources separated by comma) @raise [OneviewSDK::IncompleteResource] if the client or uri is not set

# 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) click to toggle source

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. @param [String] operation The operation to be performed @param [String] path The path of operation @param [String] value The value @note This attribute is subject to incompatible changes in future release versions, including redefinition or removal.

# 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