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.
@@ -1,163 +0,0 @@
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
- # Configure the Zeitwerk loader, See https://github.com/fxn/zeitwerk
25
- def setup_zeitwerk_loader(loader)
26
- @loader = loader
27
-
28
- # Ignore this file (more ignores below)
29
- loader.ignore __FILE__
30
-
31
- # these paths all define classes & modules directly below 'Jamf'
32
- # If we didn't collaps them, then e.g.
33
- # /jamf/api/base_classes/classic/group.rb
34
- # would be expected to define
35
- # Jamf::Api::BaseClasses::Classic::Group
36
- # rather than what we want:
37
- # Jamf::Group
38
- ###################################################
39
-
40
- loader.collapse("#{__dir__}/jamf/api")
41
-
42
- loader.collapse("#{__dir__}/jamf/api/classic")
43
- loader.collapse("#{__dir__}/jamf/api/classic/api_objects")
44
- loader.collapse("#{__dir__}/jamf/api/classic/base_classes")
45
-
46
- loader.collapse("#{__dir__}/jamf/api/jamf_pro")
47
- loader.collapse("#{__dir__}/jamf/api/jamf_pro/api_objects")
48
- loader.collapse("#{__dir__}/jamf/api/jamf_pro/mixins")
49
- loader.collapse("#{__dir__}/jamf/api/jamf_pro/base_classes")
50
- loader.collapse("#{__dir__}/jamf/api/jamf_pro/other_classes")
51
-
52
- loader.collapse("#{__dir__}/jamf/deprecations")
53
-
54
- # filenames => Constants, which don't adhere to zeitwerk's parsing standards
55
- # Mostly because the a filename like 'oapi_object' would be
56
- # loaded by zeitwerk expecting it to define 'OapiObject', but it really
57
- # defines 'OAPIObject'
58
- ###############################################
59
-
60
- # Connections
61
- loader.inflector.inflect 'classic_api' => 'ClassicAPI'
62
- loader.inflector.inflect 'jamf_pro_api' => 'JamfProAPI'
63
- loader.inflector.inflect 'jamf_pro_api_error' => 'JamfProAPIError'
64
-
65
- # API objects, resources, and mixins
66
- loader.inflector.inflect 'oapi_schemas' => 'OAPISchemas'
67
- loader.inflector.inflect 'oapi_object' => 'OAPIObject'
68
- loader.inflector.inflect 'oapi_validate' => 'OAPIValidate'
69
-
70
- loader.inflector.inflect 'jpapi_resource' => 'JPAPIResource'
71
-
72
- loader.inflector.inflect 'api_object' => 'APIObject'
73
- loader.inflector.inflect 'xml_workaround' => 'XMLWorkaround'
74
- loader.inflector.inflect 'json_object' => 'JSONObject'
75
- loader.inflector.inflect 'vppable' => 'VPPable'
76
- loader.inflector.inflect 'osx_configuration_profile' => 'OSXConfigurationProfile'
77
- loader.inflector.inflect 'jp_extendable' => 'JPExtendable'
78
- loader.inflector.inflect 'mdm' => 'MDM'
79
- loader.inflector.inflect 'ibeacon' => 'IBeacon'
80
- loader.inflector.inflect 'powerbroker_identity_services' => 'PowerBroker'
81
- loader.inflector.inflect 'admitmac' => 'ADmitMac'
82
- loader.inflector.inflect 'ip_address' => 'IPAddress'
83
- loader.inflector.inflect 'netboot_server' => 'NetBootServer'
84
- loader.inflector.inflect 'vpp_account' => 'VPPAccount'
85
- loader.inflector.inflect 'removable_macaddr' => 'RemovableMacAddress'
86
- loader.inflector.inflect 'md_prestage_name' => 'MobileDevicePrestageName'
87
- loader.inflector.inflect 'md_prestage_names' => 'MobileDevicePrestageNames'
88
- loader.inflector.inflect 'md_prestage_skip_setup_items' => 'MobileDevicePrestageSkipSetupItems'
89
- loader.inflector.inflect 'macos_managed_updates' => 'MacOSManagedUpdates'
90
-
91
- # deprecations, separated so they load only when used
92
- loader.inflector.inflect('deprecated_api_constant' => 'API')
93
- loader.inflector.inflect('deprecated_config_constant' => 'CONFIG')
94
-
95
- # These should be ignored, some will be required directly
96
- #####################################
97
-
98
- loader.ignore "#{__dir__}/jamf/api/jamf_pro/pre_oapi"
99
-
100
- loader.ignore "#{__dir__}/jamf/db_connection.rb"
101
- loader.ignore "#{__dir__}/jamf/ruby_extensions.rb"
102
- loader.ignore "#{__dir__}/jamf/ruby_extensions"
103
- loader.ignore "#{__dir__}/jamf/exceptions.rb"
104
- loader.ignore "#{__dir__}/jss-api.rb"
105
- loader.ignore "#{__dir__}/jss.rb"
106
- loader.ignore "#{__dir__}/ruby-jss.rb"
107
-
108
- # callback for when a specific file/constant loads
109
- #####################################
110
- loader.on_load('Jamf::SomeClass') do |klass, abspath|
111
- Jamf.load_msg "I just loaded #{klass} from #{abspath}"
112
- end
113
-
114
- # callback for when anything loads
115
- # - const_path is like "Jamf::SomeClass" or "Jamf::SomeClass::SOME_CONST_ARRY"
116
- # - value is the value that constant contains after loading,
117
- # e.g. a the class Jamf::SomeClass for 'Jamf::SomeClass' or
118
- # and Array for the constant "Jamf::SomeClass::SOME_CONST_ARRY"
119
- # - abspath is the full path to the file where the constant was loaded from.
120
- #####################################
121
- loader.on_load do |const_path, value, abspath|
122
- Jamf.load_msg "Zeitwerk just loaded #{value.class} '#{const_path}' from:\n #{abspath}"
123
-
124
- # Parse OAPI_PROPERTIES into getters and setters for subclasses of
125
- # OAPIObject in the JPAPI.
126
- # The class we just loaded must have this method and constant
127
- # and the method must not have run already for the class or any superclass.
128
- # This prevents running parse_oapi_properties again in subclasses that
129
- # don't need to do that
130
- if value.respond_to?(:oapi_properties_parsed?) && \
131
- defined?(value::OAPI_PROPERTIES) && \
132
- !value.oapi_properties_parsed?
133
-
134
- parsed = value.parse_oapi_properties
135
- Jamf.load_msg "Parsed OAPI_PROPERTIES for #{value}" if parsed
136
- end
137
-
138
- # Generate the identifier list methods (.all_*) for subclasses of APIObject
139
- # in the Classic API
140
- if value.is_a?(Class) && value.superclass == Jamf::APIObject
141
-
142
- done = value.define_identifier_list_methods
143
- Jamf.load_msg "Defined identifier list methods for #{value}" if done
144
- end
145
- end
146
-
147
- loader.setup
148
- end # setup_zeitwerk_loader
149
-
150
- # For testing the Zeitwrk Loader.
151
- # Normally we want autoloading on demand,
152
- # eager loading loads everything so we can see it
153
- #
154
- # To make this happen touch the file defined in JAMF_ZEITWERK_EAGER_LOAD_FILE
155
- # in jamf.rb
156
- def eager_load_for_testing
157
- return unless JAMF_ZEITWERK_EAGER_LOAD_FILE.file?
158
-
159
- @loader.eager_load(force: true)
160
- warn :loaded
161
- # rescue Zeitwerk::NameError => e
162
- # warn e.message
163
- end