ruby-jss 2.0.0b1 → 2.0.0rc1
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 +1 -0
- data/README-2.0.0.md +101 -64
- data/README.md +223 -173
- data/lib/jamf/api/classic/api_objects/distribution_point.rb +12 -50
- data/lib/jamf/api/classic/api_objects/mobile_device_application.rb +35 -6
- data/lib/jamf/api/classic/api_objects/patch_title.rb +14 -9
- data/lib/jamf/api/classic/base_classes/api_object.rb +69 -10
- data/lib/jamf/api/classic/base_classes/patch_source.rb +10 -5
- data/lib/jamf/api/connection/token.rb +1 -0
- data/lib/jamf/api/connection.rb +1 -5
- data/lib/jamf/api/jamf_pro/api_objects/inventory_preload_record.rb +0 -1
- data/lib/jamf/api/jamf_pro/mixins/collection_resource.rb +8 -12
- data/lib/jamf/api/jamf_pro/mixins/macos_managed_updates.rb +17 -7
- data/lib/jamf/deprecations/deprecated_api_connection_class.rb +29 -0
- data/lib/jamf/version.rb +1 -1
- data/lib/jamf/zeitwerk_config.rb +217 -0
- data/lib/jamf.rb +7 -39
- data/test/tests/policy.rb +1 -0
- metadata +20 -31
- data/lib/zeitwerk_config.rb +0 -163
@@ -24,6 +24,7 @@
|
|
24
24
|
#
|
25
25
|
|
26
26
|
module Jamf
|
27
|
+
|
27
28
|
# A Collection Resource in Jamf Pro
|
28
29
|
#
|
29
30
|
# See {Jamf::Resource} for general info about API resources.
|
@@ -60,6 +61,7 @@ module Jamf
|
|
60
61
|
# @abstract
|
61
62
|
######################################
|
62
63
|
module CollectionResource
|
64
|
+
|
63
65
|
include Jamf::JPAPIResource
|
64
66
|
|
65
67
|
# when this module is included, also extend our Class Methods
|
@@ -71,6 +73,7 @@ module Jamf
|
|
71
73
|
# Class Methods
|
72
74
|
#####################################
|
73
75
|
module ClassMethods
|
76
|
+
|
74
77
|
# 'include' all of these, so their methods become defined in this
|
75
78
|
# module, and will become Class Methods when this module
|
76
79
|
# is extended.
|
@@ -128,7 +131,6 @@ module Jamf
|
|
128
131
|
@patch_path ||= defined?(self::PATCH_PATH) ? self::PATCH_PATH : self::LIST_PATH
|
129
132
|
end
|
130
133
|
|
131
|
-
|
132
134
|
# The path for POSTing to create a single object in the collection.
|
133
135
|
#
|
134
136
|
# Classes including CollectionResource really need to define POST_PATH if it
|
@@ -256,7 +258,6 @@ module Jamf
|
|
256
258
|
#
|
257
259
|
######################################
|
258
260
|
def all(sort: nil, filter: nil, instantiate: false, cnx: Jamf.cnx, refresh: nil)
|
259
|
-
|
260
261
|
# if we are here, we need to query for all items, possibly filtered and
|
261
262
|
# sorted
|
262
263
|
sort = Jamf::Sortable.parse_url_sort_param(sort)
|
@@ -287,7 +288,6 @@ module Jamf
|
|
287
288
|
# arbitrary pages from the collection.
|
288
289
|
#
|
289
290
|
def pager(page_size: Jamf::Pager::DEFAULT_PAGE_SIZE, sort: nil, filter: nil, instantiate: false, cnx: Jamf.cnx)
|
290
|
-
|
291
291
|
sort = Jamf::Sortable.parse_url_sort_param(sort)
|
292
292
|
filter = filterable? ? Jamf::Filterable.parse_url_filter_param(filter) : nil
|
293
293
|
|
@@ -325,7 +325,6 @@ module Jamf
|
|
325
325
|
|
326
326
|
raise Jamf::NoSuchItemError, "No attribute :#{to} for class #{self}" unless self::OAPI_PROPERTIES.key? to
|
327
327
|
|
328
|
-
|
329
328
|
list = cached_list || all(cnx: cnx)
|
330
329
|
to_class = self::OAPI_PROPERTIES[to][:class]
|
331
330
|
to_multi = self::OAPI_PROPERTIES[to][:multi]
|
@@ -362,7 +361,7 @@ module Jamf
|
|
362
361
|
# raw_data some_value
|
363
362
|
#
|
364
363
|
# If some_value is an integer or a string containing an integer, it
|
365
|
-
# is assumed to be an :id otherwise all the available identifers
|
364
|
+
# is assumed to be an :id, otherwise all the available identifers
|
366
365
|
# are searched, in the order you see them when you call <class>.identifiers
|
367
366
|
#
|
368
367
|
# If no matching object is found, nil is returned.
|
@@ -382,8 +381,6 @@ module Jamf
|
|
382
381
|
#
|
383
382
|
######################################
|
384
383
|
def raw_data(searchterm = nil, ident: nil, value: nil, cnx: Jamf.cnx)
|
385
|
-
|
386
|
-
|
387
384
|
# given a value with no ident key
|
388
385
|
return raw_data_by_searchterm_only(searchterm, cnx: cnx) if searchterm
|
389
386
|
|
@@ -491,15 +488,13 @@ module Jamf
|
|
491
488
|
#
|
492
489
|
# @return [Boolean]
|
493
490
|
######################################
|
494
|
-
|
491
|
+
def creatable?
|
495
492
|
true
|
496
493
|
end
|
497
494
|
|
498
495
|
# Make a new thing to be added to the API
|
499
496
|
######################################
|
500
497
|
def create(**params)
|
501
|
-
|
502
|
-
|
503
498
|
# no such animal when .creating
|
504
499
|
params.delete :id
|
505
500
|
|
@@ -582,7 +577,7 @@ module Jamf
|
|
582
577
|
def delete(*ids, cnx: Jamf.cnx)
|
583
578
|
raise Jamf::UnsupportedError, "Deleting #{self} objects is not currently supported" unless deletable?
|
584
579
|
|
585
|
-
return bulk_delete(ids, cnx: Jamf.cnx) if
|
580
|
+
return bulk_delete(ids, cnx: Jamf.cnx) if bulk_deletable?
|
586
581
|
|
587
582
|
errs = []
|
588
583
|
ids.each do |id_to_delete|
|
@@ -650,7 +645,6 @@ module Jamf
|
|
650
645
|
raise NoMethodError, "no method '#{list_method_name}': '#{attr_name}' is not an indentifier for #{self}"
|
651
646
|
end
|
652
647
|
end
|
653
|
-
|
654
648
|
end # create_identifier_list_method
|
655
649
|
private :create_identifier_list_method
|
656
650
|
|
@@ -758,5 +752,7 @@ module Jamf
|
|
758
752
|
raise Jamf::MissingDataError, "Attribute '#{attr_name}' cannot be nil, must be a #{attr_def[:class]}"
|
759
753
|
end
|
760
754
|
end
|
755
|
+
|
761
756
|
end # class CollectionResource
|
757
|
+
|
762
758
|
end # module JAMF
|
@@ -49,6 +49,10 @@ module Jamf
|
|
49
49
|
# https://developer.jamf.com/jamf-pro/reference/post_v1-macos-managed-software-updates-send-updates
|
50
50
|
MANAGED_SW_UPDATES_SEND_UPDATES_RSRC = "#{MANAGED_SW_UPDATES_RSRC}/send-updates"
|
51
51
|
|
52
|
+
# These are the options available in Jamf::OAPISchemas::MacOsManagedSoftwareUpdate::UPDATE_ACTION_OPTIONS
|
53
|
+
DOWNLOAD_AND_INSTALL = 'DOWNLOAD_AND_INSTALL'
|
54
|
+
DOWNLOAD_ONLY = 'DOWNLOAD_ONLY'
|
55
|
+
|
52
56
|
# Class Methods
|
53
57
|
#####################################
|
54
58
|
module ClassMethods
|
@@ -67,11 +71,11 @@ module Jamf
|
|
67
71
|
Jamf::OAPISchemas::AvailableUpdates.new(data).availableUpdates
|
68
72
|
end
|
69
73
|
|
70
|
-
# Send the os update command to target
|
74
|
+
# Send the os update command to target Computers or a ComputerGroup
|
71
75
|
#
|
72
76
|
# @param updateAction [String] Required. 'DOWNLOAD_AND_INSTALL' or 'DOWNLOAD_ONLY'
|
73
77
|
#
|
74
|
-
# @param deviceIds [String, Integer, Array<String, Integer>]
|
78
|
+
# @param deviceIds [String, Integer, Array<String, Integer>] Identifiers for the
|
75
79
|
# computer targets. Required if no groupId is given.
|
76
80
|
#
|
77
81
|
# @param groupId [String, Integer] Identifier for the computer group target.
|
@@ -82,19 +86,20 @@ module Jamf
|
|
82
86
|
# Update will use the InstallLater install action. MaxDeferral is ignored if using the
|
83
87
|
# DOWNLOAD_ONLY updateAction.
|
84
88
|
#
|
85
|
-
# @param version [String] If no value is provided, the
|
86
|
-
# version based on device eligibility.
|
89
|
+
# @param version [String] The OS version to install. If no value is provided, the
|
90
|
+
# version will default to latest version based on device eligibility.
|
87
91
|
#
|
88
|
-
# @param skipVersionVerification [Boolean]
|
92
|
+
# @param skipVersionVerification [Boolean] Should the specified version be installed
|
93
|
+
# even it it isn't applicable to this machine? If no value is provided, will default to false.
|
89
94
|
# If true, the specified version will be forced to complete DownloadAndInstall
|
90
95
|
# install action.
|
91
96
|
#
|
92
|
-
# @param applyMajorUpdate [Boolean]
|
97
|
+
# @param applyMajorUpdate [Boolean] Available only when updating to the latest version
|
93
98
|
# based on device eligibility. Defaults to false. If false the calculated latest version
|
94
99
|
# will only include minor version updates. If a value is provided, the calculated latest
|
95
100
|
# version will include minor and major version updates.
|
96
101
|
#
|
97
|
-
# @param forceRestart [Boolean]
|
102
|
+
# @param forceRestart [Boolean] Will default to false. Can only be true if updateAction
|
98
103
|
# is DOWNLOAD_AND_INSTALLn and the devices the command is sent to are on macOs 11 or higher.
|
99
104
|
# If true, the DownloadAndInstall action is performed, a restart will be forced.
|
100
105
|
# MaxDeferral will be ignored if true.
|
@@ -146,6 +151,11 @@ module Jamf
|
|
146
151
|
# Instance Methods
|
147
152
|
######################################
|
148
153
|
|
154
|
+
# Send a managed update command to an instance of Computer or ComputerGroup.
|
155
|
+
# This just calls the class method of the same name.
|
156
|
+
#
|
157
|
+
# @see MacOSManagedUpdates.send_managed_os_update
|
158
|
+
#
|
149
159
|
def send_managed_os_update(updateAction:, maxDeferrals: nil, version: nil, skipVersionVerification: false, applyMajorUpdate: false, forceRestart: false, cnx: Jamf.cnx)
|
150
160
|
deviceIds = is_a?(Jamf::Computer) ? @id : nil
|
151
161
|
groupId = is_a?(Jamf::Computer) ? nil : @id
|
@@ -0,0 +1,29 @@
|
|
1
|
+
# Copyright 2022 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
|
+
# @deprecated Use class Jamf::Connection
|
25
|
+
module Jamf
|
26
|
+
|
27
|
+
APIConnection = Connection
|
28
|
+
|
29
|
+
end
|
data/lib/jamf/version.rb
CHANGED
@@ -0,0 +1,217 @@
|
|
1
|
+
# Copyright 2022 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
|
+
# Gems
|
25
|
+
######
|
26
|
+
|
27
|
+
require 'zeitwerk'
|
28
|
+
|
29
|
+
# Jamf's Zeitwerk Config and processes
|
30
|
+
module JamfZeitwerkConfig
|
31
|
+
|
32
|
+
# touch this file to make zeitwerk and mixins send text to stderr as things load
|
33
|
+
# or get mixed in
|
34
|
+
VERBOSE_LOADING_FILE = Pathname.new('/tmp/ruby-jss-verbose-loading')
|
35
|
+
|
36
|
+
# Or, set this ENV var to also make zeitverk and mixins send text to stderr
|
37
|
+
VERBOSE_LOADING_ENV = 'RUBY_JSS_VERBOSE_LOADING'
|
38
|
+
|
39
|
+
# touch this file to make zeitwek eager-load everything when the gem is required.
|
40
|
+
EAGER_LOAD_FILE = Pathname.new('/tmp/ruby-jss-zeitwerk-eager-load')
|
41
|
+
|
42
|
+
# Only look at the filesystem once.
|
43
|
+
def self.verbose_loading?
|
44
|
+
return @verbose_loading unless @verbose_loading.nil?
|
45
|
+
|
46
|
+
@verbose_loading = VERBOSE_LOADING_FILE.file?
|
47
|
+
@verbose_loading ||= ENV.include? VERBOSE_LOADING_ENV
|
48
|
+
@verbose_loading
|
49
|
+
end
|
50
|
+
|
51
|
+
# rubocop: disable Style/StderrPuts
|
52
|
+
def self.load_msg(msg)
|
53
|
+
$stderr.puts msg if verbose_loading?
|
54
|
+
end
|
55
|
+
# rubocop: enable Style/StderrPuts
|
56
|
+
|
57
|
+
# The loader object for Xolo
|
58
|
+
def self.loader
|
59
|
+
@loader
|
60
|
+
end
|
61
|
+
|
62
|
+
# Configure the Zeitwerk loader, See https://github.com/fxn/zeitwerk
|
63
|
+
def self.setup_zeitwerk_loader(zloader)
|
64
|
+
@loader = zloader
|
65
|
+
|
66
|
+
# Ignore this file (more ignores below)
|
67
|
+
loader.ignore __FILE__
|
68
|
+
|
69
|
+
##### Collaped Paths
|
70
|
+
|
71
|
+
# these paths all define classes & modules directly below 'Jamf'
|
72
|
+
# If we didn't collapse them, then e.g.
|
73
|
+
# /jamf/api/base_classes/classic/group.rb
|
74
|
+
# would be expected to define
|
75
|
+
# Jamf::Api::BaseClasses::Classic::Group
|
76
|
+
# rather than what we want:
|
77
|
+
# Jamf::Group
|
78
|
+
###################################################
|
79
|
+
|
80
|
+
loader.collapse("#{__dir__}/api")
|
81
|
+
|
82
|
+
loader.collapse("#{__dir__}/api/classic")
|
83
|
+
loader.collapse("#{__dir__}/api/classic/api_objects")
|
84
|
+
loader.collapse("#{__dir__}/api/classic/base_classes")
|
85
|
+
|
86
|
+
loader.collapse("#{__dir__}/api/jamf_pro")
|
87
|
+
loader.collapse("#{__dir__}/api/jamf_pro/api_objects")
|
88
|
+
loader.collapse("#{__dir__}/api/jamf_pro/mixins")
|
89
|
+
loader.collapse("#{__dir__}/api/jamf_pro/base_classes")
|
90
|
+
loader.collapse("#{__dir__}/api/jamf_pro/other_classes")
|
91
|
+
|
92
|
+
loader.collapse("#{__dir__}/deprecations")
|
93
|
+
|
94
|
+
##### Inflected Paths
|
95
|
+
|
96
|
+
# filenames => Constants, which don't adhere to zeitwerk's parsing standards.
|
97
|
+
#
|
98
|
+
# Mostly because the a filename like 'oapi_object' would be
|
99
|
+
# loaded by zeitwerk expecting it to define 'OapiObject', but it really
|
100
|
+
# defines 'OAPIObject'
|
101
|
+
###############################################
|
102
|
+
|
103
|
+
# Connections
|
104
|
+
loader.inflector.inflect 'classic_api' => 'ClassicAPI'
|
105
|
+
loader.inflector.inflect 'jamf_pro_api' => 'JamfProAPI'
|
106
|
+
loader.inflector.inflect 'jamf_pro_api_error' => 'JamfProAPIError'
|
107
|
+
|
108
|
+
# API objects, resources, and mixins
|
109
|
+
loader.inflector.inflect 'oapi_schemas' => 'OAPISchemas'
|
110
|
+
loader.inflector.inflect 'oapi_object' => 'OAPIObject'
|
111
|
+
loader.inflector.inflect 'oapi_validate' => 'OAPIValidate'
|
112
|
+
|
113
|
+
loader.inflector.inflect 'jpapi_resource' => 'JPAPIResource'
|
114
|
+
|
115
|
+
loader.inflector.inflect 'api_object' => 'APIObject'
|
116
|
+
loader.inflector.inflect 'xml_workaround' => 'XMLWorkaround'
|
117
|
+
loader.inflector.inflect 'json_object' => 'JSONObject'
|
118
|
+
loader.inflector.inflect 'vppable' => 'VPPable'
|
119
|
+
loader.inflector.inflect 'osx_configuration_profile' => 'OSXConfigurationProfile'
|
120
|
+
loader.inflector.inflect 'jp_extendable' => 'JPExtendable'
|
121
|
+
loader.inflector.inflect 'mdm' => 'MDM'
|
122
|
+
loader.inflector.inflect 'ibeacon' => 'IBeacon'
|
123
|
+
loader.inflector.inflect 'powerbroker_identity_services' => 'PowerBroker'
|
124
|
+
loader.inflector.inflect 'admitmac' => 'ADmitMac'
|
125
|
+
loader.inflector.inflect 'ip_address' => 'IPAddress'
|
126
|
+
loader.inflector.inflect 'netboot_server' => 'NetBootServer'
|
127
|
+
loader.inflector.inflect 'vpp_account' => 'VPPAccount'
|
128
|
+
loader.inflector.inflect 'removable_macaddr' => 'RemovableMacAddress'
|
129
|
+
loader.inflector.inflect 'md_prestage_name' => 'MobileDevicePrestageName'
|
130
|
+
loader.inflector.inflect 'md_prestage_names' => 'MobileDevicePrestageNames'
|
131
|
+
loader.inflector.inflect 'md_prestage_skip_setup_items' => 'MobileDevicePrestageSkipSetupItems'
|
132
|
+
loader.inflector.inflect 'macos_managed_updates' => 'MacOSManagedUpdates'
|
133
|
+
|
134
|
+
# deprecations, separated so they load only when used.
|
135
|
+
# When its time to get rid of them, delete the files from the
|
136
|
+
# 'deprecations' directory, and the matching line here.
|
137
|
+
loader.inflector.inflect('deprecated_api_constant' => 'API')
|
138
|
+
loader.inflector.inflect('deprecated_config_constant' => 'CONFIG')
|
139
|
+
loader.inflector.inflect('deprecated_api_connection_class' => 'APIConnection')
|
140
|
+
|
141
|
+
##### Ingored Paths
|
142
|
+
|
143
|
+
# These should be ignored, some will be required directly
|
144
|
+
#####################################
|
145
|
+
|
146
|
+
loader.ignore "#{__dir__}/db_connection.rb"
|
147
|
+
loader.ignore "#{__dir__}/ruby_extensions.rb"
|
148
|
+
loader.ignore "#{__dir__}/ruby_extensions"
|
149
|
+
loader.ignore "#{__dir__}/exceptions.rb"
|
150
|
+
|
151
|
+
lib_dir = Pathname.new(__dir__).parent.to_s
|
152
|
+
loader.ignore "#{lib_dir}/ruby-jss.rb"
|
153
|
+
loader.ignore "#{lib_dir}/jss.rb"
|
154
|
+
loader.ignore "#{lib_dir}/jss-api.rb"
|
155
|
+
|
156
|
+
##### Callbacks
|
157
|
+
|
158
|
+
# callback for when a specific file/constant loads
|
159
|
+
# duplicate and uncomment this if desired to react to
|
160
|
+
# specific things loading
|
161
|
+
#####################################
|
162
|
+
# loader.on_load('Jamf::SomeClass') do |klass, abspath|
|
163
|
+
# Jamf.load_msg "I just loaded #{klass} from #{abspath}"
|
164
|
+
# end
|
165
|
+
|
166
|
+
# callback for when anything loads
|
167
|
+
# - const_path is like "Jamf::SomeClass" or "Jamf::SomeClass::SOME_CONST_ARRY"
|
168
|
+
# - value is the value that constant contains after loading,
|
169
|
+
# e.g. the class Jamf::SomeClass for 'Jamf::SomeClass' or
|
170
|
+
# an Array for the constant "Jamf::SomeClass::SOME_CONST_ARRY"
|
171
|
+
# - abspath is the full path to the file where the constant was loaded from.
|
172
|
+
#####################################
|
173
|
+
loader.on_load do |const_path, value, abspath|
|
174
|
+
load_msg "Zeitwerk just loaded #{value.class} '#{const_path}' from:\n #{abspath}"
|
175
|
+
|
176
|
+
# Parse OAPI_PROPERTIES into getters and setters for subclasses of
|
177
|
+
# OAPIObject in the JPAPI.
|
178
|
+
#
|
179
|
+
# The class we just loaded must have this method and constant
|
180
|
+
# and the method must not have run already for the class or any superclass.
|
181
|
+
# This prevents running parse_oapi_properties again in subclasses that
|
182
|
+
# don't need to do that
|
183
|
+
if value.respond_to?(:oapi_properties_parsed?) && \
|
184
|
+
defined?(value::OAPI_PROPERTIES) && \
|
185
|
+
!value.oapi_properties_parsed?
|
186
|
+
|
187
|
+
parsed = value.parse_oapi_properties
|
188
|
+
load_msg "Parsed OAPI_PROPERTIES for #{value}" if parsed
|
189
|
+
end
|
190
|
+
|
191
|
+
# Generate the identifier list methods (.all_*) for subclasses of APIObject
|
192
|
+
# in the Classic API
|
193
|
+
if value.is_a?(Class) && value.superclass == Jamf::APIObject
|
194
|
+
|
195
|
+
done = value.define_identifier_list_methods
|
196
|
+
load_msg "Defined identifier list methods for #{value}" if done
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
loader.setup
|
201
|
+
end # setup_zeitwerk_loader
|
202
|
+
|
203
|
+
# For testing the Zeitwrk Loader.
|
204
|
+
# Normally we want autoloading on demand,
|
205
|
+
# eager loading loads everything so we can see it
|
206
|
+
#
|
207
|
+
# To make this happen touch the file defined in EAGER_LOAD_FILE
|
208
|
+
def self.eager_load_for_testing
|
209
|
+
return unless EAGER_LOAD_FILE.file?
|
210
|
+
|
211
|
+
loader.eager_load(force: true)
|
212
|
+
warn :loaded
|
213
|
+
# rescue Zeitwerk::NameError => e
|
214
|
+
# warn e.message
|
215
|
+
end
|
216
|
+
|
217
|
+
end # module JamfZeitwerkConfig
|
data/lib/jamf.rb
CHANGED
@@ -54,49 +54,20 @@ require 'jamf/exceptions'
|
|
54
54
|
require 'jamf/db_connection'
|
55
55
|
|
56
56
|
# Configure the Zeitwerk loader, See https://github.com/fxn/zeitwerk
|
57
|
-
require '
|
58
|
-
require 'zeitwerk_config'
|
59
|
-
|
60
|
-
# touch this file to make zeitwerk and mixins send text to stderr as things load
|
61
|
-
# or get mixed in
|
62
|
-
JAMF_VERBOSE_LOADING_FILE = Pathname.new('/tmp/ruby-jss-verbose-loading')
|
63
|
-
|
64
|
-
# Or, set this ENV var to also make zeitverk and mixins send text to stderr
|
65
|
-
JAMF_VERBOSE_LOADING_ENV = 'RUBY_JSS_VERBOSE_LOADING'.freeze
|
66
|
-
|
67
|
-
# touch this file to make zeitwek eager-load everything when the gem is required.
|
68
|
-
JAMF_ZEITWERK_EAGER_LOAD_FILE = Pathname.new('/tmp/ruby-jss-zeitwerk-eager-load')
|
57
|
+
require 'jamf/zeitwerk_config'
|
69
58
|
|
70
59
|
# the `Zeitwerk::Loader.for_gem` creates the loader object, and must
|
71
60
|
# happen in this file, so we pass it into a method defined in
|
72
61
|
# zeitwerk_config
|
73
|
-
setup_zeitwerk_loader Zeitwerk::Loader.for_gem
|
62
|
+
JamfZeitwerkConfig.setup_zeitwerk_loader Zeitwerk::Loader.for_gem
|
74
63
|
|
75
64
|
# Jamf, A Ruby module for interacting with the JAMF Pro Server via both of its REST APIs
|
76
65
|
module Jamf
|
77
66
|
|
78
|
-
|
79
|
-
return if Gem::Version.new(RUBY_VERSION) >= Gem::Version.new(MINIMUM_RUBY_VERSION)
|
80
|
-
|
81
|
-
raise "Can't use ruby-jss #{Jamf::VERSION}, ruby itself must be version #{MINIMUM_RUBY_VERSION} or greater, this is ruby #{RUBY_VERSION}."
|
82
|
-
end
|
83
|
-
|
84
|
-
# Only look at the filesystem once.
|
85
|
-
def self.verbose_loading?
|
86
|
-
return @verbose_loading unless @verbose_loading.nil?
|
87
|
-
|
88
|
-
@verbose_loading = JAMF_VERBOSE_LOADING_FILE.file?
|
89
|
-
@verbose_loading ||= ENV.include? JAMF_VERBOSE_LOADING_ENV
|
90
|
-
@verbose_loading
|
91
|
-
end
|
92
|
-
|
93
|
-
# rubocop: disable Style/StderrPuts
|
67
|
+
# Use the load_msg method defined for Zeitwerk
|
94
68
|
def self.load_msg(msg)
|
95
|
-
|
96
|
-
|
97
|
-
$stderr.puts msg
|
98
|
-
end
|
99
|
-
# rubocop: enable Style/StderrPuts
|
69
|
+
JamfZeitwerkConfig.load_msg msg
|
70
|
+
end
|
100
71
|
|
101
72
|
# the single instance of our configuration object
|
102
73
|
def self.config
|
@@ -113,11 +84,8 @@ module Jamf
|
|
113
84
|
|
114
85
|
end # module Jamf
|
115
86
|
|
116
|
-
# make sure we can run
|
117
|
-
Jamf.validate_ruby_version
|
118
|
-
|
119
87
|
# JSS module is now a synonym for Jamf module
|
120
88
|
JSS = Jamf
|
121
89
|
|
122
|
-
# testing zeitwerk loading
|
123
|
-
eager_load_for_testing
|
90
|
+
# testing zeitwerk loading, the the desired file is present
|
91
|
+
JamfZeitwerkConfig.eager_load_for_testing
|
data/test/tests/policy.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: 2.0.
|
4
|
+
version: 2.0.0rc1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Chris Lasell
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2022-
|
13
|
+
date: 2022-09-07 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: CFPropertyList
|
@@ -50,42 +50,30 @@ dependencies:
|
|
50
50
|
name: faraday
|
51
51
|
requirement: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- - "
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: 1.0.0
|
56
|
-
- - "<="
|
53
|
+
- - "~>"
|
57
54
|
- !ruby/object:Gem::Version
|
58
|
-
version: 1.0
|
55
|
+
version: '1.0'
|
59
56
|
type: :runtime
|
60
57
|
prerelease: false
|
61
58
|
version_requirements: !ruby/object:Gem::Requirement
|
62
59
|
requirements:
|
63
|
-
- - "
|
64
|
-
- !ruby/object:Gem::Version
|
65
|
-
version: 1.0.0
|
66
|
-
- - "<="
|
60
|
+
- - "~>"
|
67
61
|
- !ruby/object:Gem::Version
|
68
|
-
version: 1.0
|
62
|
+
version: '1.0'
|
69
63
|
- !ruby/object:Gem::Dependency
|
70
64
|
name: faraday_middleware
|
71
65
|
requirement: !ruby/object:Gem::Requirement
|
72
66
|
requirements:
|
73
|
-
- - "
|
74
|
-
- !ruby/object:Gem::Version
|
75
|
-
version: 1.0.0
|
76
|
-
- - "<="
|
67
|
+
- - "~>"
|
77
68
|
- !ruby/object:Gem::Version
|
78
|
-
version: 1.0
|
69
|
+
version: '1.0'
|
79
70
|
type: :runtime
|
80
71
|
prerelease: false
|
81
72
|
version_requirements: !ruby/object:Gem::Requirement
|
82
73
|
requirements:
|
83
|
-
- - "
|
84
|
-
- !ruby/object:Gem::Version
|
85
|
-
version: 1.0.0
|
86
|
-
- - "<="
|
74
|
+
- - "~>"
|
87
75
|
- !ruby/object:Gem::Version
|
88
|
-
version: 1.0
|
76
|
+
version: '1.0'
|
89
77
|
- !ruby/object:Gem::Dependency
|
90
78
|
name: concurrent-ruby
|
91
79
|
requirement: !ruby/object:Gem::Requirement
|
@@ -107,9 +95,6 @@ dependencies:
|
|
107
95
|
- - "~>"
|
108
96
|
- !ruby/object:Gem::Version
|
109
97
|
version: '2.3'
|
110
|
-
- - ">="
|
111
|
-
- !ruby/object:Gem::Version
|
112
|
-
version: 2.3.0
|
113
98
|
type: :runtime
|
114
99
|
prerelease: false
|
115
100
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -117,9 +102,6 @@ dependencies:
|
|
117
102
|
- - "~>"
|
118
103
|
- !ruby/object:Gem::Version
|
119
104
|
version: '2.3'
|
120
|
-
- - ">="
|
121
|
-
- !ruby/object:Gem::Version
|
122
|
-
version: 2.3.0
|
123
105
|
- !ruby/object:Gem::Dependency
|
124
106
|
name: zeitwerk
|
125
107
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,6 +126,9 @@ dependencies:
|
|
144
126
|
name: rexml
|
145
127
|
requirement: !ruby/object:Gem::Requirement
|
146
128
|
requirements:
|
129
|
+
- - "~>"
|
130
|
+
- !ruby/object:Gem::Version
|
131
|
+
version: '3.1'
|
147
132
|
- - ">="
|
148
133
|
- !ruby/object:Gem::Version
|
149
134
|
version: 3.1.9
|
@@ -151,6 +136,9 @@ dependencies:
|
|
151
136
|
prerelease: false
|
152
137
|
version_requirements: !ruby/object:Gem::Requirement
|
153
138
|
requirements:
|
139
|
+
- - "~>"
|
140
|
+
- !ruby/object:Gem::Version
|
141
|
+
version: '3.1'
|
154
142
|
- - ">="
|
155
143
|
- !ruby/object:Gem::Version
|
156
144
|
version: 3.1.9
|
@@ -159,9 +147,9 @@ description: |
|
|
159
147
|
an enterprise/education tool for managing Apple devices, from jamf.com.
|
160
148
|
The Jamf module provides access to both the 'Classic' API and the more modern
|
161
149
|
'Jamf Pro' API. Jamf Pro objects are implemented as classes and can interact
|
162
|
-
with each other.
|
150
|
+
with each other. Authentication tokens, data transfer using JSON or XML and other
|
163
151
|
details are handled automatically under the hood to allow simpler, intuitive
|
164
|
-
automation of Jamf-related
|
152
|
+
automation of Jamf-related tasks.
|
165
153
|
email: ruby-jss@pixar.com
|
166
154
|
executables:
|
167
155
|
- cgrouper
|
@@ -759,6 +747,7 @@ files:
|
|
759
747
|
- lib/jamf/configuration.rb
|
760
748
|
- lib/jamf/constants.rb
|
761
749
|
- lib/jamf/db_connection.rb
|
750
|
+
- lib/jamf/deprecations/deprecated_api_connection_class.rb
|
762
751
|
- lib/jamf/deprecations/deprecated_api_constant.rb
|
763
752
|
- lib/jamf/deprecations/deprecated_config_constant.rb
|
764
753
|
- lib/jamf/exceptions.rb
|
@@ -786,10 +775,10 @@ files:
|
|
786
775
|
- lib/jamf/utility.rb
|
787
776
|
- lib/jamf/validate.rb
|
788
777
|
- lib/jamf/version.rb
|
778
|
+
- lib/jamf/zeitwerk_config.rb
|
789
779
|
- lib/jss-api.rb
|
790
780
|
- lib/jss.rb
|
791
781
|
- lib/ruby-jss.rb
|
792
|
-
- lib/zeitwerk_config.rb
|
793
782
|
- test/README-TEST.md
|
794
783
|
- test/bin/runtests
|
795
784
|
- test/lib/jamf_test.rb
|