ruby-jss 0.6.4 → 0.6.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of ruby-jss might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/lib/jss.rb +3 -0
- data/lib/jss/api_object.rb +27 -23
- data/lib/jss/api_object/account.rb +160 -0
- data/lib/jss/api_object/computer.rb +30 -12
- data/lib/jss/api_object/computer_invitation.rb +206 -0
- data/lib/jss/api_object/creatable.rb +7 -6
- data/lib/jss/api_object/distribution_point.rb +11 -6
- data/lib/jss/api_object/group.rb +13 -13
- data/lib/jss/api_object/osx_configuration_profile.rb +61 -59
- data/lib/jss/api_object/package.rb +41 -12
- data/lib/jss/api_object/restricted_software.rb +86 -0
- data/lib/jss/api_object/script.rb +1 -1
- data/lib/jss/api_object/self_servable.rb +55 -58
- data/lib/jss/api_object/updatable.rb +1 -1
- data/lib/jss/client.rb +1 -1
- data/lib/jss/version.rb +1 -1
- metadata +5 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: edccb1a8e4436aae8603aecc748d5cd817115144
|
4
|
+
data.tar.gz: 7f169bdfa8623ee12699e241872ddee9259d19b9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a25d238371cdfd1157b3e11320002ac10f6da9b90acf4b10cadfba5f54cc932d0b3d4525d22f3e471f318b778ed0c45afc987a560bb08afd3a86b0eec66bb19a
|
7
|
+
data.tar.gz: 48f2c4bc65aad055eb5e84eb3ef2a195706d4253cdb7b4a0ba3675d76fea364921ef7fb79002e78aea358138a4dd3b19056a4b1f425b4589cb3b5a3e2b929f3b
|
data/lib/jss.rb
CHANGED
@@ -159,6 +159,7 @@ module JSS
|
|
159
159
|
|
160
160
|
### APIObject Classes without SubClasses
|
161
161
|
|
162
|
+
class Account < JSS::APIObject ; end
|
162
163
|
class Building < JSS::APIObject ; end
|
163
164
|
class Category < JSS::APIObject ; end
|
164
165
|
class Computer < JSS::APIObject ; end
|
@@ -168,11 +169,13 @@ module JSS
|
|
168
169
|
class MobileDevice < JSS::APIObject ; end
|
169
170
|
class NetBootServer < JSS::APIObject ; end
|
170
171
|
class NetworkSegment < JSS::APIObject ; end
|
172
|
+
class OSXConfigurationProfile < JSS::APIObject ; end
|
171
173
|
class Package < JSS::APIObject ; end
|
172
174
|
class PeripheralType < JSS::APIObject ; end
|
173
175
|
class Peripheral < JSS::APIObject ; end
|
174
176
|
class Policy < JSS::APIObject ; end
|
175
177
|
class RemovableMacAddress < JSS::APIObject ; end
|
178
|
+
class RestrictedSoftware < JSS::APIObject ; end
|
176
179
|
class Script < JSS::APIObject ; end
|
177
180
|
class Site < JSS::APIObject ; end
|
178
181
|
class SoftwareUpdateServer < JSS::APIObject ; end
|
data/lib/jss/api_object.rb
CHANGED
@@ -1,25 +1,25 @@
|
|
1
1
|
### Copyright 2016 Pixar
|
2
|
-
###
|
2
|
+
###
|
3
3
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
4
|
### with the following modification; you may not use this file except in
|
5
5
|
### compliance with the Apache License and the following modification to it:
|
6
6
|
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
-
###
|
7
|
+
###
|
8
8
|
### 6. Trademarks. This License does not grant permission to use the trade
|
9
9
|
### names, trademarks, service marks, or product names of the Licensor
|
10
10
|
### and its affiliates, except as required to comply with Section 4(c) of
|
11
11
|
### the License and to reproduce the content of the NOTICE file.
|
12
|
-
###
|
12
|
+
###
|
13
13
|
### You may obtain a copy of the Apache License at
|
14
|
-
###
|
14
|
+
###
|
15
15
|
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
-
###
|
16
|
+
###
|
17
17
|
### Unless required by applicable law or agreed to in writing, software
|
18
18
|
### distributed under the Apache License with the above modification is
|
19
19
|
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
20
|
### KIND, either express or implied. See the Apache License for the specific
|
21
21
|
### language governing permissions and limitations under the Apache License.
|
22
|
-
###
|
22
|
+
###
|
23
23
|
###
|
24
24
|
|
25
25
|
###
|
@@ -235,11 +235,11 @@ module JSS
|
|
235
235
|
self.all(refresh).each{|i| h[i[:id]] = i[other_key]}
|
236
236
|
h
|
237
237
|
end
|
238
|
-
|
239
|
-
|
238
|
+
|
239
|
+
|
240
240
|
### Return an Array of JSS::APIObject subclass instances
|
241
241
|
### e.g when called on JSS::Package, return all JSS::Package
|
242
|
-
### objects in the JSS.
|
242
|
+
### objects in the JSS.
|
243
243
|
###
|
244
244
|
### NOTE: This may be slow as it has to look up each object individually!
|
245
245
|
### use it wisely.
|
@@ -251,11 +251,11 @@ module JSS
|
|
251
251
|
objects_key = "#{self::RSRC_LIST_KEY}_objects".to_sym
|
252
252
|
@@all_items[objects_key] = nil if refresh
|
253
253
|
return @@all_items[objects_key] if @@all_items[objects_key]
|
254
|
-
@@all_items[objects_key] = self.all(refresh = false).map{|o| self.new :id => o[:id]}
|
254
|
+
@@all_items[objects_key] = self.all(refresh = false).map{|o| self.new :id => o[:id]}
|
255
255
|
end
|
256
|
-
|
257
|
-
|
258
|
-
|
256
|
+
|
257
|
+
|
258
|
+
|
259
259
|
###
|
260
260
|
### Convert an Array of Hashes of API object data to a
|
261
261
|
### REXML element.
|
@@ -439,7 +439,7 @@ module JSS
|
|
439
439
|
@name = args[:name]
|
440
440
|
@init_data = {:name => args[:name]}
|
441
441
|
@in_jss = false
|
442
|
-
@rest_rsrc = "#{self.class::RSRC_BASE}/name/#{
|
442
|
+
@rest_rsrc = "#{self.class::RSRC_BASE}/name/#{CGI.escape @name}"
|
443
443
|
@need_to_update = true
|
444
444
|
return
|
445
445
|
|
@@ -488,13 +488,13 @@ module JSS
|
|
488
488
|
# many things have a :site
|
489
489
|
if @main_subset[:site]
|
490
490
|
@site = JSS::APIObject.get_name( @main_subset[:site])
|
491
|
-
end
|
492
|
-
|
491
|
+
end
|
492
|
+
|
493
493
|
# many things have a :category
|
494
494
|
if @main_subset[:category]
|
495
|
-
@category = JSS::APIObject.get_name( @main_subset[:category])
|
495
|
+
@category = JSS::APIObject.get_name( @main_subset[:category])
|
496
496
|
end
|
497
|
-
|
497
|
+
|
498
498
|
# set empty strings to nil
|
499
499
|
@init_data.jss_nillify! '', :recurse
|
500
500
|
|
@@ -540,7 +540,7 @@ module JSS
|
|
540
540
|
def delete
|
541
541
|
return nil unless @in_jss
|
542
542
|
JSS::API.delete_rsrc @rest_rsrc
|
543
|
-
@rest_rsrc = "#{self.class::RSRC_BASE}/name/#{
|
543
|
+
@rest_rsrc = "#{self.class::RSRC_BASE}/name/#{CGI.escape @name}"
|
544
544
|
@id = nil
|
545
545
|
@in_jss = false
|
546
546
|
@need_to_update = false
|
@@ -565,11 +565,11 @@ module JSS
|
|
565
565
|
return doc.to_s
|
566
566
|
end
|
567
567
|
|
568
|
-
|
568
|
+
|
569
569
|
### Aliases
|
570
|
-
|
570
|
+
|
571
571
|
alias in_jss? in_jss
|
572
|
-
|
572
|
+
|
573
573
|
end # class APIObject
|
574
574
|
|
575
575
|
|
@@ -584,6 +584,7 @@ require "jss/api_object/matchable"
|
|
584
584
|
require "jss/api_object/purchasable"
|
585
585
|
require "jss/api_object/updatable"
|
586
586
|
require "jss/api_object/extendable"
|
587
|
+
require "jss/api_object/self_servable"
|
587
588
|
|
588
589
|
### Mix-in Sub Modules with Classes
|
589
590
|
require "jss/api_object/criteriable"
|
@@ -595,22 +596,25 @@ require "jss/api_object/extension_attribute"
|
|
595
596
|
require "jss/api_object/group"
|
596
597
|
|
597
598
|
### APIObject SubClasses without SubClasses
|
599
|
+
require "jss/api_object/account"
|
598
600
|
require "jss/api_object/building"
|
599
601
|
require "jss/api_object/category"
|
600
602
|
require "jss/api_object/computer"
|
603
|
+
require "jss/api_object/computer_invitation"
|
601
604
|
require "jss/api_object/department"
|
602
605
|
require "jss/api_object/distribution_point"
|
603
606
|
require "jss/api_object/ldap_server"
|
604
607
|
require "jss/api_object/mobile_device"
|
605
608
|
require "jss/api_object/netboot_server"
|
606
609
|
require "jss/api_object/network_segment"
|
610
|
+
require "jss/api_object/osx_configuration_profile"
|
607
611
|
require "jss/api_object/package"
|
608
612
|
require "jss/api_object/peripheral_type"
|
609
613
|
require "jss/api_object/peripheral"
|
610
614
|
require "jss/api_object/policy"
|
611
615
|
require "jss/api_object/removable_macaddr"
|
616
|
+
require "jss/api_object/restricted_software"
|
612
617
|
require "jss/api_object/script"
|
613
618
|
require "jss/api_object/site"
|
614
619
|
require "jss/api_object/software_update_server"
|
615
620
|
require "jss/api_object/user"
|
616
|
-
|
@@ -0,0 +1,160 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
###
|
26
|
+
module JSS
|
27
|
+
|
28
|
+
#####################################
|
29
|
+
### Module Variables
|
30
|
+
#####################################
|
31
|
+
|
32
|
+
#####################################
|
33
|
+
### Module Methods
|
34
|
+
#####################################
|
35
|
+
|
36
|
+
#####################################
|
37
|
+
### Classes
|
38
|
+
#####################################
|
39
|
+
|
40
|
+
###
|
41
|
+
### A User in the JSS.
|
42
|
+
###
|
43
|
+
### @see JSS::APIObject
|
44
|
+
###
|
45
|
+
class Account < JSS::APIObject
|
46
|
+
|
47
|
+
### Note: This class is not fully extended and since the resource
|
48
|
+
### is different than the rest, methods like JSS::Account.all do not work
|
49
|
+
|
50
|
+
#####################################
|
51
|
+
### Mix-Ins
|
52
|
+
#####################################
|
53
|
+
|
54
|
+
#####################################
|
55
|
+
### Class Methods
|
56
|
+
#####################################
|
57
|
+
|
58
|
+
### @return [Array<Hash>] all JSS account users
|
59
|
+
def self.all_users(refresh = false)
|
60
|
+
self.all(refresh)[:users]
|
61
|
+
end
|
62
|
+
|
63
|
+
### @return [Array<Hash>] all JSS account user ids
|
64
|
+
def self.all_user_ids(refresh = false)
|
65
|
+
self.all(refresh)[:users].map{|i| i[:id]}
|
66
|
+
end
|
67
|
+
|
68
|
+
### @return [Array<Hash>] all JSS account user names
|
69
|
+
def self.all_user_names(refresh = false)
|
70
|
+
self.all(refresh)[:users].map{|i| i[:name]}
|
71
|
+
end
|
72
|
+
|
73
|
+
### @return [Array<Hash>] all JSS account groups
|
74
|
+
def self.all_groups(refresh = false)
|
75
|
+
self.all(refresh)[:groups]
|
76
|
+
end
|
77
|
+
|
78
|
+
### @return [Array<Hash>] all JSS account group ids
|
79
|
+
def self.all_group_ids(refresh = false)
|
80
|
+
self.all(refresh)[:groups].map{|i| i[:id]}
|
81
|
+
end
|
82
|
+
|
83
|
+
### @return [Array<Hash>] all JSS account group names
|
84
|
+
def self.all_group_names(refresh = false)
|
85
|
+
self.all(refresh)[:groups].map{|i| i[:name]}
|
86
|
+
end
|
87
|
+
|
88
|
+
#####################################
|
89
|
+
### Class Constants
|
90
|
+
#####################################
|
91
|
+
|
92
|
+
### The base for REST resources of this class
|
93
|
+
RSRC_BASE = "accounts"
|
94
|
+
|
95
|
+
### the hash key used for the JSON list output of all objects in the JSS
|
96
|
+
RSRC_LIST_KEY = :accounts
|
97
|
+
|
98
|
+
### The hash key used for the JSON object output.
|
99
|
+
### It's also used in various error messages
|
100
|
+
RSRC_OBJECT_KEY = :account
|
101
|
+
|
102
|
+
#####################################
|
103
|
+
### Attributes
|
104
|
+
#####################################
|
105
|
+
|
106
|
+
### @return [String] The user's full name
|
107
|
+
attr_reader :full_name
|
108
|
+
|
109
|
+
### @return [String] The user's email address
|
110
|
+
attr_reader :email
|
111
|
+
|
112
|
+
### @return [String] The user's access level
|
113
|
+
attr_reader :access_level
|
114
|
+
|
115
|
+
### @return [String] The user's privilege set
|
116
|
+
attr_reader :privilege_set
|
117
|
+
|
118
|
+
### @return [Hash]
|
119
|
+
###
|
120
|
+
### Info about the privileges assigned to the user
|
121
|
+
###
|
122
|
+
### Note: these arrays may be empty, they always exist
|
123
|
+
###
|
124
|
+
### The Hash keys are:
|
125
|
+
### * :jss_objects => An array of jss_object privileges
|
126
|
+
### * :jss_settings => An array of jss_settings privileges
|
127
|
+
### * :jss_actions => An array of jss_actions privileges
|
128
|
+
### * :recon => An array of Casper Recon privileges
|
129
|
+
### * :casper_admin => An array of Casper Admin privileges
|
130
|
+
### * :casper_remote => An array of Casper Remote privileges
|
131
|
+
### * :casper_imaging => An array of Casper Imaging privileges
|
132
|
+
attr_reader :privileges
|
133
|
+
|
134
|
+
#####################################
|
135
|
+
### Constructor
|
136
|
+
#####################################
|
137
|
+
|
138
|
+
###
|
139
|
+
### See JSS::APIObject#initialize
|
140
|
+
###
|
141
|
+
def initialize (args = {})
|
142
|
+
super args, [:userid, :username, :groupid, :groupname]
|
143
|
+
|
144
|
+
# check to see if a user has been specified, haven't built groups yet
|
145
|
+
is_user = [:userid, :username].any? { |key| args.keys.include? key }
|
146
|
+
|
147
|
+
if is_user
|
148
|
+
@user_name = @init_data[:name]
|
149
|
+
@full_name = @init_data[:full_name]
|
150
|
+
@email = @init_data[:email]
|
151
|
+
@access_level = @init_data[:access_level]
|
152
|
+
@privilege_set = @init_data[:privilege_set]
|
153
|
+
@privileges = @init_data[:privileges]
|
154
|
+
end
|
155
|
+
|
156
|
+
end # initialize
|
157
|
+
|
158
|
+
end # class accounts
|
159
|
+
|
160
|
+
end # module
|
@@ -1,25 +1,25 @@
|
|
1
1
|
### Copyright 2016 Pixar
|
2
|
-
###
|
2
|
+
###
|
3
3
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
4
|
### with the following modification; you may not use this file except in
|
5
5
|
### compliance with the Apache License and the following modification to it:
|
6
6
|
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
-
###
|
7
|
+
###
|
8
8
|
### 6. Trademarks. This License does not grant permission to use the trade
|
9
9
|
### names, trademarks, service marks, or product names of the Licensor
|
10
10
|
### and its affiliates, except as required to comply with Section 4(c) of
|
11
11
|
### the License and to reproduce the content of the NOTICE file.
|
12
|
-
###
|
12
|
+
###
|
13
13
|
### You may obtain a copy of the Apache License at
|
14
|
-
###
|
14
|
+
###
|
15
15
|
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
-
###
|
16
|
+
###
|
17
17
|
### Unless required by applicable law or agreed to in writing, software
|
18
18
|
### distributed under the Apache License with the above modification is
|
19
19
|
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
20
|
### KIND, either express or implied. See the Apache License for the specific
|
21
21
|
### language governing permissions and limitations under the Apache License.
|
22
|
-
###
|
22
|
+
###
|
23
23
|
###
|
24
24
|
|
25
25
|
###
|
@@ -319,7 +319,7 @@ module JSS
|
|
319
319
|
|
320
320
|
### @return [String] the barcodes
|
321
321
|
attr_reader :barcode_1, :barcode_2
|
322
|
-
|
322
|
+
|
323
323
|
|
324
324
|
### @return [String] The name of the distribution point for this computer
|
325
325
|
attr_reader :distribution_point
|
@@ -359,7 +359,7 @@ module JSS
|
|
359
359
|
|
360
360
|
### @return [String] the serial number
|
361
361
|
attr_reader :serial_number
|
362
|
-
|
362
|
+
|
363
363
|
|
364
364
|
### @return [Hash] the :name and :id of the site for this machine
|
365
365
|
attr_reader :site
|
@@ -593,16 +593,34 @@ module JSS
|
|
593
593
|
def local_accounts
|
594
594
|
@groups_accounts[:local_accounts]
|
595
595
|
end
|
596
|
-
|
597
596
|
|
597
|
+
|
598
|
+
### @return [Boolean] is FileVault2 enabled?
|
598
599
|
###
|
600
|
+
def filevault2_enabled?
|
601
|
+
boot_drive[:partition][:filevault2_status] != "Not Encrypted"
|
602
|
+
end
|
603
|
+
|
604
|
+
### @return [Array<Hash>] The local_accounts Array that have Legacy FV enabled
|
605
|
+
###
|
606
|
+
def filevault1_accounts
|
607
|
+
return [] if filevault2_enabled?
|
608
|
+
local_accounts.select{ |a| a[:filevault_enabled] }
|
609
|
+
end
|
610
|
+
|
599
611
|
### @return [Array<Hash>] each storage device
|
600
612
|
###
|
601
613
|
def drives
|
602
614
|
@hardware[:storage]
|
603
615
|
end
|
604
616
|
|
617
|
+
### @return [Hash, nil] The hardware[:storage] hash of the boot drive
|
605
618
|
###
|
619
|
+
def boot_drive
|
620
|
+
drives.each{ |d| return d if d[:partition][:type] == "boot" }
|
621
|
+
return nil
|
622
|
+
end
|
623
|
+
|
606
624
|
### @return [Array<Hash>] each printer on this computer
|
607
625
|
### Keys are :name, :uri, :type, :location
|
608
626
|
###
|
@@ -755,8 +773,8 @@ module JSS
|
|
755
773
|
@purchasing = nil
|
756
774
|
@software = nil
|
757
775
|
end #delete
|
758
|
-
|
759
|
-
|
776
|
+
|
777
|
+
|
760
778
|
# Not Functional until I get more docs from JAMF
|
761
779
|
#
|
762
780
|
# ###
|
@@ -786,7 +804,7 @@ module JSS
|
|
786
804
|
# alias erase erase_device
|
787
805
|
# alias wipe erase_device
|
788
806
|
|
789
|
-
|
807
|
+
|
790
808
|
### aliases
|
791
809
|
alias alt_macaddress alt_mac_address
|
792
810
|
alias bar_code_1 barcode_1
|
@@ -0,0 +1,206 @@
|
|
1
|
+
### Copyright 2016 Pixar
|
2
|
+
###
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
4
|
+
### with the following modification; you may not use this file except in
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
7
|
+
###
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
12
|
+
###
|
13
|
+
### You may obtain a copy of the Apache License at
|
14
|
+
###
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
16
|
+
###
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
18
|
+
### distributed under the Apache License with the above modification is
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
22
|
+
###
|
23
|
+
###
|
24
|
+
|
25
|
+
###
|
26
|
+
module JSS
|
27
|
+
|
28
|
+
#####################################
|
29
|
+
### Module Constants
|
30
|
+
#####################################
|
31
|
+
|
32
|
+
#####################################
|
33
|
+
### Module Variables
|
34
|
+
#####################################
|
35
|
+
|
36
|
+
#####################################
|
37
|
+
### Module Methods
|
38
|
+
#####################################
|
39
|
+
|
40
|
+
###
|
41
|
+
### This class represents a Computer Invitation in the JSS.
|
42
|
+
###
|
43
|
+
### ===Adding Computer Invitations to the JSS
|
44
|
+
###
|
45
|
+
### This class is meant only to generate and hold the response of creating
|
46
|
+
### an invitation.
|
47
|
+
###
|
48
|
+
### @see APIObject
|
49
|
+
### @see Creatable
|
50
|
+
###
|
51
|
+
|
52
|
+
class ComputerInvitation < JSS::APIObject
|
53
|
+
|
54
|
+
#####################################
|
55
|
+
### MixIns
|
56
|
+
#####################################
|
57
|
+
|
58
|
+
include JSS::Creatable
|
59
|
+
|
60
|
+
#####################################
|
61
|
+
### Class Variables
|
62
|
+
#####################################
|
63
|
+
|
64
|
+
#####################################
|
65
|
+
### Class Methods
|
66
|
+
#####################################
|
67
|
+
|
68
|
+
#####################################
|
69
|
+
### Class Constants
|
70
|
+
#####################################
|
71
|
+
|
72
|
+
### The base for REST resources of this class
|
73
|
+
RSRC_BASE = "computerinvitations"
|
74
|
+
|
75
|
+
### the hash key used for the JSON list output of all objects in the JSS
|
76
|
+
RSRC_LIST_KEY = :computer_invitations
|
77
|
+
|
78
|
+
### The hash key used for the JSON object output.
|
79
|
+
### It's also used in various error messages
|
80
|
+
RSRC_OBJECT_KEY = :computer_invitation
|
81
|
+
|
82
|
+
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
83
|
+
VALID_DATA_KEYS = [:invitation]
|
84
|
+
|
85
|
+
#####################################
|
86
|
+
### Attributes
|
87
|
+
#####################################
|
88
|
+
|
89
|
+
### The values returned in the General, Location, and Purchasing subsets are stored as direct attributes
|
90
|
+
### Location and Purchasing are defined in the Locatable and Purchasable mixin modules.
|
91
|
+
### Here's General, in alphabetical order
|
92
|
+
|
93
|
+
### @return [String] the invitation name
|
94
|
+
attr_reader :name
|
95
|
+
|
96
|
+
### @return [String] the invitation type
|
97
|
+
###
|
98
|
+
### Valid values are: URL and EMAIL. Will default to DEFAULT.
|
99
|
+
attr_accessor :invitation_type
|
100
|
+
|
101
|
+
### @return [String] whether or not to create the account if required
|
102
|
+
###
|
103
|
+
### "true" or "false" are valid values.
|
104
|
+
attr_accessor :create_account_if_does_not_exist
|
105
|
+
|
106
|
+
### @return [String]
|
107
|
+
###
|
108
|
+
### Time since epoch that the invitation will expire at.
|
109
|
+
###
|
110
|
+
### Note: defaults to "Unlimited", so only set if it should expire.
|
111
|
+
attr_accessor :expiration_date_epoch
|
112
|
+
|
113
|
+
### @return [String]
|
114
|
+
###
|
115
|
+
### The username of the ssh user to be created.
|
116
|
+
###
|
117
|
+
### REQUIRED for valid setup.
|
118
|
+
attr_accessor :ssh_username
|
119
|
+
|
120
|
+
### @return [String]
|
121
|
+
###
|
122
|
+
### The whether or not to hide the ssh user.
|
123
|
+
attr_accessor :hide_account
|
124
|
+
|
125
|
+
### @return [String]
|
126
|
+
###
|
127
|
+
### The invitation_status.
|
128
|
+
attr_accessor :invitation_status
|
129
|
+
|
130
|
+
### @return [String]
|
131
|
+
###
|
132
|
+
### Whether the invitation can be used multiple times (boolean).
|
133
|
+
attr_accessor :multiple_uses_allowed
|
134
|
+
|
135
|
+
#####################################
|
136
|
+
### Public Instance Methods
|
137
|
+
#####################################
|
138
|
+
|
139
|
+
###
|
140
|
+
### @see APIObject#initialize
|
141
|
+
###
|
142
|
+
def initialize(args = {
|
143
|
+
id: :new,
|
144
|
+
name: "some_new_name",
|
145
|
+
ssh_username: "casper_remote",
|
146
|
+
hide_account: "true" } )
|
147
|
+
|
148
|
+
super args, []
|
149
|
+
|
150
|
+
@name = @init_data[:invitation]
|
151
|
+
@invitation_type = @init_data[:invitation_type]
|
152
|
+
@create_account_if_does_not_exist = @init_data[:create_account_if_does_not_exist]
|
153
|
+
@expiration_date_epoch = @init_data[:expiration_date_epoch] || args[:expiration_date_epoch]
|
154
|
+
@ssh_username = @init_data[:ssh_username] || args[:ssh_username]
|
155
|
+
@hide_account = @init_data[:hide_account] || args[:hide_account]
|
156
|
+
@invitation_status = @init_data[:invitation_status] || args[:invitation_status]
|
157
|
+
@multiple_uses_allowed = @init_data[:multiple_uses_allowed] || args[:multiple_uses_allowed]
|
158
|
+
end
|
159
|
+
|
160
|
+
#####################################
|
161
|
+
### Public Class Methods
|
162
|
+
#####################################
|
163
|
+
|
164
|
+
###
|
165
|
+
### Needed to support creation of new Computer Invitations to set their name.
|
166
|
+
###
|
167
|
+
### @return [JSS::ComputerInvitation]
|
168
|
+
###
|
169
|
+
def create
|
170
|
+
new_invitation_id = super
|
171
|
+
|
172
|
+
jss_me = ComputerInvitation.new(id: new_invitation_id, name: 'set_by_request')
|
173
|
+
@name = jss_me.name
|
174
|
+
@invitation_type = jss_me.invitation_type
|
175
|
+
@create_account_if_does_not_exist = jss_me.create_account_if_does_not_exist
|
176
|
+
@expiration_date_epoch = jss_me.expiration_date_epoch
|
177
|
+
@ssh_username = jss_me.ssh_username
|
178
|
+
@hide_account = jss_me.hide_account
|
179
|
+
@invitation_status = jss_me.invitation_status
|
180
|
+
@multiple_uses_allowed = jss_me.multiple_uses_allowed
|
181
|
+
end
|
182
|
+
|
183
|
+
#####################################
|
184
|
+
### Private Instance Methods
|
185
|
+
#####################################
|
186
|
+
private
|
187
|
+
|
188
|
+
###
|
189
|
+
### Sets invitation expiration 4 hours after request.
|
190
|
+
###
|
191
|
+
def rest_xml
|
192
|
+
doc = REXML::Document.new APIConnection::XML_HEADER
|
193
|
+
obj = doc.add_element RSRC_OBJECT_KEY.to_s
|
194
|
+
obj.add_element('invitation_type').text = invitation_type
|
195
|
+
obj.add_element('create_account_if_does_not_exist').text = create_account_if_does_not_exist
|
196
|
+
if expiration_date_epoch
|
197
|
+
obj.add_element('expiration_date_epoch').text = expiration_date_epoch
|
198
|
+
end
|
199
|
+
obj.add_element('ssh_username').text = ssh_username
|
200
|
+
obj.add_element('hide_account').text = hide_account
|
201
|
+
obj.add_element('invitation_status').text = invitation_status
|
202
|
+
obj.add_element('multiple_uses_allowed').text = multiple_uses_allowed
|
203
|
+
return doc.to_s
|
204
|
+
end
|
205
|
+
end
|
206
|
+
end
|