module OneviewSDK::API300::C7000::Scope::ScopeHelperMethods

Helper methods for add, remove and replace scopes from the another resources

Public Instance Methods

add_scope(scope) click to toggle source

Add one scope to the resource @param [OneviewSDK::API300::C7000::Scope] scope The scope resource @raise [OneviewSDK::IncompleteResource] if the uri of scope is not set

# File lib/oneview-sdk/resource/api300/c7000/scope.rb, line 112
def add_scope(scope)
  scope.ensure_uri
  patch('add', '/scopeUris/-', scope['uri'])
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/api300/c7000/scope.rb, line 98
def patch(operation, path, value = nil)
  ensure_client && ensure_uri
  body = {
    'op' => operation,
    'path' => path,
    'value' => value
  }
  response = @client.rest_patch(@data['uri'], { 'body' => [body] }, @api_version)
  @client.response_handler(response)
end
remove_scope(scope) click to toggle source

Remove one scope from the resource @param [OneviewSDK::API300::C7000::Scope] scope The scope resource @return [Boolean] True if the scope was deleted and false if enclosure has not the scope @raise [OneviewSDK::IncompleteResource] if the uri of scope is not set

# File lib/oneview-sdk/resource/api300/c7000/scope.rb, line 121
def remove_scope(scope)
  scope.ensure_uri
  scope_index = @data['scopeUris'].find_index { |uri| uri == scope['uri'] }
  return false unless scope_index
  patch('remove', "/scopeUris/#{scope_index}", nil)
  true
end
replace_scopes(*scopes) click to toggle source

Change the list of scopes in the resource @param [Array<OneviewSDK::API300::C7000::Scope>] scopes The scopes list (or scopes separeted by comma) @raise [OneviewSDK::IncompleteResource] if the uri of each scope is not set

# File lib/oneview-sdk/resource/api300/c7000/scope.rb, line 132
def replace_scopes(*scopes)
  uris = ensure_and_get_uris(scopes.flatten)
  patch('replace', '/scopeUris', uris)
end