class Springcm::Account
Public Class Methods
new(data, client)
click to toggle source
Calls superclass method
# File lib/springcm-sdk/account.rb, line 6 def initialize(data, client) super(data, client) @all_attribute_groups = nil end
Public Instance Methods
all_attribute_groups()
click to toggle source
Retrieve all attribute groups for this account. Calls attribute_groups
and concatenates results to a cache that is returned from future calls to all_attribute_groups
.
# File lib/springcm-sdk/account.rb, line 14 def all_attribute_groups if @all_attribute_groups.nil? load_all_attribute_groups end @all_attribute_groups end
attribute_group(name: nil, uid: nil)
click to toggle source
# File lib/springcm-sdk/account.rb, line 40 def attribute_group(name: nil, uid: nil) if (name.nil? && uid.nil?) || (!name.nil? && !uid.nil?) raise ArgumentError.new("Specify exactly one of: name, uid") end all_attribute_groups.select { |group| (!name.nil? && group.name == name) || (!uid.nil? && group.uid == uid) }.first end
attribute_groups(offset: 0, limit: 20)
click to toggle source
Retrieve a page of attribute groups in this account. In most cases, you can call all_attribute_groups
instead, as attribute group configurations do not frequently change.
# File lib/springcm-sdk/account.rb, line 24 def attribute_groups(offset: 0, limit: 20) Helpers.validate_offset_limit!(offset, limit) conn = @client.authorized_connection(url: @client.object_api_url) res = conn.get do |req| req.url "accounts/current/attributegroups" req.params["offset"] = offset req.params["limit"] = limit end if res.success? data = JSON.parse(res.body) ResourceList.new(data, self, AttributeGroup, @client) else nil end end
Private Instance Methods
load_all_attribute_groups()
click to toggle source
# File lib/springcm-sdk/account.rb, line 51 def load_all_attribute_groups @all_attribute_groups = [] list = attribute_groups(offset: 0, limit: 20) while !list.nil? @all_attribute_groups.concat(list.items) list = list.next end end