ruby-jss 0.8.2 → 0.9.0.b1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ruby-jss might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGES.md +37 -1
- data/README.md +15 -15
- data/bin/cgrouper +1 -1
- data/bin/netseg-update +1 -1
- data/lib/jss/api_connection.rb +307 -25
- data/lib/jss/api_object.rb +123 -54
- data/lib/jss/api_object/account.rb +6 -1
- data/lib/jss/api_object/advanced_search.rb +12 -12
- data/lib/jss/api_object/computer.rb +570 -141
- data/lib/jss/api_object/computer_invitation.rb +9 -0
- data/lib/jss/api_object/creatable.rb +1 -1
- data/lib/jss/api_object/distribution_point.rb +1 -1
- data/lib/jss/api_object/extension_attribute.rb +6 -6
- data/lib/jss/api_object/group.rb +1 -1
- data/lib/jss/api_object/matchable.rb +1 -1
- data/lib/jss/api_object/mobile_device.rb +690 -304
- data/lib/jss/api_object/mobile_device_application.rb +11 -1
- data/lib/jss/api_object/package.rb +1 -1
- data/lib/jss/api_object/policy.rb +206 -2
- data/lib/jss/api_object/restricted_software.rb +126 -42
- data/lib/jss/api_object/scopable/scope.rb +20 -21
- data/lib/jss/api_object/self_servable.rb +9 -6
- data/lib/jss/api_object/updatable.rb +1 -1
- data/lib/jss/api_object/uploadable.rb +1 -1
- data/lib/jss/server.rb +57 -56
- data/lib/jss/utility.rb +4 -0
- data/lib/jss/version.rb +1 -1
- metadata +4 -24
@@ -1,26 +1,26 @@
|
|
1
1
|
### Copyright 2017 Pixar
|
2
2
|
|
3
|
-
###
|
3
|
+
###
|
4
4
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
5
|
### with the following modification; you may not use this file except in
|
6
6
|
### compliance with the Apache License and the following modification to it:
|
7
7
|
### Section 6. Trademarks. is deleted and replaced with:
|
8
|
-
###
|
8
|
+
###
|
9
9
|
### 6. Trademarks. This License does not grant permission to use the trade
|
10
10
|
### names, trademarks, service marks, or product names of the Licensor
|
11
11
|
### and its affiliates, except as required to comply with Section 4(c) of
|
12
12
|
### the License and to reproduce the content of the NOTICE file.
|
13
|
-
###
|
13
|
+
###
|
14
14
|
### You may obtain a copy of the Apache License at
|
15
|
-
###
|
15
|
+
###
|
16
16
|
### http://www.apache.org/licenses/LICENSE-2.0
|
17
|
-
###
|
17
|
+
###
|
18
18
|
### Unless required by applicable law or agreed to in writing, software
|
19
19
|
### distributed under the Apache License with the above modification is
|
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
|
-
###
|
23
|
+
###
|
24
24
|
###
|
25
25
|
|
26
26
|
###
|
@@ -127,11 +127,11 @@ module JSS
|
|
127
127
|
###
|
128
128
|
### For telling it when a change is made and an update needed
|
129
129
|
attr_accessor :container
|
130
|
-
|
131
|
-
### @return [Boolean] should we expect a potential 409 Conflict
|
130
|
+
|
131
|
+
### @return [Boolean] should we expect a potential 409 Conflict
|
132
132
|
### if we can't connect to LDAP servers for verification?
|
133
133
|
attr_accessor :unable_to_verify_ldap_entries
|
134
|
-
|
134
|
+
|
135
135
|
### what type of target is this scope for? Computers or Mobiledevices?
|
136
136
|
attr_reader :target_class
|
137
137
|
|
@@ -157,7 +157,7 @@ module JSS
|
|
157
157
|
### targets in the JSS form the base scope.
|
158
158
|
###
|
159
159
|
attr_reader :all_targets
|
160
|
-
|
160
|
+
|
161
161
|
|
162
162
|
|
163
163
|
### @return [Hash<Array>]
|
@@ -199,8 +199,8 @@ module JSS
|
|
199
199
|
###
|
200
200
|
### @param api_scope[Hash] the JSON :scope data from an API query that is scopable, e.g. a Policy.
|
201
201
|
###
|
202
|
-
def initialize(target_key, api_scope =
|
203
|
-
|
202
|
+
def initialize(target_key, api_scope = nil)
|
203
|
+
api_scope ||= DEFAULT_SCOPE
|
204
204
|
raise JSS::InvalidDataError, "The target class of a Scope must be one of the symbols :#{TARGETS_AND_GROUPS.keys.join(', :')}" unless TARGETS_AND_GROUPS.keys.include? target_key
|
205
205
|
|
206
206
|
@target_key = target_key
|
@@ -575,13 +575,13 @@ module JSS
|
|
575
575
|
end
|
576
576
|
return scope
|
577
577
|
end #scope_xml
|
578
|
-
|
579
|
-
|
578
|
+
|
579
|
+
|
580
580
|
### Aliases
|
581
|
-
|
581
|
+
|
582
582
|
alias all_targets? all_targets
|
583
|
-
|
584
|
-
|
583
|
+
|
584
|
+
|
585
585
|
#####################################
|
586
586
|
### Private Instance Methods
|
587
587
|
#####################################
|
@@ -600,17 +600,17 @@ module JSS
|
|
600
600
|
return true if found_in_jss
|
601
601
|
|
602
602
|
return false unless CHECK_LDAP_KEYS.include?(key)
|
603
|
-
|
603
|
+
|
604
604
|
begin
|
605
605
|
return JSS::LDAPServer.user_in_ldap?(name) if LDAP_USER_KEYS.include?(key)
|
606
606
|
return JSS::LDAPServer.group_in_ldap?(name) if LDAP_GROUP_KEYS.include?(key)
|
607
|
-
|
607
|
+
|
608
608
|
# if an ldap server isn't connected, make a note of it and return true
|
609
609
|
rescue JSS::InvalidConnectionError
|
610
610
|
@unable_to_verify_ldap_entries = true
|
611
611
|
return true
|
612
612
|
end # begin
|
613
|
-
|
613
|
+
|
614
614
|
return false
|
615
615
|
end
|
616
616
|
|
@@ -619,4 +619,3 @@ module JSS
|
|
619
619
|
end # class Scope
|
620
620
|
end #module Scopable
|
621
621
|
end # module
|
622
|
-
|
@@ -458,6 +458,7 @@ module JSS
|
|
458
458
|
def in_self_service_at_init?
|
459
459
|
return nil unless @self_service_data_config[:in_self_service_data_path]
|
460
460
|
subsection, key = @self_service_data_config[:in_self_service_data_path]
|
461
|
+
return false unless @init_data[subsection]
|
461
462
|
@init_data[subsection][key] == @self_service_data_config[:in_self_service]
|
462
463
|
end
|
463
464
|
|
@@ -481,7 +482,7 @@ module JSS
|
|
481
482
|
#
|
482
483
|
def refresh_icon
|
483
484
|
return nil unless @in_jss
|
484
|
-
fresh_data = JSS
|
485
|
+
fresh_data = JSS.api_connection.get_rsrc(@rest_rsrc)[self.class::RSRC_OBJECT_KEY]
|
485
486
|
icon_data = fresh_data[:self_service][:self_service_icon]
|
486
487
|
@icon = JSS::Icon.new icon_data
|
487
488
|
end # refresh icon
|
@@ -506,11 +507,13 @@ module JSS
|
|
506
507
|
end
|
507
508
|
|
508
509
|
cats = ssvc.add_element('self_service_categories')
|
509
|
-
@self_service_categories
|
510
|
-
|
511
|
-
|
512
|
-
|
513
|
-
|
510
|
+
if @self_service_categories
|
511
|
+
@self_service_categories.each do |cat|
|
512
|
+
catelem = cats.add_element('category')
|
513
|
+
catelem.add_element('name').text = cat[:name]
|
514
|
+
catelem.add_element('display_in').text = cat[:display_in] if @self_service_data_config[:can_display_in_categories]
|
515
|
+
catelem.add_element('feature_in').text = cat[:feature_in] if @self_service_data_config[:can_feature_in_categories]
|
516
|
+
end
|
514
517
|
end
|
515
518
|
|
516
519
|
if self_service_targets.include? :macos
|
@@ -93,7 +93,7 @@ module JSS
|
|
93
93
|
return nil unless @need_to_update
|
94
94
|
raise JSS::UnsupportedError, "Editing #{self.class::RSRC_LIST_KEY} isn't yet supported. Please use other Casper workflows." unless UPDATABLE
|
95
95
|
raise JSS::NoSuchItemError, "Not In JSS! Use #create to create this #{self.class::RSRC_OBJECT_KEY} in the JSS before updating it." unless @in_jss
|
96
|
-
JSS
|
96
|
+
JSS.api_connection.put_rsrc @rest_rsrc, rest_xml
|
97
97
|
@need_to_update = false
|
98
98
|
refresh_icon if self_servable?
|
99
99
|
@id
|
data/lib/jss/server.rb
CHANGED
@@ -1,109 +1,110 @@
|
|
1
1
|
### Copyright 2017 Pixar
|
2
2
|
|
3
|
-
###
|
3
|
+
###
|
4
4
|
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
5
5
|
### with the following modification; you may not use this file except in
|
6
6
|
### compliance with the Apache License and the following modification to it:
|
7
7
|
### Section 6. Trademarks. is deleted and replaced with:
|
8
|
-
###
|
8
|
+
###
|
9
9
|
### 6. Trademarks. This License does not grant permission to use the trade
|
10
10
|
### names, trademarks, service marks, or product names of the Licensor
|
11
11
|
### and its affiliates, except as required to comply with Section 4(c) of
|
12
12
|
### the License and to reproduce the content of the NOTICE file.
|
13
|
-
###
|
13
|
+
###
|
14
14
|
### You may obtain a copy of the Apache License at
|
15
|
-
###
|
15
|
+
###
|
16
16
|
### http://www.apache.org/licenses/LICENSE-2.0
|
17
|
-
###
|
17
|
+
###
|
18
18
|
### Unless required by applicable law or agreed to in writing, software
|
19
19
|
### distributed under the Apache License with the above modification is
|
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
|
-
###
|
23
|
+
###
|
24
24
|
###
|
25
25
|
|
26
26
|
###
|
27
27
|
module JSS
|
28
28
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
29
|
+
# A class representing the currently-connected JSS Server.
|
30
|
+
#
|
31
|
+
# The {JSS::APIConnection} instance has a JSS::Server instance in its #server
|
32
|
+
# attribute. It is created fresh every time {APIConnection#connect} is called.
|
33
|
+
#
|
34
|
+
# That's the only time it should be instantiated, and all access should be
|
35
|
+
# through {JSS.api_connection.server}
|
36
|
+
#
|
37
37
|
class Server
|
38
38
|
|
39
|
+
# Constants
|
39
40
|
#####################################
|
40
|
-
|
41
|
-
|
41
|
+
ACTIVATION_CODE_RSRC = 'activationcode'.freeze
|
42
|
+
ACTIVATION_CODE_KEY = :activation_code
|
42
43
|
|
43
|
-
### @return [String] the organization to which the server is licensed
|
44
|
-
attr_reader :organization
|
45
|
-
|
46
44
|
|
47
|
-
|
48
|
-
|
45
|
+
# Attributes
|
46
|
+
#####################################
|
49
47
|
|
50
|
-
|
48
|
+
# @return [String] the type of server licence
|
51
49
|
attr_reader :license_type
|
52
50
|
|
53
|
-
|
51
|
+
# @return [String] the license product name
|
54
52
|
attr_reader :product
|
55
53
|
|
56
|
-
|
54
|
+
# @return [String] The version of the JSS. See the method JSS.parse_jss_version
|
57
55
|
attr_reader :version
|
58
56
|
|
59
|
-
|
57
|
+
# @return [Integer]
|
60
58
|
attr_reader :major_version
|
61
59
|
|
62
|
-
|
60
|
+
# @return [Integer]
|
63
61
|
attr_reader :minor_version
|
64
62
|
|
65
|
-
|
63
|
+
# @return [Integer]
|
66
64
|
attr_reader :revision_version
|
67
65
|
|
68
|
-
|
66
|
+
# @return [String]
|
69
67
|
attr_reader :raw_version
|
70
68
|
|
69
|
+
# Instance Methods
|
71
70
|
#####################################
|
72
|
-
### Instance Methods
|
73
|
-
#####################################
|
74
71
|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
72
|
+
# Initialize!
|
73
|
+
# THe jss_data to be passed in is the JSON output of the 'jssuser' resource
|
74
|
+
# on the API server.
|
75
|
+
# the jssuser resource is readable by anyone with a JSS acct
|
76
|
+
# regardless of their permissions.
|
77
|
+
# However, it's marked as 'deprecated'. Hopefully jamf will
|
78
|
+
# keep this basic level of info available for basic authentication
|
79
|
+
# and JSS version checking.
|
80
|
+
def initialize(jss_data)
|
81
|
+
|
82
|
+
@license_type = jss_data[:license_type]
|
83
|
+
@product = jss_data[:product]
|
84
|
+
@raw_version = jss_data[:version]
|
85
|
+
parsed = JSS.parse_jss_version(@raw_version)
|
86
|
+
@major_version = parsed[:major]
|
87
|
+
@minor_version = parsed[:minor]
|
88
|
+
@revision_version = parsed[:revision]
|
89
|
+
@version = parsed[:version]
|
90
|
+
end
|
91
|
+
|
92
|
+
# @return [String] the organization to which the server is licensed
|
93
|
+
def organization
|
94
|
+
@act_code_data ||= JSS.api_connection.get_rsrc(ACTIVATION_CODE_RSRC)[ACTIVATION_CODE_KEY]
|
95
|
+
@act_code_data[:organization_name]
|
96
|
+
end
|
99
97
|
|
98
|
+
# @return [String] the activation code for the server licence
|
99
|
+
def activation_code
|
100
|
+
@act_code_data ||= JSS.api_connection.get_rsrc(ACTIVATION_CODE_RSRC)[ACTIVATION_CODE_KEY]
|
101
|
+
@act_code_data[:code]
|
100
102
|
end
|
101
103
|
|
102
|
-
|
103
104
|
##### Aliases
|
104
105
|
alias institution organization
|
105
106
|
alias product_name product
|
106
|
-
|
107
|
+
|
107
108
|
end # class server
|
108
109
|
|
109
110
|
end # module
|
data/lib/jss/utility.rb
CHANGED
@@ -281,6 +281,7 @@ module JSS
|
|
281
281
|
|
282
282
|
# Given an element name and an array of content, generate an Array of
|
283
283
|
# REXML::Element objects with that name, and matching content.
|
284
|
+
# Given element name 'foo' and the array ['bar','morefoo']
|
284
285
|
# The array of REXML elements would render thus:
|
285
286
|
# <foo>bar</foo>
|
286
287
|
# <foo>morefoo</foo>
|
@@ -419,6 +420,9 @@ module JSS
|
|
419
420
|
def self.parse_jss_version_newstyle(version)
|
420
421
|
release, build = version.split '-'
|
421
422
|
major, minor, revision = release.split '.'
|
423
|
+
minor ||= 0
|
424
|
+
revision ||= 0
|
425
|
+
|
422
426
|
{
|
423
427
|
major: major.to_i,
|
424
428
|
minor: minor.to_i,
|
data/lib/jss/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-jss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.9.0.b1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lasell
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2017-
|
12
|
+
date: 2017-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: plist
|
@@ -79,26 +79,6 @@ dependencies:
|
|
79
79
|
- - "~>"
|
80
80
|
- !ruby/object:Gem::Version
|
81
81
|
version: '0.8'
|
82
|
-
- !ruby/object:Gem::Dependency
|
83
|
-
name: immutable-struct
|
84
|
-
requirement: !ruby/object:Gem::Requirement
|
85
|
-
requirements:
|
86
|
-
- - "~>"
|
87
|
-
- !ruby/object:Gem::Version
|
88
|
-
version: '2.2'
|
89
|
-
- - ">="
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version: 2.2.2
|
92
|
-
type: :runtime
|
93
|
-
prerelease: false
|
94
|
-
version_requirements: !ruby/object:Gem::Requirement
|
95
|
-
requirements:
|
96
|
-
- - "~>"
|
97
|
-
- !ruby/object:Gem::Version
|
98
|
-
version: '2.2'
|
99
|
-
- - ">="
|
100
|
-
- !ruby/object:Gem::Version
|
101
|
-
version: 2.2.2
|
102
82
|
description: |2
|
103
83
|
The ruby-jss gem provides the JSS module, a framework for interacting with the REST API
|
104
84
|
of the Jamf Software Server (JSS), the core of Jamf Pro, an enterprise/education
|
@@ -223,9 +203,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
223
203
|
version: 1.9.3
|
224
204
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
225
205
|
requirements:
|
226
|
-
- - "
|
206
|
+
- - ">"
|
227
207
|
- !ruby/object:Gem::Version
|
228
|
-
version:
|
208
|
+
version: 1.3.1
|
229
209
|
requirements: []
|
230
210
|
rubyforge_project:
|
231
211
|
rubygems_version: 2.6.8
|