Class: JSS::User
- Includes:
- Creatable, Extendable, Updatable
- Defined in:
- lib/jss/api_object/user.rb,
lib/jss.rb
Overview
A User in the JSS.
Constant Summary collapse
- RSRC_BASE =
The base for REST resources of this class
"users"
- RSRC_LIST_KEY =
the hash key used for the JSON list output of all objects in the JSS
:users
- RSRC_OBJECT_KEY =
The hash key used for the JSON object output. It’s also used in various error messages
:user
- VALID_DATA_KEYS =
these keys, as well as :id and :name, are present in valid API JSON data for this class
[:position, :full_name, :email]
- SEARCH_CLASS =
This class lets us seach for users
JSS::AdvancedUserSearch
- EXT_ATTRIB_CLASS =
This is the class for relevant Extension Attributes
JSS::UserExtensionAttribute
Instance Attribute Summary collapse
-
#computers ⇒ Array<Hash>
readonly
The computers associated with this user.
-
#email ⇒ String
The user’s email address.
-
#ext_attrs ⇒ Hash
included
from Extendable
readonly
A mapping of Ext Attrib names to their values.
-
#extension_attributes ⇒ Array<Hash>
included
from Extendable
readonly
The extension attribute values for the object.
-
#full_name ⇒ String
The user’s full name.
-
#ldap_server ⇒ String
The name of the user’s LDAP server.
-
#mobile_devices ⇒ Array<Hash>
readonly
The mobile devices associated with this user.
-
#need_to_update ⇒ Boolean
included
from Updatable
readonly
Do we have unsaved changes?.
-
#peripherals ⇒ Array<Hash>
readonly
The peripherals associated with this user.
-
#phone_number ⇒ String
The user’s phone number.
-
#position ⇒ String
The user’s position / job title.
-
#sites ⇒ Array<Hash>
readonly
The sites associated with this user.
-
#total_vpp_code_count ⇒ Integer
readonly
The total number of vpp codes assigned to this user.
-
#vpp_assignments ⇒ Array<Hash>
readonly
The vpp assignments associated with this user.
Instance Method Summary collapse
-
#add_site(site) ⇒ void
Add this user to a site.
-
#clone(new_name) ⇒ APIObject
included
from Creatable
make a clone of this API object, with a new name.
-
#create ⇒ Integer
included
from Creatable
Create a new object in the JSS.
-
#ext_attr_xml ⇒ REXML::Element
included
from Extendable
private
An <extension_attribute> element to be included in the rest_xml of objects that mix-in this module.
-
#initialize(args = {}) ⇒ User
constructor
See JSS::APIObject#initialize.
-
#name=(newname) ⇒ void
included
from Updatable
Change the name of this item Remember to #update to push changes to the server.
-
#parse_ext_attrs ⇒ void
included
from Extendable
Populate @extension_attributes (the Array of Hashes that comes from the API) and @ext_attr_names, which is a Hash mapping the EA names to their index in the @extension_attributes Array.
-
#remove_site(site) ⇒ void
Remove this user from a site.
-
#set_ext_attr(name, value) ⇒ void
included
from Extendable
Set the value of an extension attribute.
-
#update ⇒ Boolean
included
from Updatable
Save changes to the JSS.
Constructor Details
#initialize(args = {}) ⇒ User
See JSS::APIObject#initialize
157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/jss/api_object/user.rb', line 157 def initialize (args = {}) super @full_name = @init_data[:full_name] @email = @init_data[:email] @phone_number = @init_data[:phone_number] @position = @init_data[:position] @ldap_server = JSS::APIObject.get_name @init_data[:ldap_server] @sites = @init_data[:sites] ? @init_data[:sites] : [] if @init_data[:links] @computers = @init_data[:links][:computers] @peripherals = @init_data[:links][:peripherals] @mobile_devices = @init_data[:links][:mobile_devices] @vpp_assignments = @init_data[:links][:vpp_assignments] @total_vpp_code_count = @init_data[:links][:total_vpp_code_count] end end |
Instance Attribute Details
#computers ⇒ Array<Hash> (readonly)
The computers associated with this user
Each Hash has then :id and :name for one computer
117 118 119 |
# File 'lib/jss/api_object/user.rb', line 117 def computers @computers end |
#email ⇒ String
Returns The user’s email address.
90 91 92 |
# File 'lib/jss/api_object/user.rb', line 90 def email @email end |
#ext_attrs ⇒ Hash (readonly) Originally defined in module Extendable
Returns A mapping of Ext Attrib names to their values.
#extension_attributes ⇒ Array<Hash> (readonly) Originally defined in module Extendable
Returns The extension attribute values for the object.
#full_name ⇒ String
Returns The user’s full name.
87 88 89 |
# File 'lib/jss/api_object/user.rb', line 87 def full_name @full_name end |
#ldap_server ⇒ String
Returns The name of the user’s LDAP server.
99 100 101 |
# File 'lib/jss/api_object/user.rb', line 99 def ldap_server @ldap_server end |
#mobile_devices ⇒ Array<Hash> (readonly)
This data is currently broken - the JSON output of the API only
The mobile devices associated with this user
Each Hash has then :id and :name for one device
returns one mobile device, and it isn’t formatted in a standard way.
137 138 139 |
# File 'lib/jss/api_object/user.rb', line 137 def mobile_devices @mobile_devices end |
#need_to_update ⇒ Boolean (readonly) Originally defined in module Updatable
Returns do we have unsaved changes?.
#peripherals ⇒ Array<Hash> (readonly)
The peripherals associated with this user
Each Hash has then :id and :name for one peripheral
126 127 128 |
# File 'lib/jss/api_object/user.rb', line 126 def peripherals @peripherals end |
#phone_number ⇒ String
Returns The user’s phone number.
93 94 95 |
# File 'lib/jss/api_object/user.rb', line 93 def phone_number @phone_number end |
#position ⇒ String
Returns The user’s position / job title.
96 97 98 |
# File 'lib/jss/api_object/user.rb', line 96 def position @position end |
#sites ⇒ Array<Hash> (readonly)
The sites associated with this user
Each Hash has then :id and :name for one site
108 109 110 |
# File 'lib/jss/api_object/user.rb', line 108 def sites @sites end |
#total_vpp_code_count ⇒ Integer (readonly)
Returns the total number of vpp codes assigned to this user.
148 149 150 |
# File 'lib/jss/api_object/user.rb', line 148 def total_vpp_code_count @total_vpp_code_count end |
Instance Method Details
#add_site(site) ⇒ void
This method returns an undefined value.
Add this user to a site
224 225 226 227 228 229 |
# File 'lib/jss/api_object/user.rb', line 224 def add_site (site) return nil if @sites.map{|s| s[:name]}.include? site raise JSS::InvalidDataError, "No site in the JSS named #{site}" unless JSS::Site.all_names.include? site @sites << {:name => site} @need_to_update = true end |
#clone(new_name) ⇒ APIObject Originally defined in module Creatable
make a clone of this API object, with a new name. The class must be creatable
#create ⇒ Integer Originally defined in module Creatable
Create a new object in the JSS.
#ext_attr_xml ⇒ REXML::Element Originally defined in module Extendable
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns An <extension_attribute> element to be included in the rest_xml of objects that mix-in this module.
#name=(newname) ⇒ void Originally defined in module Updatable
This method returns an undefined value.
Change the name of this item Remember to #update to push changes to the server.
#parse_ext_attrs ⇒ void Originally defined in module Extendable
This method returns an undefined value.
Populate @extension_attributes (the Array of Hashes that comes from the API) and @ext_attr_names, which is a Hash mapping the EA names to their index in the @extension_attributes Array.
Classes including this module should call this in #initialize
#remove_site(site) ⇒ void
This method returns an undefined value.
Remove this user from a site
238 239 240 241 242 |
# File 'lib/jss/api_object/user.rb', line 238 def remove_site (site) return nil unless @sites.map{|s| s[:name]}.include? site @sites.reject!{|s| s[:name] == site} @need_to_update = true end |
#set_ext_attr(name, value) ⇒ void Originally defined in module Extendable
This method returns an undefined value.
Set the value of an extension attribute
If the extension attribute is defined as a popup menu, the value must be one of the defined popup choices.
If the ext. attrib. is defined with a data type of Integer, the value must be an Integer.
If the ext. attrib. is defined with a data type of Date, the value will be converted to a Time
#update ⇒ Boolean Originally defined in module Updatable
Save changes to the JSS