ruby-jss 1.4.1 → 1.6.0
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.
- 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
|
@@ -32,6 +32,9 @@ module Jamf
|
|
|
32
32
|
#
|
|
33
33
|
class AppStoreCountryCodes < Jamf::SingletonResource
|
|
34
34
|
|
|
35
|
+
# Mix-Ins
|
|
36
|
+
#####################################
|
|
37
|
+
|
|
35
38
|
extend Jamf::Immutable
|
|
36
39
|
|
|
37
40
|
# Constants
|
|
@@ -48,7 +51,8 @@ module Jamf
|
|
|
48
51
|
countryCodes: {
|
|
49
52
|
class: Jamf::Country,
|
|
50
53
|
multi: true,
|
|
51
|
-
read_only: true
|
|
54
|
+
read_only: true,
|
|
55
|
+
aliases: [:list]
|
|
52
56
|
}
|
|
53
57
|
|
|
54
58
|
}.freeze # end OBJECT_MODEL
|
|
@@ -58,6 +62,12 @@ module Jamf
|
|
|
58
62
|
# Class Methods
|
|
59
63
|
#####################################
|
|
60
64
|
|
|
65
|
+
# @return [Array<Jamf::Country>] all the Countries available
|
|
66
|
+
#
|
|
67
|
+
def self.list(refresh = false, cnx: Jamf.cnx)
|
|
68
|
+
fetch(refresh, cnx: cnx).countryCodes
|
|
69
|
+
end
|
|
70
|
+
|
|
61
71
|
# Class level wrapper for #names
|
|
62
72
|
def self.names(refresh = false, cnx: Jamf.cnx)
|
|
63
73
|
fetch(refresh, cnx: cnx).names
|
|
@@ -93,22 +103,22 @@ module Jamf
|
|
|
93
103
|
|
|
94
104
|
# @return [Array<String>] the available country names
|
|
95
105
|
def names
|
|
96
|
-
@names ||= countryCodes.map
|
|
106
|
+
@names ||= countryCodes.map(&:name)
|
|
97
107
|
end
|
|
98
108
|
|
|
99
109
|
# @return [Array<String>] the available country codes
|
|
100
110
|
def codes
|
|
101
|
-
@codes ||= countryCodes.map
|
|
111
|
+
@codes ||= countryCodes.map(&:code)
|
|
102
112
|
end
|
|
103
113
|
|
|
104
114
|
# @return [Hash] name => code
|
|
105
115
|
def codes_by_name
|
|
106
|
-
@codes_by_name ||= countryCodes.map{ |country| [country.name, country.code] }.to_h
|
|
116
|
+
@codes_by_name ||= countryCodes.map { |country| [country.name, country.code] }.to_h
|
|
107
117
|
end
|
|
108
118
|
|
|
109
119
|
# @return [Hash] code => name
|
|
110
120
|
def names_by_code
|
|
111
|
-
@names_by_code ||= countryCodes.map{ |country| [country.code, country.name] }.to_h
|
|
121
|
+
@names_by_code ||= countryCodes.map { |country| [country.code, country.name] }.to_h
|
|
112
122
|
end
|
|
113
123
|
|
|
114
124
|
# return a country code from its name, case-insensitive
|
|
@@ -0,0 +1,155 @@
|
|
|
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 list of known timezones
|
|
33
|
+
class Locales < Jamf::SingletonResource
|
|
34
|
+
|
|
35
|
+
# Mix-Ins
|
|
36
|
+
#####################################
|
|
37
|
+
|
|
38
|
+
extend Jamf::Immutable
|
|
39
|
+
|
|
40
|
+
# Constants
|
|
41
|
+
#####################################
|
|
42
|
+
|
|
43
|
+
RSRC_VERSION = 'v1'.freeze
|
|
44
|
+
|
|
45
|
+
RSRC_PATH = 'locales'.freeze
|
|
46
|
+
|
|
47
|
+
OBJECT_MODEL = {
|
|
48
|
+
|
|
49
|
+
# @!attribute checkInFrequency
|
|
50
|
+
# @return [integer]
|
|
51
|
+
locales: {
|
|
52
|
+
class: Jamf::Locale,
|
|
53
|
+
multi: true,
|
|
54
|
+
read_only: true,
|
|
55
|
+
aliases: [:list]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}.freeze # end OBJECT_MODEL
|
|
59
|
+
|
|
60
|
+
parse_object_model
|
|
61
|
+
|
|
62
|
+
# TEMP? until this endpoint is brought up to standards
|
|
63
|
+
# the data from the API is a raw Array, but it should be a
|
|
64
|
+
# Hash containing an array.
|
|
65
|
+
def initialize(data, cnx: Jamf.cnx)
|
|
66
|
+
data = { locales: data }
|
|
67
|
+
super data, cnx: cnx
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
# Class Methods
|
|
71
|
+
#####################################
|
|
72
|
+
|
|
73
|
+
# @return [Array<Jamf::Locale>] all the locales available
|
|
74
|
+
#
|
|
75
|
+
def self.list(refresh = false, cnx: Jamf.cnx)
|
|
76
|
+
fetch(refresh, cnx: cnx).locales
|
|
77
|
+
end
|
|
78
|
+
|
|
79
|
+
# Class level wrapper for #descriptions
|
|
80
|
+
def self.descriptions(refresh = false, cnx: Jamf.cnx)
|
|
81
|
+
fetch(refresh, cnx: cnx).descriptions
|
|
82
|
+
end
|
|
83
|
+
# how to alias a class method
|
|
84
|
+
singleton_class.send(:alias_method, :names, :descriptions)
|
|
85
|
+
|
|
86
|
+
# Class level wrapper for #identifiers
|
|
87
|
+
def self.identifiers(refresh = false, cnx: Jamf.cnx)
|
|
88
|
+
fetch(refresh, cnx: cnx).identifiers
|
|
89
|
+
end
|
|
90
|
+
singleton_class.send(:alias_method, :ids, :identifiers)
|
|
91
|
+
|
|
92
|
+
# Class level wrapper for #ids_by_desc
|
|
93
|
+
def self.ids_by_desc(refresh = false, cnx: Jamf.cnx)
|
|
94
|
+
fetch(refresh, cnx: cnx).ids_by_desc
|
|
95
|
+
end
|
|
96
|
+
|
|
97
|
+
# Class level wrapper for #descs_by_id
|
|
98
|
+
def self.descs_by_id(refresh = false, cnx: Jamf.cnx)
|
|
99
|
+
fetch(refresh, cnx: cnx).descs_by_id
|
|
100
|
+
end
|
|
101
|
+
|
|
102
|
+
# Class level wrapper for #id_for_desc
|
|
103
|
+
def self.id_for_desc(desc, refresh = false, cnx: Jamf.cnx)
|
|
104
|
+
fetch(refresh, cnx: cnx).id_for_desc desc
|
|
105
|
+
end
|
|
106
|
+
|
|
107
|
+
# Class level wrapper for #desc_for_id
|
|
108
|
+
def self.desc_for_id(id, refresh = false, cnx: Jamf.cnx)
|
|
109
|
+
fetch(refresh, cnx: cnx).desc_for_id id
|
|
110
|
+
end
|
|
111
|
+
|
|
112
|
+
# Instance Methods
|
|
113
|
+
#####################################
|
|
114
|
+
|
|
115
|
+
# @return [Array<String>] the available descriptions
|
|
116
|
+
def descriptions
|
|
117
|
+
@descriptions ||= locales.map(&:description)
|
|
118
|
+
end
|
|
119
|
+
alias names descriptions
|
|
120
|
+
|
|
121
|
+
# @return [Array<String>] the available identifiers
|
|
122
|
+
def identifiers
|
|
123
|
+
@identifiers ||= locales.map(&:identifier)
|
|
124
|
+
end
|
|
125
|
+
alias ids identifiers
|
|
126
|
+
|
|
127
|
+
# @return [Hash] name => code
|
|
128
|
+
def ids_by_desc
|
|
129
|
+
@ids_by_desc ||= locales.map { |l| [l.description, l.identifier] }.to_h
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
# @return [Hash] code => name
|
|
133
|
+
def descs_by_id
|
|
134
|
+
@descs_by_id ||= locales.map { |l| [l.identifier, l.description] }.to_h
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
# return an identifier from its description, case-insensitive
|
|
138
|
+
# @param desc[String] the description of a locale
|
|
139
|
+
# @return [String]
|
|
140
|
+
def id_for_desc(desc)
|
|
141
|
+
desc = descriptions.select { |n| n.casecmp? desc }.first
|
|
142
|
+
ids_by_desc[desc]
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# return a description from its identifier, case-insensitive
|
|
146
|
+
# @param name[String] the identifier of a local
|
|
147
|
+
# @return [String]
|
|
148
|
+
def desc_for_id(id)
|
|
149
|
+
id = identifiers.select { |n| n.casecmp? id }.first
|
|
150
|
+
descs_by_id[id]
|
|
151
|
+
end
|
|
152
|
+
|
|
153
|
+
end # class
|
|
154
|
+
|
|
155
|
+
end # module
|
|
@@ -0,0 +1,213 @@
|
|
|
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 list of known timezones
|
|
33
|
+
class TimeZones < Jamf::SingletonResource
|
|
34
|
+
|
|
35
|
+
# Mix-Ins
|
|
36
|
+
#####################################
|
|
37
|
+
|
|
38
|
+
extend Jamf::Immutable
|
|
39
|
+
|
|
40
|
+
# Constants
|
|
41
|
+
#####################################
|
|
42
|
+
|
|
43
|
+
RSRC_VERSION = 'v1'.freeze
|
|
44
|
+
|
|
45
|
+
RSRC_PATH = 'time-zones'.freeze
|
|
46
|
+
|
|
47
|
+
OBJECT_MODEL = {
|
|
48
|
+
|
|
49
|
+
# @!attribute checkInFrequency
|
|
50
|
+
# @return [integer]
|
|
51
|
+
timeZones: {
|
|
52
|
+
class: Jamf::TimeZone,
|
|
53
|
+
multi: true,
|
|
54
|
+
read_only: true,
|
|
55
|
+
aliases: [:list]
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
}.freeze # end OBJECT_MODEL
|
|
59
|
+
|
|
60
|
+
parse_object_model
|
|
61
|
+
|
|
62
|
+
# TEMP? until this endpoint is brought up to standards
|
|
63
|
+
# the data from the API is a raw Array, but it should be a
|
|
64
|
+
# Hash containing an array.
|
|
65
|
+
def initialize(data, cnx: Jamf.cnx)
|
|
66
|
+
data = { timeZones: data }
|
|
67
|
+
super data, cnx: cnx
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# Class Methods
|
|
73
|
+
#####################################
|
|
74
|
+
|
|
75
|
+
# @return [Array<Jamf::TimeZone>] all the zomes available
|
|
76
|
+
#
|
|
77
|
+
def self.list(refresh = false, cnx: Jamf.cnx)
|
|
78
|
+
fetch(refresh, cnx: cnx).timeZones
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Class level wrapper for #displayNames
|
|
82
|
+
def self.displayNames(refresh = false, cnx: Jamf.cnx)
|
|
83
|
+
fetch(refresh, cnx: cnx).displayNames
|
|
84
|
+
end
|
|
85
|
+
singleton_class.send(:alias_method, :names, :displayNames)
|
|
86
|
+
|
|
87
|
+
# Class level wrapper for #zoneIds
|
|
88
|
+
def self.zoneIds(refresh = false, cnx: Jamf.cnx)
|
|
89
|
+
fetch(refresh, cnx: cnx).zoneIds
|
|
90
|
+
end
|
|
91
|
+
singleton_class.send(:alias_method, :ids, :zoneIds)
|
|
92
|
+
|
|
93
|
+
# Class level wrapper for #regions
|
|
94
|
+
def self.regions(refresh = false, cnx: Jamf.cnx)
|
|
95
|
+
fetch(refresh, cnx: cnx).regions
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
# Class level wrapper for #ids_by_name
|
|
99
|
+
def self.ids_by_name(refresh = false, cnx: Jamf.cnx)
|
|
100
|
+
fetch(refresh, cnx: cnx).ids_by_name
|
|
101
|
+
end
|
|
102
|
+
|
|
103
|
+
# Class level wrapper for #names_by_id
|
|
104
|
+
def self.names_by_id(refresh = false, cnx: Jamf.cnx)
|
|
105
|
+
fetch(refresh, cnx: cnx).names_by_id
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
# Class level wrapper for #regions_by_id
|
|
109
|
+
def self.regions_by_id(refresh = false, cnx: Jamf.cnx)
|
|
110
|
+
fetch(refresh, cnx: cnx).regions_by_id
|
|
111
|
+
end
|
|
112
|
+
|
|
113
|
+
# Class level wrapper for #regions_by_name
|
|
114
|
+
def self.regions_by_name(refresh = false, cnx: Jamf.cnx)
|
|
115
|
+
fetch(refresh, cnx: cnx).regions_by_name
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
# Class level wrapper for #id_for_name
|
|
119
|
+
def self.id_for_name(name, refresh = false, cnx: Jamf.cnx)
|
|
120
|
+
fetch(refresh, cnx: cnx).id_for_name name
|
|
121
|
+
end
|
|
122
|
+
|
|
123
|
+
# Class level wrapper for #name_for_id
|
|
124
|
+
def self.name_for_id(id, refresh = false, cnx: Jamf.cnx)
|
|
125
|
+
fetch(refresh, cnx: cnx).name_for_id id
|
|
126
|
+
end
|
|
127
|
+
|
|
128
|
+
# Class level wrapper for #region_for_name
|
|
129
|
+
def self.region_for_name(name, refresh = false, cnx: Jamf.cnx)
|
|
130
|
+
fetch(refresh, cnx: cnx).region_for_name name
|
|
131
|
+
end
|
|
132
|
+
|
|
133
|
+
# Class level wrapper for #name_for_id
|
|
134
|
+
def self.region_for_id(id, refresh = false, cnx: Jamf.cnx)
|
|
135
|
+
fetch(refresh, cnx: cnx).region_for_id id
|
|
136
|
+
end
|
|
137
|
+
|
|
138
|
+
|
|
139
|
+
# Instance Methods
|
|
140
|
+
#####################################
|
|
141
|
+
|
|
142
|
+
# @return [Array<String>] the available zone names
|
|
143
|
+
def displayNames
|
|
144
|
+
@names ||= timeZones.map(&:displayName)
|
|
145
|
+
end
|
|
146
|
+
alias names displayNames
|
|
147
|
+
|
|
148
|
+
# @return [Array<String>] the available zone ids
|
|
149
|
+
def zoneIds
|
|
150
|
+
@ids ||= timeZones.map(&:zoneId)
|
|
151
|
+
end
|
|
152
|
+
alias ids zoneIds
|
|
153
|
+
|
|
154
|
+
# @return [Array<String>] the available zone regions
|
|
155
|
+
def regions
|
|
156
|
+
@regions ||= timeZones.map(&:region).uniq
|
|
157
|
+
end
|
|
158
|
+
|
|
159
|
+
# @return [Hash] name => id
|
|
160
|
+
def ids_by_name
|
|
161
|
+
@ids_by_name ||= timeZones.map { |tz| [tz.displayName, tz.zoneId] }.to_h
|
|
162
|
+
end
|
|
163
|
+
|
|
164
|
+
# @return [Hash] id => name
|
|
165
|
+
def names_by_id
|
|
166
|
+
@names_by_id ||= timeZones.map { |tz| [tz.zoneId, tz.displayName] }.to_h
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
# @return [Hash] id => region
|
|
170
|
+
def regions_by_id
|
|
171
|
+
@regions_by_id ||= timeZones.map { |tz| [tz.zoneId, tz.region] }.to_h
|
|
172
|
+
end
|
|
173
|
+
|
|
174
|
+
# @return [Hash] name => region
|
|
175
|
+
def regions_by_name
|
|
176
|
+
@regions_by_name ||= timeZones.map { |tz| [tz.displayName, tz.region] }.to_h
|
|
177
|
+
end
|
|
178
|
+
|
|
179
|
+
# return a zone id from its name, case-insensitive
|
|
180
|
+
# @param name[String] the name of a zone
|
|
181
|
+
# @return [String]
|
|
182
|
+
def id_for_name(name)
|
|
183
|
+
name = names.select { |n| n.casecmp? name }.first
|
|
184
|
+
ids_by_name[name]
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# return a zone name from its id, case-insensitive
|
|
188
|
+
# @param name[String] the name of a zone
|
|
189
|
+
# @return [String]
|
|
190
|
+
def name_for_id(id)
|
|
191
|
+
id = ids.select { |n| n.casecmp? id }.first
|
|
192
|
+
names_by_id[id]
|
|
193
|
+
end
|
|
194
|
+
|
|
195
|
+
# return a zone name from its id, case-insensitive
|
|
196
|
+
# @param name[String] the name of a zone
|
|
197
|
+
# @return [String]
|
|
198
|
+
def region_for_name(name)
|
|
199
|
+
name = names.select { |n| n.casecmp? name }.first
|
|
200
|
+
regions_by_name[name]
|
|
201
|
+
end
|
|
202
|
+
|
|
203
|
+
# return a zones from its id, case-insensitive
|
|
204
|
+
# @param name[String] the name of a zone
|
|
205
|
+
# @return [String]
|
|
206
|
+
def region_for_id(id)
|
|
207
|
+
id = ids.select { |n| n.casecmp? id }.first
|
|
208
|
+
regions_by_id[id]
|
|
209
|
+
end
|
|
210
|
+
|
|
211
|
+
end # class
|
|
212
|
+
|
|
213
|
+
end # module
|
data/lib/jamf/client.rb
CHANGED
|
@@ -179,7 +179,7 @@ module Jamf
|
|
|
179
179
|
#
|
|
180
180
|
def self.jamf_plist
|
|
181
181
|
return {} unless JAMF_PLIST.file?
|
|
182
|
-
|
|
182
|
+
Jamf.parse_plist JAMF_PLIST
|
|
183
183
|
end
|
|
184
184
|
|
|
185
185
|
# All the JAMF receipts on this client
|
|
@@ -232,7 +232,7 @@ module Jamf
|
|
|
232
232
|
#
|
|
233
233
|
def self.hardware_data
|
|
234
234
|
raw = `/usr/sbin/system_profiler SPHardwareDataType -xml 2>/dev/null`
|
|
235
|
-
|
|
235
|
+
Jamf.parse_plist(raw)[0]['_items'][0]
|
|
236
236
|
end
|
|
237
237
|
|
|
238
238
|
# Who's currently got an active GUI session? - might be
|
|
@@ -284,7 +284,7 @@ module Jamf
|
|
|
284
284
|
myudid = udid
|
|
285
285
|
nc_prefs_file = Pathname.new "#{home}/#{USER_PREFS_BYHOST_FOLDER}/com.apple.notificationcenterui.#{myudid}.plist"
|
|
286
286
|
return nil unless nc_prefs_file.readable?
|
|
287
|
-
|
|
287
|
+
Jamf.parse_plist(nc_prefs_file)['doNotDisturb']
|
|
288
288
|
end
|
|
289
289
|
|
|
290
290
|
# The home dir of the specified user, nil if
|