Class: Jamf::Account
- Defined in:
- lib/jamf/api/classic/api_objects/account.rb
Overview
A User or group in the JSS.
TODO: Split this into 2 classes, with lots of custom code. Thanks Jamf!
Constant Summary collapse
- RSRC_BASE =
The base for REST resources of this class
'accounts'.freeze
- RSRC_LIST_KEY =
the hash key used for the JSON list output of all objects in the JSS
:accounts
- RSRC_OBJECT_KEY =
The hash key used for the JSON object output. It's also used in various error messages
:account
- OTHER_LOOKUP_KEYS =
these keys, as well as :id and :name, can be used to look up objects of this class in the JSS
{ userid: { fetch_rsrc_key: :userid }, username: { fetch_rsrc_key: :username }, groupid: { fetch_rsrc_key: :groupid }, groupname: { fetch_rsrc_key: :groupname } }.freeze
Instance Attribute Summary collapse
-
#access_level ⇒ String
readonly
The user's access level.
-
#email ⇒ String
readonly
The user's email address.
-
#full_name ⇒ String
readonly
The user's full name.
-
#privilege_set ⇒ String
readonly
The user's privilege set.
-
#privileges ⇒ Hash
readonly
Info about the privileges assigned to the user.
Class Method Summary collapse
-
.all_group_ids(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>
All JSS account group ids.
-
.all_group_names(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>
All JSS account group names.
-
.all_groups(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>
All JSS account groups.
-
.all_ids(_refresh = false, **_bunk) ⇒ Object
override auto-defined method.
-
.all_names(_refresh = false, **_bunk) ⇒ Object
override auto-defined method.
-
.all_user_ids(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>
All JSS account user ids.
-
.all_user_names(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>
All JSS account user names.
-
.all_users(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>
All JSS account users.
Instance Method Summary collapse
-
#initialize(**args) ⇒ Account
constructor
See Jamf::APIObject#initialize.
Constructor Details
#initialize(**args) ⇒ Account
See Jamf::APIObject#initialize
160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/jamf/api/classic/api_objects/account.rb', line 160 def initialize(**args) super # check to see if a user has been specified, haven't built groups yet is_user = [:userid, :username].any? { |key| args.keys.include? key } return unless is_user @user_name = @init_data[:name] @full_name = @init_data[:full_name] @email = @init_data[:email] @access_level = @init_data[:access_level] @privilege_set = @init_data[:privilege_set] @privileges = @init_data[:privileges] end |
Instance Attribute Details
#access_level ⇒ String (readonly)
Returns The user's access level.
134 135 136 |
# File 'lib/jamf/api/classic/api_objects/account.rb', line 134 def access_level @access_level end |
#email ⇒ String (readonly)
Returns The user's email address.
131 132 133 |
# File 'lib/jamf/api/classic/api_objects/account.rb', line 131 def email @email end |
#full_name ⇒ String (readonly)
Returns The user's full name.
128 129 130 |
# File 'lib/jamf/api/classic/api_objects/account.rb', line 128 def full_name @full_name end |
#privilege_set ⇒ String (readonly)
Returns The user's privilege set.
137 138 139 |
# File 'lib/jamf/api/classic/api_objects/account.rb', line 137 def privilege_set @privilege_set end |
#privileges ⇒ Hash (readonly)
Info about the privileges assigned to the user
Note: these arrays may be empty, they always exist
The Hash keys are:
-
:jss_objects => An array of jss_object privileges
-
:jss_settings => An array of jss_settings privileges
-
:jss_actions => An array of jss_actions privileges
-
:recon => An array of Casper Recon privileges
-
:casper_admin => An array of Casper Admin privileges
-
:casper_remote => An array of Casper Remote privileges
-
:casper_imaging => An array of Casper Imaging privileges
153 154 155 |
# File 'lib/jamf/api/classic/api_objects/account.rb', line 153 def privileges @privileges end |
Class Method Details
.all_group_ids(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>
Returns all JSS account group ids.
113 114 115 116 |
# File 'lib/jamf/api/classic/api_objects/account.rb', line 113 def self.all_group_ids(refresh = false, api: nil, cnx: Jamf.cnx) cnx = api if api all(refresh, cnx: cnx)[:groups].map { |i| i[:id] } end |
.all_group_names(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>
Returns all JSS account group names.
119 120 121 122 |
# File 'lib/jamf/api/classic/api_objects/account.rb', line 119 def self.all_group_names(refresh = false, api: nil, cnx: Jamf.cnx) cnx = api if api all(refresh, cnx: cnx)[:groups].map { |i| i[:name] } end |
.all_groups(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>
Returns all JSS account groups.
107 108 109 110 |
# File 'lib/jamf/api/classic/api_objects/account.rb', line 107 def self.all_groups(refresh = false, api: nil, cnx: Jamf.cnx) cnx = api if api all(refresh, cnx: cnx)[:groups] end |
.all_ids(_refresh = false, **_bunk) ⇒ Object
override auto-defined method
79 80 81 |
# File 'lib/jamf/api/classic/api_objects/account.rb', line 79 def self.all_ids(_refresh = false, **_bunk) raise '.all_ids is not valid for Jamf::Account, use .all_user_ids or .all_group_ids' end |
.all_names(_refresh = false, **_bunk) ⇒ Object
override auto-defined method
84 85 86 |
# File 'lib/jamf/api/classic/api_objects/account.rb', line 84 def self.all_names(_refresh = false, **_bunk) raise '.all_names is not valid for Jamf::Account, use .all_user_names or .all_group_names' end |
.all_user_ids(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>
Returns all JSS account user ids.
95 96 97 98 |
# File 'lib/jamf/api/classic/api_objects/account.rb', line 95 def self.all_user_ids(refresh = false, api: nil, cnx: Jamf.cnx) cnx = api if api all(refresh, cnx: cnx)[:users].map { |i| i[:id] } end |
.all_user_names(refresh = false, api: nil, cnx: Jamf.cnx) ⇒ Array<Hash>
Returns all JSS account user names.
101 102 103 104 |
# File 'lib/jamf/api/classic/api_objects/account.rb', line 101 def self.all_user_names(refresh = false, api: nil, cnx: Jamf.cnx) cnx = api if api all(refresh, cnx: cnx)[:users].map { |i| i[:name] } end |