Class: Springcm::Account
Instance Method Summary collapse
-
#all_attribute_groups ⇒ Object
Retrieve all attribute groups for this account.
- #attribute_group(name: nil, uid: nil) ⇒ Object
-
#attribute_groups(offset: 0, limit: 20) ⇒ Object
Retrieve a page of attribute groups in this account.
-
#initialize(data, client) ⇒ Account
constructor
A new instance of Account.
Methods inherited from Object
Constructor Details
#initialize(data, client) ⇒ Account
Returns a new instance of Account.
6 7 8 9 |
# File 'lib/springcm-sdk/account.rb', line 6 def initialize(data, client) super(data, client) @all_attribute_groups = nil end |
Dynamic Method Handling
This class handles dynamic methods through the method_missing method in the class Springcm::Object
Instance Method Details
#all_attribute_groups ⇒ Object
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.
14 15 16 17 18 19 |
# 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) ⇒ Object
40 41 42 43 44 45 46 47 |
# 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) ⇒ Object
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.
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/springcm-sdk/account.rb', line 24 def attribute_groups(offset: 0, limit: 20) Helpers.validate_offset_limit!(offset, limit) conn = @client.(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 |