class OneviewSDK::API300::C7000::Scope

Scope resource implementation for API300 C7k

Constants

BASE_URI

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::Resource::new
# File lib/oneview-sdk/resource/api300/c7000/scope.rb, line 26
def initialize(client, params = {}, api_ver = nil)
  @data ||= {}
  @data['type'] ||= 'Scope'
  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/api300/c7000/scope.rb, line 74
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 = {
      'addedResourceUris' => add_uris,
      'removedResourceUris' => remove_uris
    }
    response = @client.rest_patch(@data['uri'] + '/resource-assignments', 'body' => body)
    @client.response_handler(response)
  end
  self
end
delete(header = {}) click to toggle source

Delete resource from OneView @param [Hash] header The header options for the request (key-value pairs) @raise [OneviewSDK::IncompleteResource] if the client or uri is not set @return [true] if resource was deleted successfully

Calls superclass method OneviewSDK::Resource#delete
# File lib/oneview-sdk/resource/api300/c7000/scope.rb, line 53
def delete(header = {})
  super(DEFAULT_REQUEST_HEADER.merge(header).merge('If-Match' => @data['eTag']))
end
set_resources(*resources) click to toggle source

Adds 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/api300/c7000/scope.rb, line 60
def set_resources(*resources)
  change_resource_assignments(add_resources: resources.flatten)
end
unset_resources(*resources) click to toggle source

Removes 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/api300/c7000/scope.rb, line 67
def unset_resources(*resources)
  change_resource_assignments(remove_resources: resources.flatten)
end
update(attributes = {}) click to toggle source

Set data and save to OneView @param [Hash] attributes The attributes to add/change for this resource (key-value pairs) @raise [OneviewSDK::IncompleteResource] if the client or uri is not set @raise [StandardError] if the resource save fails @return [Resource] self

# File lib/oneview-sdk/resource/api300/c7000/scope.rb, line 37
def update(attributes = {})
  set_all(attributes)
  ensure_client && ensure_uri
  options = {
    'If-Match' => @data.delete('eTag'),
    'body' => @data
  }
  response = @client.rest_put(@data['uri'], options, @api_version)
  @client.response_handler(response)
  self
end