ruby-jss 1.2.4a2 → 1.2.4a3

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.

Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/lib/jamf.rb +8 -1
  3. data/lib/jamf/api/abstract_classes/advanced_search.rb +86 -0
  4. data/lib/jamf/api/abstract_classes/collection_resource.rb +3 -8
  5. data/lib/jamf/api/abstract_classes/json_object.rb +11 -5
  6. data/lib/jamf/api/abstract_classes/prestage.rb +189 -6
  7. data/lib/jamf/api/abstract_classes/resource.rb +8 -3
  8. data/lib/jamf/api/connection.rb +19 -9
  9. data/lib/jamf/api/json_objects/criterion.rb +152 -0
  10. data/lib/jamf/api/json_objects/device_enrollment_device.rb +156 -0
  11. data/lib/jamf/api/json_objects/device_enrollment_sync_status.rb +71 -0
  12. data/lib/jamf/api/json_objects/inventory_preload_extension_attribute.rb +6 -1
  13. data/lib/jamf/api/json_objects/prestage_assignment.rb +15 -2
  14. data/lib/jamf/api/json_objects/prestage_scope.rb +5 -2
  15. data/lib/jamf/api/mixins/immutable.rb +1 -1
  16. data/lib/jamf/api/mixins/lockable.rb +9 -1
  17. data/lib/jamf/api/resources/collection_resources/advanced_mobile_device_search.rb +52 -0
  18. data/lib/jamf/api/resources/collection_resources/advanced_user_search.rb +52 -0
  19. data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +3 -1
  20. data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +292 -0
  21. data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +7 -7
  22. data/lib/jamf/api/resources/collection_resources/{md_prestage.rb → mobile_device_prestage.rb} +5 -3
  23. data/lib/jamf/exceptions.rb +5 -0
  24. data/lib/jamf/ruby_extensions/array/utils.rb +26 -12
  25. data/lib/jamf/version.rb +1 -1
  26. data/lib/jss/api_object/criteriable/criterion.rb +0 -1
  27. data/lib/jss/version.rb +1 -1
  28. metadata +10 -3
@@ -183,7 +183,12 @@ module Jamf
183
183
  def initialize(url = nil, **params)
184
184
  @name = params.delete :name
185
185
  @name ||= NOT_CONNECTED
186
- connect(url, params) unless params[:at_load]
186
+
187
+ @singleton_cache = {}
188
+ @collection_cache = {}
189
+ @ext_attr_cache = {}
190
+
191
+ connect(url, params) unless params[:do_not_connect]
187
192
  end
188
193
 
189
194
  # Public Instance Methods
@@ -512,17 +517,23 @@ module Jamf
512
517
 
513
518
  # Apply defaults from the Jamf.config,
514
519
  # then from the Jamf::Client,
515
- # then from the module defaults
516
- # to the params for the #connect method
520
+ # then from the Jamf module defaults
521
+ # to the unset params for the #connect method
517
522
  #
518
523
  # @param params[Hash] The params for #connect
519
524
  #
520
525
  # @return [Hash] The params with defaults applied
521
526
  #
522
527
  def apply_connection_defaults(params)
528
+ # if no port given, either directly or via URL, and the host
529
+ # is a jamfcloud host, always set the port to 443
530
+ # This should happen before the config is applied, so
531
+ # on-prem users can still get to jamfcoud without specifying the port
532
+ params[:port] = JAMFCLOUD_PORT if params[:port].nil? && params[:host].to_s.end_with?(JAMFCLOUD_DOMAIN)
533
+
523
534
  apply_defaults_from_config(params)
524
535
 
525
- # TODO: when clients are moved over
536
+ # TODO: when clients are moved over to Jamf module
526
537
  # apply_defaults_from_client(params)
527
538
 
528
539
  apply_module_defaults(params)
@@ -572,7 +583,8 @@ module Jamf
572
583
  # @return [Hash] The params with defaults applied
573
584
  #
574
585
  def apply_module_defaults(params)
575
- params[:port] ||= params[:host].to_s.end_with?(JAMFCLOUD_DOMAIN) ? JAMFCLOUD_PORT : ON_PREM_SSL_PORT
586
+ # if we have no port set by this point, assume on-prem
587
+ params[:port] ||= ON_PREM_SSL_PORT
576
588
  params[:timeout] ||= DFT_TIMEOUT
577
589
  params[:open_timeout] ||= DFT_OPEN_TIMEOUT
578
590
  params[:ssl_version] ||= DFT_SSL_VERSION
@@ -712,11 +724,12 @@ module Jamf
712
724
  end # class Connection
713
725
 
714
726
  # Jamf module methods dealing with the active connection
727
+ ########################################################
715
728
 
716
729
  # @return [Jamf::Connection] the active connection
717
730
  #
718
731
  def self.cnx
719
- @active_connection ||= Connection.new
732
+ @active_connection ||= Connection.new do_not_connect: true
720
733
  end
721
734
 
722
735
  # Create a new Connection object and use it as the active_connection,
@@ -750,7 +763,4 @@ module Jamf
750
763
  @active_connection = connection
751
764
  end
752
765
 
753
- # create the default connection
754
- connect(at_load: true) unless @active_connection
755
-
756
766
  end # module Jamf
@@ -0,0 +1,152 @@
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
+ # The module
27
+ module Jamf
28
+
29
+ # A 'location' for a computer prestage in Jamf Pro
30
+ class Criterion < Jamf::JSONObject
31
+
32
+ # the acceptable strings for and/or
33
+ AND = 'and'.freeze
34
+ OR = 'or'.freeze
35
+
36
+ AND_OR = [
37
+ AND,
38
+ OR
39
+ ].freeze
40
+
41
+ # These are the available search-types for building criteria
42
+ IS = 'is'.freeze
43
+ IS_NOT = 'is not'.freeze
44
+ LIKE = 'like'.freeze
45
+ NOT_LIKE = 'not like'.freeze
46
+ HAS = 'has'.freeze
47
+ HAS_NOT = 'does not have'.freeze
48
+ MORE_THAN = 'more than'.freeze
49
+ GREATER_THAN = 'greater than'.freeze
50
+ LESS_THAN = 'less than'.freeze
51
+ GREATER_OR_EQUAL = 'greater than or equal'.freeze
52
+ LESS_OR_EQUAL = 'less than or equal'.freeze
53
+ BEFORE_DATE = 'before (yyyy-mm-dd)'.freeze
54
+ AFTER_DATE = 'after (yyyy-mm-dd)'.freeze
55
+ MORE_THAN_DAYS_AGO = 'more than x days ago'.freeze
56
+ LESS_THAN_DAYS_AGO = 'less than x days ago'.freeze
57
+ IN_MORE_THAN_DAYS = 'in more than x days'.freeze
58
+ IN_LESS_THAN_DAYS = 'in less than x days'.freeze
59
+ MEMBER = 'member of'.freeze
60
+ NOT_MEMBER = 'not member of'.freeze
61
+ CURRENT = 'current'.freeze
62
+ NOT_CURRENT = 'not current'.freeze
63
+ REGEX = 'matches regex'.freeze
64
+ NOT_REGEX = 'does not match regex'.freeze
65
+
66
+ SEARCH_TYPES = [
67
+ IS,
68
+ IS_NOT,
69
+ LIKE,
70
+ NOT_LIKE,
71
+ HAS,
72
+ HAS_NOT,
73
+ MORE_THAN,
74
+ GREATER_THAN,
75
+ LESS_THAN,
76
+ GREATER_OR_EQUAL,
77
+ LESS_OR_EQUAL,
78
+ BEFORE_DATE,
79
+ AFTER_DATE,
80
+ MORE_THAN_DAYS_AGO,
81
+ LESS_THAN_DAYS_AGO,
82
+ IN_MORE_THAN_DAYS,
83
+ IN_LESS_THAN_DAYS,
84
+ MEMBER,
85
+ NOT_MEMBER,
86
+ CURRENT,
87
+ NOT_CURRENT,
88
+ REGEX,
89
+ NOT_REGEX
90
+ ].freeze
91
+
92
+ OBJECT_MODEL = {
93
+
94
+ # @!attribute name - the attribute name for this criterion
95
+ # @return [String]
96
+ name: {
97
+ class: :string,
98
+ required: true
99
+ },
100
+
101
+ # @!attribute priority - Not used? Seems to always be zero.
102
+ # Order is determined by array index, so not really sure,
103
+ # possibly a holdover from classic API/XML
104
+ # @return [Integer]
105
+ priority: {
106
+ class: :integer
107
+ },
108
+
109
+ # @!attribute andOr - How this criterion is joined to the previous:
110
+ # 'and' or 'or', defaults to 'and'.
111
+ # meaningless for the first criterion in an array
112
+ # @return [String]
113
+ andOr: {
114
+ class: :string,
115
+ enum: Jamf::Criterion::AND_OR
116
+ },
117
+
118
+ # @!attribute searchType - How to compare the attribute value to
119
+ # the search value
120
+ # @return [String]
121
+ searchType: {
122
+ class: :string,
123
+ enum: Jamf::Criterion::SEARCH_TYPES,
124
+ required: true
125
+ },
126
+
127
+ # @!attribute value - the value to compare to the attribute
128
+ # @return [String]
129
+ value: {
130
+ class: :string,
131
+ required: true
132
+ },
133
+
134
+ # @!attribute isOpeningParen - does this criterion start with an openParen?
135
+ # @return [Boolean]
136
+ isOpeningParen: {
137
+ class: :boolean
138
+ },
139
+
140
+ # @!attribute isClosingParen - does this criterion end with a closeParen?
141
+ # @return [Boolean]
142
+ isClosingParen: {
143
+ class: :boolean
144
+ }
145
+
146
+ }.freeze
147
+
148
+ parse_object_model
149
+
150
+ end # class location
151
+
152
+ end # module
@@ -0,0 +1,156 @@
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
+ # The Module
27
+ module Jamf
28
+
29
+ # Classes
30
+ #####################################
31
+
32
+ # A decvice enrollment defined in the JSS
33
+ # This is a connection to Apple's Device Enrollment Program.
34
+ # A single Jamf server may have many of them, and they can belong to
35
+ # different sites.
36
+ #
37
+ # These objects can be used to find the details of all the devices
38
+ # connected to them, including the device serial numbers.
39
+ # To see how or if those devices are assigned to prestages, see
40
+ # Jamf::Prestage and its subclasses ComputerPrestage and MobileDevicePrestage
41
+ #
42
+ class DeviceEnrollmentDevice < Jamf::JSONObject
43
+
44
+ # Mix-Ins
45
+ #####################################
46
+
47
+ extend Jamf::Immutable
48
+
49
+ # Constants
50
+ #####################################
51
+
52
+ PROFILE_STATUS_EMPTY = 'EMPTY'.freeze
53
+ PROFILE_STATUS_ASSIGNED = 'ASSIGNED'.freeze
54
+ PROFILE_STATUS_PUSHED = 'PUSHED'.freeze
55
+ PROFILE_STATUS_REMOVED = 'REMOVED'.freeze
56
+
57
+ PROFILE_STATUSES = [
58
+ PROFILE_STATUS_EMPTY,
59
+ PROFILE_STATUS_ASSIGNED,
60
+ PROFILE_STATUS_PUSHED,
61
+ PROFILE_STATUS_REMOVED
62
+ ].freeze
63
+
64
+ # Object Model / Attributes
65
+ # See APIObject class documentation for details
66
+ # of how the OBJECT_MODEL hash works.
67
+ #####################################
68
+ OBJECT_MODEL = {
69
+
70
+ # @!attribute id
71
+ # @return [Integer]
72
+ id: {
73
+ class: :integer,
74
+ identifier: true
75
+ },
76
+
77
+ # @!attribute deviceEnrollmentProgramInstanceId
78
+ # @return [Integer]
79
+ deviceEnrollmentProgramInstanceId: {
80
+ class: :integer
81
+ },
82
+
83
+ # @!attribute prestageId
84
+ # @return [Integer]
85
+ prestageId: {
86
+ class: :integer
87
+ },
88
+
89
+ # @!attribute serialNumber
90
+ # @return [String]
91
+ serialNumber: {
92
+ class: :string
93
+ },
94
+
95
+ # @!attribute description
96
+ # @return [String]
97
+ description: {
98
+ class: :string
99
+ },
100
+
101
+ # @!attribute model
102
+ # @return [String]
103
+ model: {
104
+ class: :string
105
+ },
106
+
107
+ # @!attribute color
108
+ # @return [String]
109
+ color: {
110
+ class: :string
111
+ },
112
+
113
+ # @!attribute assetTag
114
+ # @return [String]
115
+ assetTag: {
116
+ class: :string
117
+ },
118
+
119
+ # @!attribute profileStatus
120
+ # @return [String]
121
+ profileStatus: {
122
+ class: :string
123
+ },
124
+
125
+ # @!attribute profileAssignTime
126
+ # @return [Jamf::Timestamp]
127
+ profileAssignTime: {
128
+ class: Jamf::Timestamp
129
+ },
130
+
131
+ # @!attribute profilePushTime
132
+ # @return [Jamf::Timestamp]
133
+ profilePushTime: {
134
+ class: Jamf::Timestamp
135
+ },
136
+
137
+ # @!attribute deviceAssignedDate
138
+ # @return [Jamf::Timestamp]
139
+ deviceAssignedDate: {
140
+ class: Jamf::Timestamp
141
+ }
142
+ }.freeze
143
+
144
+ parse_object_model
145
+
146
+ # Class Methods
147
+ #########################################
148
+
149
+
150
+
151
+ # Instance Methods
152
+ #########################################
153
+
154
+ end # class
155
+
156
+ end # module
@@ -0,0 +1,71 @@
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
+ # The module
27
+ module Jamf
28
+
29
+ # A 'location' for a managed object in Jamf Pro
30
+ class DeviceEnrollmentSyncStatus < Jamf::JSONObject
31
+
32
+ extend Jamf::Immutable
33
+
34
+ OBJECT_MODEL = {
35
+
36
+ # @!attribute syncState
37
+ # @return [String]
38
+ syncState: {
39
+ class: :string
40
+ },
41
+
42
+ # @!attribute instanceId
43
+ # @return [Integer]
44
+ instanceId: {
45
+ class: :integer
46
+ },
47
+
48
+ # @!attribute timestamp
49
+ # @return [Jamf::Timestamp]
50
+ timestamp: {
51
+ class: Jamf::Timestamp
52
+ }
53
+ }.freeze
54
+
55
+ parse_object_model
56
+
57
+ # TEMPORARY timestamps are in UTC, but
58
+ # the iso8601 string isn't marked as such, so
59
+ # they are interpreted as localtime.
60
+ # i.e. the string comes as "2019-12-06T18:32:47.218"
61
+ # but is should be "2019-12-06T18:32:47.218Z"
62
+ #
63
+ # This resets them to the correct time
64
+ def initialize(*args)
65
+ super
66
+ @timestamp += @timestamp.utc_offset
67
+ end
68
+
69
+ end # class Country
70
+
71
+ end # module