Module: OneviewSDK::API300::C7000::Scope::ScopeHelperMethods
- Included in:
- Enclosure, EthernetNetwork, FCNetwork, FCoENetwork, LogicalInterconnect, LogicalInterconnectGroup, LogicalSwitch, LogicalSwitchGroup, NetworkSet, OneviewSDK::API300::C7000::ServerHardware, OneviewSDK::API300::C7000::Switch, Synergy::EthernetNetwork, Synergy::FCNetwork, Synergy::FCoENetwork, OneviewSDK::API500::C7000::FCNetwork, OneviewSDK::API500::Synergy::FCNetwork
- Defined in:
- lib/oneview-sdk/resource/api300/c7000/scope.rb
Overview
Helper methods for add, remove and replace scopes from the another resources
Instance Method Summary collapse
-
#add_scope(scope) ⇒ Object
Add one scope to the resource.
-
#patch(operation, path, value = nil) ⇒ Object
Performs a specific patch operation for the given server.
-
#remove_scope(scope) ⇒ Boolean
Remove one scope from the resource.
-
#replace_scopes(*scopes) ⇒ Object
Change the list of scopes in the resource.
Instance Method Details
#add_scope(scope) ⇒ Object
Add one scope to the resource
112 113 114 115 |
# 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) ⇒ 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.
98 99 100 101 102 103 104 105 106 107 |
# 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) ⇒ Boolean
Remove one scope from the resource
121 122 123 124 125 126 127 |
# 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) ⇒ Object
Change the list of scopes in the resource
132 133 134 135 |
# 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 |