ruby-jss 1.0.4 → 1.1.0b1
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/CHANGES.md +26 -0
- data/lib/jss.rb +47 -24
- data/lib/jss/api_connection.rb +39 -7
- data/lib/jss/api_object.rb +651 -319
- data/lib/jss/api_object/account.rb +19 -5
- data/lib/jss/api_object/advanced_search/advanced_computer_search.rb +0 -3
- data/lib/jss/api_object/advanced_search/advanced_mobile_device_search.rb +0 -3
- data/lib/jss/api_object/advanced_search/advanced_user_search.rb +0 -3
- data/lib/jss/api_object/building.rb +0 -3
- data/lib/jss/api_object/category.rb +0 -3
- data/lib/jss/api_object/computer.rb +83 -28
- data/lib/jss/api_object/computer_invitation.rb +1 -11
- data/lib/jss/api_object/configuration_profile/osx_configuration_profile.rb +0 -3
- data/lib/jss/api_object/department.rb +0 -3
- data/lib/jss/api_object/distribution_point.rb +0 -3
- data/lib/jss/api_object/extendable.rb +113 -57
- data/lib/jss/api_object/extension_attribute.rb +46 -13
- data/lib/jss/api_object/extension_attribute/computer_extension_attribute.rb +0 -3
- data/lib/jss/api_object/extension_attribute/mobile_device_extension_attribute.rb +56 -19
- data/lib/jss/api_object/extension_attribute/user_extension_attribute.rb +0 -3
- data/lib/jss/api_object/group/computer_group.rb +0 -3
- data/lib/jss/api_object/group/mobile_device_group.rb +0 -3
- data/lib/jss/api_object/group/user_group.rb +0 -3
- data/lib/jss/api_object/ldap_server.rb +0 -3
- data/lib/jss/api_object/mobile_device.rb +25 -29
- data/lib/jss/api_object/mobile_device_application.rb +1 -9
- data/lib/jss/api_object/netboot_server.rb +0 -3
- data/lib/jss/api_object/network_segment.rb +0 -3
- data/lib/jss/api_object/package.rb +0 -3
- data/lib/jss/api_object/patch_source/patch_external_source.rb +0 -2
- data/lib/jss/api_object/patch_source/patch_internal_source.rb +0 -3
- data/lib/jss/api_object/patch_title.rb +1 -2
- data/lib/jss/api_object/peripheral.rb +0 -3
- data/lib/jss/api_object/peripheral_type.rb +0 -2
- data/lib/jss/api_object/policy.rb +20 -2
- data/lib/jss/api_object/removable_macaddr.rb +0 -3
- data/lib/jss/api_object/restricted_software.rb +0 -3
- data/lib/jss/api_object/scopable.rb +0 -12
- data/lib/jss/api_object/scopable/scope.rb +1 -1
- data/lib/jss/api_object/script.rb +0 -3
- data/lib/jss/api_object/self_servable.rb +3 -1
- data/lib/jss/api_object/site.rb +0 -3
- data/lib/jss/api_object/software_update_server.rb +0 -3
- data/lib/jss/api_object/user.rb +0 -3
- data/lib/jss/api_object/webhook.rb +0 -3
- data/lib/jss/compatibility.rb +74 -53
- data/lib/jss/exceptions.rb +5 -0
- data/lib/jss/ruby_extensions/string.rb +4 -48
- data/lib/jss/ruby_extensions/string/conversions.rb +69 -0
- data/lib/jss/ruby_extensions/string/predicates.rb +47 -0
- data/lib/jss/version.rb +1 -1
- data/test/README.md +2 -4
- metadata +6 -4
@@ -70,9 +70,6 @@ module JSS
|
|
70
70
|
### It's also used in various error messages
|
71
71
|
RSRC_OBJECT_KEY = :netboot_server
|
72
72
|
|
73
|
-
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
74
|
-
VALID_DATA_KEYS = [:protocol, :boot_args]
|
75
|
-
|
76
73
|
# the object type for this object in
|
77
74
|
# the object history table.
|
78
75
|
# See {APIObject#add_object_history_entry}
|
@@ -59,9 +59,6 @@ module JSS
|
|
59
59
|
### It's also used in various error messages
|
60
60
|
RSRC_OBJECT_KEY = :network_segment
|
61
61
|
|
62
|
-
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
63
|
-
VALID_DATA_KEYS = [:distribution_point, :starting_address, :override_departments].freeze
|
64
|
-
|
65
62
|
# the object type for this object in
|
66
63
|
# the object history table.
|
67
64
|
# See {APIObject#add_object_history_entry}
|
@@ -61,9 +61,6 @@ module JSS
|
|
61
61
|
# It's also used in various error messages
|
62
62
|
RSRC_OBJECT_KEY = :package
|
63
63
|
|
64
|
-
# these keys, as well as :id and :name, are present in valid API JSON data for this class
|
65
|
-
VALID_DATA_KEYS = %i[fill_existing_users fill_user_template reboot_required].freeze
|
66
|
-
|
67
64
|
# The pkg storage folder on the distribution point
|
68
65
|
DIST_POINT_PKGS_FOLDER = 'Packages'.freeze
|
69
66
|
|
@@ -48,8 +48,6 @@ module JSS
|
|
48
48
|
# It's also used in various error messages
|
49
49
|
RSRC_OBJECT_KEY = :patch_external_source
|
50
50
|
|
51
|
-
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
52
|
-
VALID_DATA_KEYS = %i[enabled ssl_enabled host_name].freeze
|
53
51
|
|
54
52
|
# Instance Methods
|
55
53
|
#####################################
|
@@ -47,9 +47,6 @@ module JSS
|
|
47
47
|
# It's also used in various error messages
|
48
48
|
RSRC_OBJECT_KEY = :patch_internal_source
|
49
49
|
|
50
|
-
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
51
|
-
VALID_DATA_KEYS = %i[enabled endpoint].freeze
|
52
|
-
|
53
50
|
end # class PatchInternalSource
|
54
51
|
|
55
52
|
end # module JSS
|
@@ -132,8 +132,7 @@ module JSS
|
|
132
132
|
# It's also used in various error messages
|
133
133
|
RSRC_OBJECT_KEY = :patch_software_title
|
134
134
|
|
135
|
-
|
136
|
-
VALID_DATA_KEYS = %i[notifications name_id source_id].freeze
|
135
|
+
NON_UNIQUE_NAMES = true
|
137
136
|
|
138
137
|
# the object type for this object in
|
139
138
|
# the object history table.
|
@@ -74,9 +74,6 @@ module JSS
|
|
74
74
|
### It's also used in various error messages
|
75
75
|
RSRC_OBJECT_KEY = :peripheral
|
76
76
|
|
77
|
-
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
78
|
-
VALID_DATA_KEYS = [:type, :bar_code_1, :computer_id ]
|
79
|
-
|
80
77
|
# the object type for this object in
|
81
78
|
# the object history table.
|
82
79
|
# See {APIObject#add_object_history_entry}
|
@@ -69,8 +69,6 @@ module JSS
|
|
69
69
|
### It's also used in various error messages
|
70
70
|
RSRC_OBJECT_KEY = :peripheral_type
|
71
71
|
|
72
|
-
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
73
|
-
VALID_DATA_KEYS = [:fields]
|
74
72
|
|
75
73
|
### field types can be one of these, either String or Symbol
|
76
74
|
FIELD_TYPES = [:text, :menu]
|
@@ -92,8 +92,26 @@ module JSS
|
|
92
92
|
# It's also used in various error messages
|
93
93
|
RSRC_OBJECT_KEY = :policy
|
94
94
|
|
95
|
-
#
|
96
|
-
|
95
|
+
# subsets available for fetching
|
96
|
+
# TODO: FilesProcesses and Maintenance don't seem to work
|
97
|
+
SUBSETS = %i[
|
98
|
+
general
|
99
|
+
scope
|
100
|
+
selfservice
|
101
|
+
self_service
|
102
|
+
packages
|
103
|
+
scripts
|
104
|
+
printers
|
105
|
+
dockitems
|
106
|
+
dock_items
|
107
|
+
reboot
|
108
|
+
userinteraction
|
109
|
+
user_interaction
|
110
|
+
disk_encryption
|
111
|
+
diskencryption
|
112
|
+
accountmaintenance
|
113
|
+
account_maintenance
|
114
|
+
].freeze
|
97
115
|
|
98
116
|
# policies can take uploaded icons
|
99
117
|
UPLOAD_TYPES = { icon: :policies }.freeze
|
@@ -72,9 +72,6 @@ module JSS
|
|
72
72
|
### It's also used in various error messages
|
73
73
|
RSRC_OBJECT_KEY = :removable_mac_address
|
74
74
|
|
75
|
-
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
76
|
-
VALID_DATA_KEYS = []
|
77
|
-
|
78
75
|
# the object type for this object in
|
79
76
|
# the object history table.
|
80
77
|
# See {APIObject#add_object_history_entry}
|
@@ -50,9 +50,6 @@ module JSS
|
|
50
50
|
# It's also used in various error messages
|
51
51
|
RSRC_OBJECT_KEY = :restricted_software
|
52
52
|
|
53
|
-
# these keys, as well as :id and :name, are present in valid API JSON data for this class
|
54
|
-
VALID_DATA_KEYS = [:scope].freeze
|
55
|
-
|
56
53
|
# Our scopes deal with computers
|
57
54
|
SCOPE_TARGET_KEY = :computers
|
58
55
|
|
@@ -54,27 +54,19 @@ module JSS
|
|
54
54
|
###
|
55
55
|
module Scopable
|
56
56
|
|
57
|
-
#####################################
|
58
57
|
### Constants
|
59
58
|
#####################################
|
60
59
|
|
61
60
|
SCOPABLE = true
|
62
61
|
|
63
|
-
#####################################
|
64
|
-
### Variables
|
65
|
-
#####################################
|
66
|
-
|
67
|
-
#####################################
|
68
62
|
### Attribtues
|
69
63
|
#####################################
|
70
64
|
|
71
65
|
attr_reader :scope
|
72
66
|
|
73
|
-
#####################################
|
74
67
|
### Mixed-in Instance Methods
|
75
68
|
#####################################
|
76
69
|
|
77
|
-
###
|
78
70
|
### @api private
|
79
71
|
###
|
80
72
|
### Call this during initialization of objects that have a scope
|
@@ -87,8 +79,6 @@ module JSS
|
|
87
79
|
@scope.container = self
|
88
80
|
end
|
89
81
|
|
90
|
-
|
91
|
-
###
|
92
82
|
### Change the scope
|
93
83
|
###
|
94
84
|
### @param new_scope[JSS::Scopable::Scope] the new scope
|
@@ -102,7 +92,6 @@ module JSS
|
|
102
92
|
@need_to_update = true
|
103
93
|
end
|
104
94
|
|
105
|
-
###
|
106
95
|
### When the scope changes, it calls this to tell us that an update is needed.
|
107
96
|
###
|
108
97
|
### @return [void]
|
@@ -112,7 +101,6 @@ module JSS
|
|
112
101
|
end
|
113
102
|
|
114
103
|
|
115
|
-
###
|
116
104
|
### A wrapper around the update method, to try catching RestClient::Conflict
|
117
105
|
### 409 errors when we couldn't verify all ldap users/groups due to lack of ldap connections
|
118
106
|
###
|
@@ -178,7 +178,7 @@ module JSS
|
|
178
178
|
# @param raw_scope[Hash] the JSON :scope data from an API query that is scopable, e.g. a Policy.
|
179
179
|
#
|
180
180
|
def initialize(target_key, raw_scope = nil)
|
181
|
-
raw_scope ||= DEFAULT_SCOPE
|
181
|
+
raw_scope ||= DEFAULT_SCOPE.dup
|
182
182
|
raise JSS::InvalidDataError, "The target class of a Scope must be one of the symbols :#{TARGETS_AND_GROUPS.keys.join(', :')}" unless TARGETS_AND_GROUPS.key?(target_key)
|
183
183
|
|
184
184
|
@target_key = target_key
|
@@ -79,9 +79,6 @@ module JSS
|
|
79
79
|
### It's also used in various error messages
|
80
80
|
RSRC_OBJECT_KEY = :script
|
81
81
|
|
82
|
-
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
83
|
-
VALID_DATA_KEYS = [:parameters, :filename, :os_requirements].freeze
|
84
|
-
|
85
82
|
### The script storage folder on the distribution point, if used
|
86
83
|
DIST_POINT_SCRIPTS_FOLDER = 'Scripts'.freeze
|
87
84
|
|
@@ -357,13 +357,15 @@ module JSS
|
|
357
357
|
#
|
358
358
|
# @return [void]
|
359
359
|
#
|
360
|
-
def
|
360
|
+
def self_service_display_name=(new_val)
|
361
361
|
new_val.strip!
|
362
362
|
return nil if @self_service_dislay_name == new_val
|
363
363
|
raise JSS::InvalidDataError, 'Only macOS Self Service items have display names' unless self_service_targets.include? :macos
|
364
364
|
@self_service_dislay_name = new_val
|
365
365
|
@need_to_update = true
|
366
366
|
end
|
367
|
+
# alias for backward compatibility with the typo
|
368
|
+
alias self_service_dislay_name self_service_display_name
|
367
369
|
|
368
370
|
# @param new_val[String] the new install button text
|
369
371
|
#
|
data/lib/jss/api_object/site.rb
CHANGED
@@ -55,9 +55,6 @@ module JSS
|
|
55
55
|
# It's also used in various error messages
|
56
56
|
RSRC_OBJECT_KEY = :site
|
57
57
|
|
58
|
-
# these keys, as well as :id and :name, are present in valid API JSON data for this class
|
59
|
-
VALID_DATA_KEYS = [].freeze
|
60
|
-
|
61
58
|
# the object type for this object in
|
62
59
|
# the object history table.
|
63
60
|
# See {APIObject#add_object_history_entry}
|
@@ -69,9 +69,6 @@ module JSS
|
|
69
69
|
### It's also used in various error messages
|
70
70
|
RSRC_OBJECT_KEY = :software_update_server
|
71
71
|
|
72
|
-
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
73
|
-
VALID_DATA_KEYS = [:set_system_wide, :port]
|
74
|
-
|
75
72
|
# the object type for this object in
|
76
73
|
# the object history table.
|
77
74
|
# See {APIObject#add_object_history_entry}
|
data/lib/jss/api_object/user.rb
CHANGED
@@ -70,9 +70,6 @@ module JSS
|
|
70
70
|
### It's also used in various error messages
|
71
71
|
RSRC_OBJECT_KEY = :user
|
72
72
|
|
73
|
-
### these keys, as well as :id and :name, are present in valid API JSON data for this class
|
74
|
-
VALID_DATA_KEYS = [:position, :full_name, :email]
|
75
|
-
|
76
73
|
### This class lets us seach for users
|
77
74
|
SEARCH_CLASS = JSS::AdvancedUserSearch
|
78
75
|
|
@@ -54,9 +54,6 @@ module JSS
|
|
54
54
|
# It's also used in various error messages
|
55
55
|
RSRC_OBJECT_KEY = :webhook
|
56
56
|
|
57
|
-
# these keys, as well as :id and :name, are present in valid API JSON data for this class
|
58
|
-
VALID_DATA_KEYS = [:event, :contact_type, :url, :enabled].freeze
|
59
|
-
|
60
57
|
# the content types available for webhooks, internally we use Symbols,
|
61
58
|
# but the API wants the proper MIME strings
|
62
59
|
CONTENT_TYPES = {
|
data/lib/jss/compatibility.rb
CHANGED
@@ -1,67 +1,88 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
### in the hash
|
37
|
-
###
|
1
|
+
# Copyright 2019 Pixar
|
2
|
+
|
3
|
+
#
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
|
+
# with the following modification; you may not use this file except in
|
6
|
+
# compliance with the Apache License and the following modification to it:
|
7
|
+
# Section 6. Trademarks. is deleted and replaced with:
|
8
|
+
#
|
9
|
+
# 6. Trademarks. This License does not grant permission to use the trade
|
10
|
+
# names, trademarks, service marks, or product names of the Licensor
|
11
|
+
# and its affiliates, except as required to comply with Section 4(c) of
|
12
|
+
# the License and to reproduce the content of the NOTICE file.
|
13
|
+
#
|
14
|
+
# You may obtain a copy of the Apache License at
|
15
|
+
#
|
16
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
17
|
+
#
|
18
|
+
# Unless required by applicable law or agreed to in writing, software
|
19
|
+
# distributed under the Apache License with the above modification is
|
20
|
+
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
|
+
# KIND, either express or implied. See the Apache License for the specific
|
22
|
+
# language governing permissions and limitations under the Apache License.
|
23
|
+
#
|
24
|
+
#
|
25
|
+
|
26
|
+
# backporting of some newer ruby methods into older rubies
|
27
|
+
#
|
28
|
+
|
29
|
+
# Hash.key
|
30
|
+
#
|
31
|
+
# #key exists in ruby 1.9+, in 1.8 its called #index
|
32
|
+
# it returns the hash key for a given value, if the value exists
|
33
|
+
# in the hash
|
34
|
+
#
|
35
|
+
###########################################
|
38
36
|
unless {}.respond_to? :key
|
39
37
|
class Hash
|
40
|
-
|
38
|
+
|
39
|
+
alias key index
|
40
|
+
|
41
41
|
end
|
42
42
|
end
|
43
43
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
44
|
+
# Array.sample
|
45
|
+
#
|
46
|
+
# #sample exists in ruby 1.9+, in 1.8 its called #choice
|
47
|
+
# it returns a randomly chosen element of the given array
|
48
|
+
# eg: [1, 2, 3].sample returns either 1, 2, or 3
|
49
|
+
#
|
50
|
+
###########################################
|
51
51
|
unless [].respond_to? :sample
|
52
52
|
class Array
|
53
|
-
|
53
|
+
|
54
|
+
alias sample choice
|
55
|
+
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
# String.force_encoding
|
60
|
+
#
|
61
|
+
#
|
62
|
+
###########################################
|
63
|
+
unless ''.respond_to? :force_encoding
|
64
|
+
class String
|
65
|
+
|
66
|
+
def force_encoding(_args = nil)
|
67
|
+
self
|
68
|
+
end
|
69
|
+
|
54
70
|
end
|
55
71
|
end
|
56
72
|
|
57
73
|
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
unless "".respond_to? :force_encoding
|
74
|
+
# String.casecmp?
|
75
|
+
#
|
76
|
+
#
|
77
|
+
###########################################
|
78
|
+
unless ''.respond_to? :casecmp?
|
64
79
|
class String
|
65
|
-
|
80
|
+
|
81
|
+
def casecmp?(other)
|
82
|
+
return nil unless other.is_a? String
|
83
|
+
|
84
|
+
casecmp(other).zero?
|
85
|
+
end
|
86
|
+
|
66
87
|
end
|
67
88
|
end
|
data/lib/jss/exceptions.rb
CHANGED
@@ -55,6 +55,11 @@ module JSS
|
|
55
55
|
###
|
56
56
|
class AlreadyExistsError < RuntimeError; end
|
57
57
|
|
58
|
+
### AmbiguousError - raise this error when a search
|
59
|
+
### term that should find one object finds more.
|
60
|
+
###
|
61
|
+
class AmbiguousError < RuntimeError; end
|
62
|
+
|
58
63
|
### FileServiceError - raise this error when
|
59
64
|
### there's a problem accessing file service on a
|
60
65
|
### distribution point.
|
@@ -20,54 +20,10 @@
|
|
20
20
|
# distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
21
21
|
# KIND, either express or implied. See the Apache License for the specific
|
22
22
|
# language governing permissions and limitations under the Apache License.
|
23
|
-
#
|
24
|
-
#
|
25
|
-
|
26
|
-
#
|
27
|
-
class String
|
28
|
-
|
29
|
-
# Convert the strings "true" and "false"
|
30
|
-
# (after stripping whitespace and downcasing)
|
31
|
-
# to TrueClass and FalseClass respectively
|
32
|
-
#
|
33
|
-
# Return nil if any other string.
|
34
|
-
#
|
35
|
-
# @return [Boolean,nil] the boolean value
|
36
|
-
#
|
37
|
-
def jss_to_bool
|
38
|
-
case strip.downcase
|
39
|
-
when 'true' then true
|
40
|
-
when 'false' then false
|
41
|
-
end # case
|
42
|
-
end # to bool
|
43
|
-
|
44
|
-
# Convert a string to a Time object
|
45
|
-
#
|
46
|
-
# returns nil if not parsable by JSS::parse_datetime
|
47
|
-
#
|
48
|
-
# @return [Time] the time represented by the string.
|
49
|
-
#
|
50
|
-
def jss_to_time
|
51
|
-
JSS.parse_time self
|
52
|
-
rescue
|
53
|
-
return nil
|
54
|
-
end
|
55
23
|
|
56
|
-
# Convert a String to a Pathname object
|
57
|
-
#
|
58
|
-
# @return [Pathname]
|
59
|
-
#
|
60
|
-
def jss_to_pathname
|
61
|
-
Pathname.new self
|
62
|
-
end
|
63
24
|
|
64
|
-
|
65
|
-
|
66
|
-
#
|
67
|
-
# @return [Boolean]
|
68
|
-
#
|
69
|
-
def jss_integer?
|
70
|
-
self =~ /\A[0-9]+\Z/ ? true : false
|
71
|
-
end
|
25
|
+
require 'jss/ruby_extensions/string/conversions.rb'
|
26
|
+
require 'jss/ruby_extensions/string/predicates.rb'
|
72
27
|
|
73
|
-
|
28
|
+
String.include JSSRubyExtensions::String::Predicates
|
29
|
+
String.include JSSRubyExtensions::String::Conversions
|