Skip to content

Commit

Permalink
Adding scopeeUris query param
Browse files Browse the repository at this point in the history
  • Loading branch information
soodpr committed Mar 16, 2018
1 parent 3704d2d commit b5ca766
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
21 changes: 17 additions & 4 deletions examples/shared_samples/sas_logical_interconnect_group.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,23 @@
# NOTE: This will create a sas logical interconnect group named 'ONEVIEW_SDK_SAMPLE_SAS_LIG', update it and then delete it.
#
# Supported APIs:
# - 300, 500, 600
# - 300, 500

# Resources that can be created according to parameters:
# api_version = 300 & variant = Synergy to OneviewSDK::API300::Synergy::SASLogicalInterconnectGroup
# api_version = 500 & variant = Synergy to OneviewSDK::API500::Synergy::SASLogicalInterconnectGroup
# api_version = 600 & variant = Synergy to OneviewSDK::API600::Synergy::SASLogicalInterconnectGroup

# Resource Class used in this sample
sas_int_group_class = OneviewSDK.resource_named('SASLogicalInterconnectGroup', @client.api_version)
scope_class = OneviewSDK.resource_named('Scope', @client.api_version)

type = 'sas-logical-interconnect-group'
scope = scope_class.get_all(@client).first

type = 'SAS Logical Interconnect Group'

options = {
name: 'ONEVIEW_SDK_SAMPLE_SAS_LIG'
name: 'ONEVIEW_SDK_SAMPLE_SAS_LIG',
initialScopeUris: ['/rest/scopes/ed1e27d2-1940-481b-bf05-a94418ab17dc']
}

item = sas_int_group_class.new(@client, options)
Expand All @@ -41,6 +44,16 @@
item.create!
puts "\n#{type} #{item[:name]} created!"

# Gets a SAS LogicalInterconnectGroup by scopeUris
query = {
scopeUris: scope['uri']
}
if @client.api_version >= 600
puts "\nGets a SAS LogicalInterconnectGroup with scope '#{query[:scopeUris]}'"
item2 = sas_int_group_class.get_all_with_query(@client, query)
puts "Found SAS LogicalInterconnectGroup'#{item2}'."
end

options2 = {
name: 'UPDATED_ONEVIEW_SDK_SAMPLE_SAS_LIG '
}
Expand Down
5 changes: 5 additions & 0 deletions lib/oneview-sdk/resource.rb
Original file line number Diff line number Diff line change
Expand Up @@ -351,6 +351,11 @@ def self.build_query(query_options)
query_path.sub('?&', '?')
end

def self.get_all_with_query(client, query = null)
query_uri = build_query(query) if query
find_with_pagination(client, "#{self::BASE_URI}/#{query_uri}")
end

protected

# Fail unless @client is set for this resource.
Expand Down

0 comments on commit b5ca766

Please sign in to comment.