ruby-jss 1.4.1 → 1.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGES.md +95 -0
- data/THANKS.md +3 -2
- data/lib/jamf.rb +18 -17
- data/lib/jamf/api/base_classes/collection_resource.rb +613 -0
- data/lib/jamf/api/{abstract_classes → base_classes}/json_object.rb +109 -101
- data/lib/jamf/api/{abstract_classes → base_classes}/prestage.rb +55 -30
- data/lib/jamf/api/{abstract_classes → base_classes}/resource.rb +10 -6
- data/lib/jamf/api/{abstract_classes → base_classes}/singleton_resource.rb +4 -3
- data/lib/jamf/api/connection.rb +13 -9
- data/lib/jamf/api/connection/api_error.rb +8 -8
- data/lib/jamf/api/connection/token.rb +16 -15
- data/lib/jamf/api/json_objects/device_enrollment_device.rb +14 -7
- data/lib/jamf/api/json_objects/{location.rb → device_enrollment_device_sync_state.rb} +27 -41
- data/lib/jamf/api/json_objects/device_enrollment_sync_status.rb +1 -1
- data/lib/jamf/api/json_objects/{attachment.rb → locale.rb} +14 -23
- data/lib/jamf/api/json_objects/md_prestage_name.rb +1 -1
- data/lib/jamf/api/json_objects/md_prestage_names.rb +2 -2
- data/lib/jamf/api/json_objects/md_prestage_skip_setup_items.rb +50 -1
- data/lib/jamf/api/json_objects/prestage_assignment.rb +2 -2
- data/lib/jamf/api/json_objects/prestage_location.rb +3 -3
- data/lib/jamf/api/json_objects/prestage_purchasing_data.rb +7 -7
- data/lib/jamf/api/json_objects/prestage_scope.rb +1 -1
- data/lib/jamf/api/{resources/collection_resources → json_objects}/time_zone.rb +9 -23
- data/lib/jamf/api/mixins/{abstract.rb → base_class.rb} +34 -16
- data/lib/jamf/api/mixins/bulk_deletable.rb +27 -6
- data/lib/jamf/api/mixins/change_log.rb +201 -51
- data/lib/jamf/api/{resources/collection_resources/computer.rb → mixins/filterable.rb} +19 -17
- data/lib/jamf/api/mixins/pageable.rb +208 -0
- data/lib/jamf/api/{json_objects/installed_application.rb → mixins/sortable.rb} +33 -33
- data/lib/jamf/api/resources/collection_resources/building.rb +16 -9
- data/lib/jamf/api/resources/collection_resources/category.rb +5 -4
- data/lib/jamf/api/resources/collection_resources/computer_prestage.rb +12 -5
- data/lib/jamf/api/resources/collection_resources/department.rb +0 -2
- data/lib/jamf/api/resources/collection_resources/device_enrollment.rb +10 -10
- data/lib/jamf/api/resources/collection_resources/inventory_preload_record.rb +11 -3
- data/lib/jamf/api/resources/collection_resources/mobile_device_prestage.rb +25 -23
- data/lib/jamf/api/resources/collection_resources/script.rb +61 -25
- data/lib/jamf/api/resources/singleton_resources/app_store_country_codes.rb +15 -5
- data/lib/jamf/api/resources/singleton_resources/locales.rb +155 -0
- data/lib/jamf/api/resources/singleton_resources/time_zones.rb +213 -0
- data/lib/jamf/client.rb +3 -3
- data/lib/jamf/client/management_action.rb +2 -3
- data/lib/jamf/composer.rb +2 -2
- data/lib/jamf/utility.rb +35 -7
- data/lib/jamf/validate.rb +63 -24
- data/lib/jamf/version.rb +1 -1
- data/lib/jss.rb +2 -2
- data/lib/jss/api_connection.rb +114 -406
- data/lib/jss/api_object.rb +3 -19
- data/lib/jss/api_object/categorizable.rb +1 -1
- data/lib/jss/api_object/computer.rb +13 -0
- data/lib/jss/api_object/configuration_profile.rb +61 -5
- data/lib/jss/api_object/directory_binding_type.rb +66 -60
- data/lib/jss/api_object/directory_binding_type/active_directory.rb +71 -34
- data/lib/jss/api_object/directory_binding_type/admitmac.rb +536 -467
- data/lib/jss/api_object/directory_binding_type/centrify.rb +21 -7
- data/lib/jss/api_object/directory_binding_type/open_directory.rb +4 -4
- data/lib/jss/api_object/distribution_point.rb +2 -2
- data/lib/jss/api_object/dock_item.rb +102 -96
- data/lib/jss/api_object/extendable.rb +1 -1
- data/lib/jss/api_object/group.rb +33 -2
- data/lib/jss/api_object/network_segment.rb +45 -13
- data/lib/jss/api_object/patch_source.rb +10 -9
- data/lib/jss/api_object/policy.rb +155 -25
- data/lib/jss/api_object/printer.rb +10 -4
- data/lib/jss/api_object/scopable.rb +10 -15
- data/lib/jss/api_object/scopable/scope.rb +31 -30
- data/lib/jss/api_object/script.rb +242 -352
- data/lib/jss/api_object/user.rb +1 -1
- data/lib/jss/client/management_action.rb +1 -2
- data/lib/jss/composer.rb +2 -2
- data/lib/jss/exceptions.rb +3 -0
- data/lib/jss/server.rb +15 -0
- data/lib/jss/utility.rb +213 -45
- data/lib/jss/version.rb +1 -1
- metadata +46 -64
- data/lib/jamf/api/abstract_classes/advanced_search.rb +0 -86
- data/lib/jamf/api/abstract_classes/collection_resource.rb +0 -433
- data/lib/jamf/api/abstract_classes/generic_reference.rb +0 -145
- data/lib/jamf/api/abstract_classes/prestage_skip_setup_items.rb +0 -126
- data/lib/jamf/api/json_objects/account_prefs.rb +0 -79
- data/lib/jamf/api/json_objects/android_details.rb +0 -139
- data/lib/jamf/api/json_objects/appletv_details.rb +0 -110
- data/lib/jamf/api/json_objects/cellular_network.rb +0 -151
- data/lib/jamf/api/json_objects/computer_prestage_skip_setup_items.rb +0 -67
- data/lib/jamf/api/json_objects/criterion.rb +0 -152
- data/lib/jamf/api/json_objects/extension_attribute_value.rb +0 -128
- data/lib/jamf/api/json_objects/installed_certificate.rb +0 -53
- data/lib/jamf/api/json_objects/installed_configuration_profile.rb +0 -67
- data/lib/jamf/api/json_objects/installed_ebook.rb +0 -58
- data/lib/jamf/api/json_objects/installed_provisioning_profile.rb +0 -59
- data/lib/jamf/api/json_objects/ios_details.rb +0 -244
- data/lib/jamf/api/json_objects/mobile_device_details.rb +0 -219
- data/lib/jamf/api/json_objects/mobile_device_security.rb +0 -101
- data/lib/jamf/api/json_objects/purchasing_data.rb +0 -125
- data/lib/jamf/api/mixins/locatable.rb +0 -124
- data/lib/jamf/api/mixins/referable.rb +0 -92
- data/lib/jamf/api/resources/collection_resources/account.rb +0 -163
- data/lib/jamf/api/resources/collection_resources/advanced_mobile_device_search.rb +0 -52
- data/lib/jamf/api/resources/collection_resources/advanced_user_search.rb +0 -52
- data/lib/jamf/api/resources/collection_resources/extension_attribute.rb +0 -45
- data/lib/jamf/api/resources/collection_resources/mobile_device.rb +0 -315
- data/lib/jamf/api/resources/collection_resources/site.rb +0 -77
- data/lib/jamf/api/resources/singleton_resources/authorization.rb +0 -88
- data/lib/jamf/api/resources/singleton_resources/client_checkin_settings.rb +0 -139
- data/lib/jamf/api/resources/singleton_resources/reenrollment_settings.rb +0 -95
@@ -1,92 +0,0 @@
|
|
1
|
-
# Copyright 2020 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
|
-
module Jamf
|
27
|
-
|
28
|
-
# CollectionResource Class instances with this module mixed-in can be
|
29
|
-
# referred to in other classes.
|
30
|
-
#
|
31
|
-
# Doing so dynamically defines a new 'Reference' class, which is a
|
32
|
-
# subclass of {Jamf::GenericReference}
|
33
|
-
#
|
34
|
-
# Examples:
|
35
|
-
#
|
36
|
-
# 1) A Policy can have a category assigned to it, and the policy's API data
|
37
|
-
# will contain a reference to a category.
|
38
|
-
#
|
39
|
-
# Jamf::Policy instances have a :category attribute, which contains an
|
40
|
-
# instance of Jamf::Category::Reference
|
41
|
-
#
|
42
|
-
# Mixing Referable into Jamf::Category automatically creates the class
|
43
|
-
# Jamf::Category::Reference
|
44
|
-
#
|
45
|
-
# 2) The API data for a Jamf::ComputerGroup contains a an Array of references
|
46
|
-
# to member Jamf::Computers. That Array arrives in JSON like this:
|
47
|
-
#
|
48
|
-
# computers: [
|
49
|
-
# { id: 234, name: 'foobar' },
|
50
|
-
# { id: 698, name: 'barfoo' }
|
51
|
-
# ]
|
52
|
-
#
|
53
|
-
# Mixing Referable into Jamf::Computer defines the class
|
54
|
-
# Jamf::Computer::Reference and allows Jamf::ComputerGroups to maintain an
|
55
|
-
# array of Jamf::Computer::Reference objects representing that list.
|
56
|
-
# When needed to send to the API, it will send this:
|
57
|
-
#
|
58
|
-
# computers: [
|
59
|
-
# { id: 234 },
|
60
|
-
# { id: 698 }
|
61
|
-
# ]
|
62
|
-
#
|
63
|
-
# Parsing the API data into Reference instances, and converting them back for
|
64
|
-
# the API is handled by the Reference class.
|
65
|
-
#
|
66
|
-
# TODO: Handle if any references contain keys other than :id and :name.
|
67
|
-
#
|
68
|
-
module Referable
|
69
|
-
|
70
|
-
# this will hopefully autoload generic_reference
|
71
|
-
GENREF = Jamf::GenericReference
|
72
|
-
|
73
|
-
# This is run when Referable is included in some class 'referent'
|
74
|
-
# It creates class referent::Reference as a subclass of
|
75
|
-
# GenericReference, and sets the REFERENT_CLASS constant of
|
76
|
-
# referent::Reference to referent.
|
77
|
-
#
|
78
|
-
def self.included(referent)
|
79
|
-
raise JSS::InvalidDataError, "'#{referent}' is not a subclass of Jamf::CollectionResource, can't include 'Referable'" unless referent.ancestors.include? Jamf::CollectionResource
|
80
|
-
referent.const_set :Reference, Class.new(GENREF)
|
81
|
-
referent::Reference.const_set :REFERENT_CLASS, referent
|
82
|
-
end
|
83
|
-
|
84
|
-
# @return [self.class::GenericReference] A reference to this object.
|
85
|
-
#
|
86
|
-
def reference
|
87
|
-
@reference ||= self.class::Reference.new self
|
88
|
-
end
|
89
|
-
|
90
|
-
end # module Referable
|
91
|
-
|
92
|
-
end # module
|
@@ -1,163 +0,0 @@
|
|
1
|
-
# Copyright 2020 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
|
-
# An administrator account in the JSS
|
33
|
-
#
|
34
|
-
# ISSUES FOR JAMF:
|
35
|
-
# - Seems like there needs to be some cleanup/coordination
|
36
|
-
# with the endpoints GET/auth, POST/auth/current, and GET/user
|
37
|
-
# Things are currently wonky enough that I can't really move forward
|
38
|
-
# with this class.
|
39
|
-
#
|
40
|
-
class Account < Jamf::JSONObject
|
41
|
-
|
42
|
-
# Constants
|
43
|
-
#####################################
|
44
|
-
|
45
|
-
ACCESS_LEVEL_FULL = 'FullAccess'.freeze
|
46
|
-
ACCESS_LEVEL_SITE = 'SiteAccess'.freeze,
|
47
|
-
ACCESS_LEVEL_GROUP = 'GroupBasedAccess'.freeze
|
48
|
-
|
49
|
-
ACCESS_LEVELS = [
|
50
|
-
ACCESS_LEVEL_FULL,
|
51
|
-
ACCESS_LEVEL_SITE,
|
52
|
-
ACCESS_LEVEL_GROUP
|
53
|
-
].freeze
|
54
|
-
|
55
|
-
PRIVILEGE_SET_ADMIN = 'ADMINISTRATOR'.freeze
|
56
|
-
PRIVILEGE_SET_AUDITOR = 'AUDITOR'.freeze
|
57
|
-
PRIVILEGE_SET_ENROLL = 'ENROLLMENT'.freeze
|
58
|
-
PRIVILEGE_SET_CUSTOM = 'CUSTOM'.freeze
|
59
|
-
|
60
|
-
PRIVILEGE_SETS = [
|
61
|
-
PRIVILEGE_SET_ADMIN,
|
62
|
-
PRIVILEGE_SET_AUDITOR,
|
63
|
-
PRIVILEGE_SET_ENROLL,
|
64
|
-
PRIVILEGE_SET_CUSTOM
|
65
|
-
].freeze
|
66
|
-
|
67
|
-
# Object Model / Attributes
|
68
|
-
# See APIObject class documentation for details
|
69
|
-
# of how the OBJECT_MODEL hash works.
|
70
|
-
#####################################
|
71
|
-
OBJECT_MODEL = {
|
72
|
-
# @!attribute [r] id
|
73
|
-
# @return [Integer]
|
74
|
-
id: {
|
75
|
-
class: :integer,
|
76
|
-
readonly: true
|
77
|
-
},
|
78
|
-
|
79
|
-
# @!attribute [r] username
|
80
|
-
# @return [String]
|
81
|
-
username: {
|
82
|
-
class: :string,
|
83
|
-
readonly: true
|
84
|
-
},
|
85
|
-
|
86
|
-
# @!attribute [r] realName
|
87
|
-
# @return [String]
|
88
|
-
realName: {
|
89
|
-
class: :string,
|
90
|
-
readonly: true
|
91
|
-
},
|
92
|
-
|
93
|
-
# @!attribute [r] email
|
94
|
-
# @return [String]
|
95
|
-
email: {
|
96
|
-
class: :string,
|
97
|
-
readonly: true
|
98
|
-
},
|
99
|
-
|
100
|
-
# @!attribute [r] preferences
|
101
|
-
# @return [String]
|
102
|
-
preferences: {
|
103
|
-
class: Jamf::AccountPreferences,
|
104
|
-
readonly: true
|
105
|
-
},
|
106
|
-
|
107
|
-
# @!attribute [r] isMultiSiteAdmin
|
108
|
-
# @return [Boolean]
|
109
|
-
isMultiSiteAdmin: {
|
110
|
-
class: :boolean,
|
111
|
-
readonly: true
|
112
|
-
},
|
113
|
-
|
114
|
-
# @!attribute [r] accessLevel
|
115
|
-
# @return [String]
|
116
|
-
accessLevel: {
|
117
|
-
class: :string,
|
118
|
-
readonly: true,
|
119
|
-
enum: Jamf::Account::ACCESS_LEVELS
|
120
|
-
},
|
121
|
-
|
122
|
-
# @!attribute [r] accessLevel
|
123
|
-
# @return [String]
|
124
|
-
privilegeSet: {
|
125
|
-
class: :string,
|
126
|
-
readonly: true,
|
127
|
-
enum: Jamf::Account::PRIVILEGE_SETS
|
128
|
-
},
|
129
|
-
|
130
|
-
}.freeze
|
131
|
-
parse_object_model
|
132
|
-
|
133
|
-
# CurrentAccount {
|
134
|
-
# id (integer, optional),
|
135
|
-
# username (string, optional),
|
136
|
-
# realName (string, optional),
|
137
|
-
# email (string, optional),
|
138
|
-
# preferences (AccountPreferences, optional),
|
139
|
-
# isMultiSiteAdmin (boolean, optional),
|
140
|
-
# accessLevel (string, optional) = ['FullAccess', 'SiteAccess', 'GroupBasedAccess'],
|
141
|
-
# privilegeSet (string, optional) = ['ADMINISTRATOR', 'AUDITOR', 'ENROLLMENT', 'CUSTOM'],
|
142
|
-
# privileges (Array[string], optional),
|
143
|
-
# groupIds (Array[integer], optional),
|
144
|
-
# currentSiteId (integer, optional)
|
145
|
-
# }
|
146
|
-
|
147
|
-
# Account/AuthAccount {
|
148
|
-
# id (integer, optional),
|
149
|
-
# username (string, optional),
|
150
|
-
# realName (string, optional),
|
151
|
-
# email (string, optional),
|
152
|
-
# preferences (AccountPreferences, optional),
|
153
|
-
# isMultiSiteAdmin (boolean, optional),
|
154
|
-
# accessLevel (string, optional) = ['FullAccess', 'SiteAccess', 'GroupBasedAccess'],
|
155
|
-
# privilegeSet (string, optional) = ['ADMINISTRATOR', 'AUDITOR', 'ENROLLMENT', 'CUSTOM'],
|
156
|
-
# privilegesBySite (object, optional),
|
157
|
-
# groupIds (Array[integer], optional),
|
158
|
-
# currentSiteId (integer, optional)
|
159
|
-
# }
|
160
|
-
|
161
|
-
end # class
|
162
|
-
|
163
|
-
end # module
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# Copyright 2020 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 Computer Prestage
|
33
|
-
class AdvancedMobileDeviceSearch < Jamf::AdvancedSearch
|
34
|
-
|
35
|
-
# Constants
|
36
|
-
#####################################
|
37
|
-
|
38
|
-
RSRC_VERSION = 'v1'.freeze
|
39
|
-
|
40
|
-
RSRC_PATH = 'advanced-mobile-device-searches'.freeze
|
41
|
-
|
42
|
-
# Object Model / Attributes
|
43
|
-
# See APIObject class documentation for details
|
44
|
-
# of how the OBJECT_MODEL hash works.
|
45
|
-
#####################################
|
46
|
-
OBJECT_MODEL = superclass::OBJECT_MODEL
|
47
|
-
|
48
|
-
parse_object_model
|
49
|
-
|
50
|
-
end # class
|
51
|
-
|
52
|
-
end # module
|
@@ -1,52 +0,0 @@
|
|
1
|
-
# Copyright 2020 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 Computer Prestage
|
33
|
-
class AdvancedUserSearch < Jamf::AdvancedSearch
|
34
|
-
|
35
|
-
# Constants
|
36
|
-
#####################################
|
37
|
-
|
38
|
-
RSRC_VERSION = 'v1'.freeze
|
39
|
-
|
40
|
-
RSRC_PATH = 'advanced-user-content-searches'.freeze
|
41
|
-
|
42
|
-
# Object Model / Attributes
|
43
|
-
# See APIObject class documentation for details
|
44
|
-
# of how the OBJECT_MODEL hash works.
|
45
|
-
#####################################
|
46
|
-
OBJECT_MODEL = superclass::OBJECT_MODEL
|
47
|
-
|
48
|
-
parse_object_model
|
49
|
-
|
50
|
-
end # class
|
51
|
-
|
52
|
-
end # module
|
@@ -1,45 +0,0 @@
|
|
1
|
-
# Copyright 2020 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
|
-
# An extension attribute in Jamf Pro
|
30
|
-
class ExtensionAttribute < Jamf::CollectionResource
|
31
|
-
|
32
|
-
VALUE_TYPES = {
|
33
|
-
string: 'STRING',
|
34
|
-
integer: 'INTEGER',
|
35
|
-
date: 'DATE'
|
36
|
-
}.freeze
|
37
|
-
|
38
|
-
OBJECT_MODEL = {
|
39
|
-
|
40
|
-
}.freeze
|
41
|
-
parse_object_model
|
42
|
-
|
43
|
-
end # class ext attr
|
44
|
-
|
45
|
-
end # module
|
@@ -1,315 +0,0 @@
|
|
1
|
-
# Copyright 2020 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 mobile device in the JSS
|
30
|
-
class MobileDevice < Jamf::CollectionResource
|
31
|
-
|
32
|
-
# Mix-Ins
|
33
|
-
#####################################
|
34
|
-
|
35
|
-
include Jamf::Referable
|
36
|
-
include Jamf::Locatable
|
37
|
-
include Jamf::Extendable
|
38
|
-
|
39
|
-
# currently not creatable via API
|
40
|
-
# TODO: remove this when it's time
|
41
|
-
extend Jamf::UnCreatable
|
42
|
-
|
43
|
-
# currently not creatable via API
|
44
|
-
# TODO: remove this when it's time
|
45
|
-
extend Jamf::UnDeletable
|
46
|
-
|
47
|
-
# Class Constants
|
48
|
-
#####################################
|
49
|
-
|
50
|
-
IOS = 'ios'.freeze
|
51
|
-
APPLETV = 'appleTv'.freeze
|
52
|
-
ANDROID = 'android'.freeze
|
53
|
-
UNKNOWN = 'unknown'.freeze
|
54
|
-
|
55
|
-
IPHONE = 'iPhone'.freeze
|
56
|
-
IPOD = 'iPod'.freeze
|
57
|
-
IPAD = 'iPad'.freeze
|
58
|
-
|
59
|
-
# The enum for the 'type' attribute
|
60
|
-
TYPES = [
|
61
|
-
IOS,
|
62
|
-
APPLETV,
|
63
|
-
ANDROID,
|
64
|
-
UNKNOWN
|
65
|
-
].freeze
|
66
|
-
|
67
|
-
APPLE_TYPES = [IOS, APPLETV].freeze
|
68
|
-
|
69
|
-
RSRC_PATH = '/inventory/obj/mobileDevice'.freeze
|
70
|
-
|
71
|
-
# This has a non-std update resource
|
72
|
-
# we POST to /inventory/obj/mobileDevice/{id}/update
|
73
|
-
# instad of the normal PUT to /inventory/obj/mobileDevice/{id}
|
74
|
-
UPDATE_RESOURCE = { method: :post, path_suffix: 'update' }.freeze
|
75
|
-
|
76
|
-
OBJECT_MODEL = {
|
77
|
-
|
78
|
-
# @!attribute [r] id
|
79
|
-
# @return [Integer]
|
80
|
-
id: {
|
81
|
-
class: :integer,
|
82
|
-
identifier: :primary,
|
83
|
-
readonly: true
|
84
|
-
},
|
85
|
-
|
86
|
-
# @!attribute name
|
87
|
-
# @param [String]
|
88
|
-
# @return [String]
|
89
|
-
name: {
|
90
|
-
class: :string
|
91
|
-
},
|
92
|
-
|
93
|
-
# @!attribute [r] serialNumber
|
94
|
-
# @return [String]
|
95
|
-
serialNumber: {
|
96
|
-
class: :string,
|
97
|
-
identifier: true,
|
98
|
-
readonly: true
|
99
|
-
},
|
100
|
-
|
101
|
-
# @!attribute [r] wifiMacAddress
|
102
|
-
# @return [String]
|
103
|
-
wifiMacAddress: {
|
104
|
-
class: :string,
|
105
|
-
identifier: true,
|
106
|
-
readonly: true
|
107
|
-
},
|
108
|
-
|
109
|
-
# @!attribute [r] udid
|
110
|
-
# @return [String]
|
111
|
-
udid: {
|
112
|
-
class: :string,
|
113
|
-
identifier: true,
|
114
|
-
readonly: true
|
115
|
-
},
|
116
|
-
|
117
|
-
# @!attribute [r] phoneNumber
|
118
|
-
# @return [String]
|
119
|
-
phoneNumber: {
|
120
|
-
class: :string,
|
121
|
-
identifier: true,
|
122
|
-
readonly: true
|
123
|
-
},
|
124
|
-
|
125
|
-
# @!attribute [r] model
|
126
|
-
# @return [String]
|
127
|
-
model: {
|
128
|
-
class: :string,
|
129
|
-
readonly: true
|
130
|
-
},
|
131
|
-
|
132
|
-
# @!attribute [r] modelIdentifier
|
133
|
-
# @return [String]
|
134
|
-
modelIdentifier: {
|
135
|
-
class: :string,
|
136
|
-
readonly: true
|
137
|
-
},
|
138
|
-
|
139
|
-
# @!attribute username
|
140
|
-
# Has custom setter, is part of Location in Details
|
141
|
-
# @param [String]
|
142
|
-
# @return [String]
|
143
|
-
username: {
|
144
|
-
class: :string,
|
145
|
-
readonly: true
|
146
|
-
},
|
147
|
-
|
148
|
-
# TODO: Will jamf give us isManaged or isSupervised?
|
149
|
-
# in the non-detail data?
|
150
|
-
# @!attribute [r] isManaged
|
151
|
-
# @return [Boolean]
|
152
|
-
# isManaged: {
|
153
|
-
# class: :boolean,
|
154
|
-
# readonly: true
|
155
|
-
# },
|
156
|
-
|
157
|
-
# @!attribute [r] type
|
158
|
-
# @return [Symbol]
|
159
|
-
type: {
|
160
|
-
class: :string,
|
161
|
-
readonly: true,
|
162
|
-
enum: Jamf::MobileDevice::TYPES
|
163
|
-
}
|
164
|
-
|
165
|
-
}.freeze
|
166
|
-
parse_object_model
|
167
|
-
|
168
|
-
# Class Methods
|
169
|
-
#####################################
|
170
|
-
|
171
|
-
# TODO: when jamf gives us isManaged in base object
|
172
|
-
# @return [Array<Hash>] the list of all managed mobile devices
|
173
|
-
# def self.all_unmanaged(refresh = false, api: JAMF.api)
|
174
|
-
# all(refresh, api: api).reject { |d| d[:managed] }
|
175
|
-
# end
|
176
|
-
|
177
|
-
# TODO: when jamf gives us isManaged in base object
|
178
|
-
# @return [Array<Hash>] the list of all unmanaged mobile devices
|
179
|
-
# def self.all_unmanaged(refresh = false, api: JAMF.api)
|
180
|
-
# all(refresh, api: api).reject { |d| d[:managed] }
|
181
|
-
# end
|
182
|
-
|
183
|
-
# TODO: when jamf gives us isSupervised in base object
|
184
|
-
# @return [Array<Hash>] the list of all supervised mobile devices
|
185
|
-
# def self.all_supervised(refresh = false, api: JAMF.api)
|
186
|
-
# all(refresh, api: api).select { |d| d[:supervised] }
|
187
|
-
# end
|
188
|
-
|
189
|
-
# TODO: when jamf gives us isSupervised in base object
|
190
|
-
# @return [Array<Hash>] the list of all unsupervised mobile devices
|
191
|
-
# def self.all_unsupervised(refresh = false, api: JAMF.api)
|
192
|
-
# all(refresh, api: api).reject { |d| d[:supervised] }
|
193
|
-
# end
|
194
|
-
|
195
|
-
# @return [Array<Hash>] the list of all iPhones
|
196
|
-
def self.all_iphones(refresh: false, cnx: Jamf.cnx)
|
197
|
-
all(refresh, cnx: cnx).select { |d| d[:model].start_with? IPHONE }
|
198
|
-
end
|
199
|
-
|
200
|
-
# @return [Array<Hash>] the list of all iPods
|
201
|
-
def self.all_ipods(refresh: false, cnx: Jamf.cnx)
|
202
|
-
all(refresh, cnx: cnx).select { |d| d[:model].start_with? IPOD }
|
203
|
-
end
|
204
|
-
|
205
|
-
# @return [Array<Hash>] the list of all iPads
|
206
|
-
def self.all_ipads(refresh: false, cnx: Jamf.cnx)
|
207
|
-
all(refresh, cnx: cnx).select { |d| d[:model].start_with? IPAD }
|
208
|
-
end
|
209
|
-
|
210
|
-
# @return [Array<Hash>] the list of all AppleTVs
|
211
|
-
def self.all_appleTvs(refresh: false, cnx: Jamf.cnx)
|
212
|
-
all(refresh, cnx: cnx).select { |d| d[:type] == APPLETV }
|
213
|
-
end
|
214
|
-
|
215
|
-
# @return [Array<Hash>] the list of all Androids
|
216
|
-
def self.all_androids(refresh: false, cnx: Jamf.cnx)
|
217
|
-
all(refresh, cnx: cnx).select { |d| d[:type] == ANDROID }
|
218
|
-
end
|
219
|
-
|
220
|
-
# Instance Methods
|
221
|
-
# Lots of overriding of standard methods in our metaclasses
|
222
|
-
# becuase we have a separate @details object, as well as
|
223
|
-
# a non-standard UPDATE_RESOURCE object model
|
224
|
-
# If this pattern becomes more common, and is uniform,
|
225
|
-
# (i.e. for computers) we'll make these methods into a module
|
226
|
-
#
|
227
|
-
#######################################
|
228
|
-
|
229
|
-
# This custom method outputs a 'UpdateMobileDevice' object model
|
230
|
-
# as defined in the API docs
|
231
|
-
#
|
232
|
-
def to_jamf
|
233
|
-
changes = unsaved_changes
|
234
|
-
data_to_send = {}
|
235
|
-
|
236
|
-
data_to_send[:name] = changes[:name][:new] if changes[:name]
|
237
|
-
|
238
|
-
data_to_send[:assetTag] = changes[:assetTag][:new] if changes[:assetTag]
|
239
|
-
data_to_send[:siteId] = changes[:site][:new].id if changes[:site]
|
240
|
-
data_to_send[:location] = details.location.to_jamf if changes[:location]
|
241
|
-
data_to_send[:updatedExtensionAttributes] = ext_attrs_to_jamf if ext_attrs_unsaved_changes?
|
242
|
-
|
243
|
-
return data_to_send unless APPLE_TYPES.include? @type
|
244
|
-
|
245
|
-
data_to_send[@type] = { purchasing: details.type_details.purchasing.to_jamf } if changes[:type_changes][:purchasing]
|
246
|
-
|
247
|
-
data_to_send[APPLETV][:airplayPassword] = changes[:type_changes][:airplayPassword][:new] if @type == APPLETV && changes[:type_changes][:airplayPassword]
|
248
|
-
|
249
|
-
data_to_send
|
250
|
-
end # to_jamf
|
251
|
-
|
252
|
-
# TODO - needed? Clean up?
|
253
|
-
# merge top-level and details changes and type-specific changes
|
254
|
-
def unsaved_changes
|
255
|
-
@unsaved_changes ||= {}
|
256
|
-
# name is the only thing at the top-level that isn't readonly
|
257
|
-
if @details
|
258
|
-
changes = details.unsaved_changes
|
259
|
-
changes[:name] = @unsaved_changes[:name] if @unsaved_changes[:name]
|
260
|
-
changes[:ext_attrs] = ext_attrs_unsaved_changes if ext_attrs_unsaved_changes?
|
261
|
-
type_changes = type_details.unsaved_changes
|
262
|
-
changes[:type_changes] = type_changes unless type_changes.empty?
|
263
|
-
else
|
264
|
-
changes = @unsaved_changes
|
265
|
-
end
|
266
|
-
changes
|
267
|
-
end
|
268
|
-
|
269
|
-
# clear changes for details as well as top
|
270
|
-
def clear_unsaved_changes
|
271
|
-
@details.clear_unsaved_changes if @details
|
272
|
-
ext_attrs_clear_unsaved_changes
|
273
|
-
@unsaved_changes = {}
|
274
|
-
end
|
275
|
-
|
276
|
-
# Fetch the details as needed
|
277
|
-
def details
|
278
|
-
@details ||= MobileDeviceDetails.fetch @id, @cnx
|
279
|
-
end # details
|
280
|
-
|
281
|
-
# Return the correct part of the details for the
|
282
|
-
# device type
|
283
|
-
def type_details
|
284
|
-
case @type
|
285
|
-
when :ios then details.ios
|
286
|
-
when :appleTv then details.appleTv
|
287
|
-
when :android then details.android
|
288
|
-
end
|
289
|
-
end
|
290
|
-
|
291
|
-
# catches the attributes in the details
|
292
|
-
def method_missing(meth, *args, &block)
|
293
|
-
if details.respond_to? meth
|
294
|
-
details.send meth, *args, &block
|
295
|
-
elsif type_details.respond_to? meth
|
296
|
-
type_details.send meth, *args, &block
|
297
|
-
else
|
298
|
-
super
|
299
|
-
end
|
300
|
-
end
|
301
|
-
|
302
|
-
# provides respond_to? for the attributes in the details
|
303
|
-
def respond_to_missing?(meth, *)
|
304
|
-
if details.respond_to? meth
|
305
|
-
true
|
306
|
-
elsif type_details.respond_to? meth
|
307
|
-
true
|
308
|
-
else
|
309
|
-
super
|
310
|
-
end
|
311
|
-
end
|
312
|
-
|
313
|
-
end # class Mobile Device
|
314
|
-
|
315
|
-
end # module
|