ruby-jss 0.6.5 → 0.6.6
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 +57 -5
- data/lib/jss.rb +78 -94
- data/lib/jss/api_connection.rb +8 -0
- data/lib/jss/api_object.rb +126 -102
- data/lib/jss/api_object/creatable.rb +33 -15
- data/lib/jss/api_object/distribution_point.rb +4 -1
- data/lib/jss/api_object/extension_attribute.rb +1 -1
- data/lib/jss/api_object/package.rb +121 -187
- data/lib/jss/api_object/policy.rb +590 -251
- data/lib/jss/api_object/script.rb +92 -128
- data/lib/jss/api_object/self_servable.rb +93 -117
- data/lib/jss/api_object/updatable.rb +12 -27
- data/lib/jss/api_object/uploadable.rb +12 -15
- data/lib/jss/client.rb +178 -156
- data/lib/jss/db_connection.rb +34 -49
- data/lib/jss/ruby_extensions/string.rb +25 -21
- data/lib/jss/version.rb +1 -1
- data/lib/jss/webhooks.rb +52 -0
- data/lib/jss/webhooks/README.md +269 -0
- data/lib/jss/webhooks/configuration.rb +212 -0
- data/lib/jss/webhooks/data/sample_handlers/RestAPIOperation-executable +90 -0
- data/lib/jss/webhooks/data/sample_handlers/RestAPIOperation.rb +44 -0
- data/lib/jss/webhooks/data/sample_jsons/ComputerAdded.json +27 -0
- data/lib/jss/webhooks/data/sample_jsons/ComputerCheckIn.json +27 -0
- data/lib/jss/webhooks/data/sample_jsons/ComputerInventoryCompleted.json +27 -0
- data/lib/jss/webhooks/data/sample_jsons/ComputerPolicyFinished.json +27 -0
- data/lib/jss/webhooks/data/sample_jsons/ComputerPushCapabilityChanged.json +27 -0
- data/lib/jss/webhooks/data/sample_jsons/JSSShutdown.json +14 -0
- data/lib/jss/webhooks/data/sample_jsons/JSSStartup.json +14 -0
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceCheckIn.json +26 -0
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceCommandCompleted.json +26 -0
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceEnrolled.json +26 -0
- data/lib/jss/webhooks/data/sample_jsons/MobileDevicePushSent.json +26 -0
- data/lib/jss/webhooks/data/sample_jsons/MobileDeviceUnEnrolled.json +26 -0
- data/lib/jss/webhooks/data/sample_jsons/PatchSoftwareTitleUpdated.json +14 -0
- data/lib/jss/webhooks/data/sample_jsons/PushSent.json +11 -0
- data/lib/jss/webhooks/data/sample_jsons/RestAPIOperation.json +15 -0
- data/lib/jss/webhooks/data/sample_jsons/SCEPChallenge.json +10 -0
- data/lib/jss/webhooks/data/sample_jsons/SmartGroupComputerMembershipChange.json +13 -0
- data/lib/jss/webhooks/data/sample_jsons/SmartGroupMobileDeviceMembershipChange.json +13 -0
- data/lib/jss/webhooks/event.rb +138 -0
- data/lib/jss/webhooks/event/computer_added.rb +37 -0
- data/lib/jss/webhooks/event/computer_check_in.rb +37 -0
- data/lib/jss/webhooks/event/computer_inventory_completed.rb +37 -0
- data/lib/jss/webhooks/event/computer_policy_finished.rb +37 -0
- data/lib/jss/webhooks/event/computer_push_capability_changed.rb +37 -0
- data/lib/jss/webhooks/event/handlers.rb +191 -0
- data/lib/jss/webhooks/event/jss_shutdown.rb +37 -0
- data/lib/jss/webhooks/event/jss_startup.rb +37 -0
- data/lib/jss/webhooks/event/mobile_device_check_in.rb +37 -0
- data/lib/jss/webhooks/event/mobile_device_command_completed.rb +37 -0
- data/lib/jss/webhooks/event/mobile_device_enrolled.rb +37 -0
- data/lib/jss/webhooks/event/mobile_device_push_sent.rb +37 -0
- data/lib/jss/webhooks/event/mobile_device_unenrolled.rb +37 -0
- data/lib/jss/webhooks/event/patch_software_title_updated.rb +37 -0
- data/lib/jss/webhooks/event/push_sent.rb +37 -0
- data/lib/jss/webhooks/event/rest_api_operation.rb +37 -0
- data/lib/jss/webhooks/event/scep_challenge.rb +37 -0
- data/lib/jss/webhooks/event/smart_group_computer_membership_change.rb +37 -0
- data/lib/jss/webhooks/event/smart_group_mobile_device_membership_change.rb +37 -0
- data/lib/jss/webhooks/event/webhook.rb +39 -0
- data/lib/jss/webhooks/event_objects.rb +111 -0
- data/lib/jss/webhooks/event_objects/computer.rb +48 -0
- data/lib/jss/webhooks/event_objects/jss.rb +35 -0
- data/lib/jss/webhooks/event_objects/mobile_device.rb +47 -0
- data/lib/jss/webhooks/event_objects/patch_software_title_update.rb +37 -0
- data/lib/jss/webhooks/event_objects/push.rb +32 -0
- data/lib/jss/webhooks/event_objects/rest_api_operation.rb +36 -0
- data/lib/jss/webhooks/event_objects/scep_challenge.rb +31 -0
- data/lib/jss/webhooks/event_objects/smart_group.rb +34 -0
- data/lib/jss/webhooks/server_app.rb +36 -0
- data/lib/jss/webhooks/server_app/routes.rb +26 -0
- data/lib/jss/webhooks/server_app/routes/handle_webhook_event.rb +38 -0
- data/lib/jss/webhooks/server_app/routes/home.rb +36 -0
- data/lib/jss/webhooks/server_app/self_signed_cert.rb +64 -0
- data/lib/jss/webhooks/server_app/server.rb +59 -0
- data/lib/jss/webhooks/version.rb +31 -0
- metadata +63 -4
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
### Copyright 2016 Pixar
|
|
2
|
+
###
|
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
4
|
+
### with the following modification; you may not use this file except in
|
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
|
7
|
+
###
|
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
|
12
|
+
###
|
|
13
|
+
### You may obtain a copy of the Apache License at
|
|
14
|
+
###
|
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
###
|
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
### distributed under the Apache License with the above modification is
|
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
|
22
|
+
###
|
|
23
|
+
###
|
|
24
|
+
|
|
25
|
+
module JSSWebHooks
|
|
26
|
+
|
|
27
|
+
class ComputerCheckInEvent < Event
|
|
28
|
+
|
|
29
|
+
EVENT_NAME = 'ComputerCheckIn'.freeze
|
|
30
|
+
OBJECT_CLASS = JSSWebHooks::EventObjects::Computer
|
|
31
|
+
|
|
32
|
+
end # class
|
|
33
|
+
|
|
34
|
+
# map the EVENT_NAME (which comes from the JSS) with this class
|
|
35
|
+
JSSWebHooks::Event.event_to_class_names[ComputerCheckInEvent::EVENT_NAME] = ComputerCheckInEvent
|
|
36
|
+
|
|
37
|
+
end # module
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
### Copyright 2016 Pixar
|
|
2
|
+
###
|
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
4
|
+
### with the following modification; you may not use this file except in
|
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
|
7
|
+
###
|
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
|
12
|
+
###
|
|
13
|
+
### You may obtain a copy of the Apache License at
|
|
14
|
+
###
|
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
###
|
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
### distributed under the Apache License with the above modification is
|
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
|
22
|
+
###
|
|
23
|
+
###
|
|
24
|
+
|
|
25
|
+
module JSSWebHooks
|
|
26
|
+
|
|
27
|
+
class ComputerInventoryCompletedEvent < Event
|
|
28
|
+
|
|
29
|
+
EVENT_NAME = 'ComputerInventoryCompleted'.freeze
|
|
30
|
+
OBJECT_CLASS = JSSWebHooks::EventObjects::Computer
|
|
31
|
+
|
|
32
|
+
end # class
|
|
33
|
+
|
|
34
|
+
# map the EVENT_NAME (which comes from the JSS) with this class
|
|
35
|
+
JSSWebHooks::Event.event_to_class_names[ComputerInventoryCompletedEvent::EVENT_NAME] = ComputerInventoryCompletedEvent
|
|
36
|
+
|
|
37
|
+
end # module
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
### Copyright 2016 Pixar
|
|
2
|
+
###
|
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
4
|
+
### with the following modification; you may not use this file except in
|
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
|
7
|
+
###
|
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
|
12
|
+
###
|
|
13
|
+
### You may obtain a copy of the Apache License at
|
|
14
|
+
###
|
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
###
|
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
### distributed under the Apache License with the above modification is
|
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
|
22
|
+
###
|
|
23
|
+
###
|
|
24
|
+
|
|
25
|
+
module JSSWebHooks
|
|
26
|
+
|
|
27
|
+
class ComputerPolicyFinishedEvent < Event
|
|
28
|
+
|
|
29
|
+
EVENT_NAME = 'ComputerPolicyFinished'.freeze
|
|
30
|
+
OBJECT_CLASS = JSSWebHooks::EventObjects::Computer
|
|
31
|
+
|
|
32
|
+
end # class
|
|
33
|
+
|
|
34
|
+
# map the EVENT_NAME (which comes from the JSS) with this class
|
|
35
|
+
JSSWebHooks::Event.event_to_class_names[ComputerPolicyFinishedEvent::EVENT_NAME] = ComputerPolicyFinishedEvent
|
|
36
|
+
|
|
37
|
+
end # module
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
### Copyright 2016 Pixar
|
|
2
|
+
###
|
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
4
|
+
### with the following modification; you may not use this file except in
|
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
|
7
|
+
###
|
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
|
12
|
+
###
|
|
13
|
+
### You may obtain a copy of the Apache License at
|
|
14
|
+
###
|
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
###
|
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
### distributed under the Apache License with the above modification is
|
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
|
22
|
+
###
|
|
23
|
+
###
|
|
24
|
+
|
|
25
|
+
module JSSWebHooks
|
|
26
|
+
|
|
27
|
+
class ComputerPushCapabilityChangedEvent < Event
|
|
28
|
+
|
|
29
|
+
EVENT_NAME = 'ComputerPushCapabilityChanged'.freeze
|
|
30
|
+
OBJECT_CLASS = JSSWebHooks::EventObjects::Computer
|
|
31
|
+
|
|
32
|
+
end # class
|
|
33
|
+
|
|
34
|
+
# map the EVENT_NAME (which comes from the JSS) with this class
|
|
35
|
+
JSSWebHooks::Event.event_to_class_names[ComputerPushCapabilityChangedEvent::EVENT_NAME] = ComputerPushCapabilityChangedEvent
|
|
36
|
+
|
|
37
|
+
end # module
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
### Copyright 2016 Pixar
|
|
2
|
+
###
|
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
4
|
+
### with the following modification; you may not use this file except in
|
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
|
7
|
+
###
|
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
|
12
|
+
###
|
|
13
|
+
### You may obtain a copy of the Apache License at
|
|
14
|
+
###
|
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
###
|
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
### distributed under the Apache License with the above modification is
|
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
|
22
|
+
###
|
|
23
|
+
###
|
|
24
|
+
|
|
25
|
+
module JSSWebHooks
|
|
26
|
+
|
|
27
|
+
# This method is used by the Ruby event-handler files.
|
|
28
|
+
#
|
|
29
|
+
# Loading them should call this method and pass in a block
|
|
30
|
+
# with one parameter: a JSS::WebHooks::Event subclass object.
|
|
31
|
+
#
|
|
32
|
+
# The block is then converted to a Proc instance in @loaded_event_handler
|
|
33
|
+
# and from there can be stored for use by the event identified by the filename.
|
|
34
|
+
#
|
|
35
|
+
# NOTE: the files should be read with 'load' not 'require', so that they can
|
|
36
|
+
# be re-loaded as needed
|
|
37
|
+
#
|
|
38
|
+
# @see_also JSSWebHooks::load_handlers
|
|
39
|
+
#
|
|
40
|
+
# @param [Block] block the block to be used as an event handler
|
|
41
|
+
#
|
|
42
|
+
# @yieldparam [JSS::WebHooks::Event subclass] The event to be handled
|
|
43
|
+
#
|
|
44
|
+
# @return [Proc] the block converted to a Proc
|
|
45
|
+
#
|
|
46
|
+
def self.event_handler(&block)
|
|
47
|
+
Event::Handlers.loaded_event_handler = Proc.new(&block)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
class Event
|
|
51
|
+
|
|
52
|
+
module Handlers
|
|
53
|
+
|
|
54
|
+
############################
|
|
55
|
+
# Module constants
|
|
56
|
+
|
|
57
|
+
DEFAULT_HANDLER_DIR = '/Library/Application Support/JSSWebHooks'.freeze
|
|
58
|
+
|
|
59
|
+
############################
|
|
60
|
+
# Module Instance Variables, & accessors
|
|
61
|
+
|
|
62
|
+
@loaded_event_handler = nil
|
|
63
|
+
|
|
64
|
+
# Getter for @loaded_event_handler
|
|
65
|
+
#
|
|
66
|
+
# @return [Proc,nil] the most recent Proc loaded from a handler file.
|
|
67
|
+
# destined for storage in @event_handlers
|
|
68
|
+
#
|
|
69
|
+
def self.loaded_event_handler
|
|
70
|
+
@loaded_event_handler
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
# Setter for @loaded_event_handler
|
|
74
|
+
#
|
|
75
|
+
# @param [Proc] a_proc the most recent Proc loaded from a handler file.
|
|
76
|
+
# destined for storage in @event_handlers
|
|
77
|
+
#
|
|
78
|
+
def self.loaded_event_handler=(a_proc)
|
|
79
|
+
@loaded_event_handler = a_proc
|
|
80
|
+
end
|
|
81
|
+
|
|
82
|
+
@event_handlers = {}
|
|
83
|
+
|
|
84
|
+
# Getter for @event_handlers
|
|
85
|
+
#
|
|
86
|
+
# @return [Hash{String => Array}] a mapping of Event Names as the come from
|
|
87
|
+
# the JSS to an Array of handlers for the event. The handlers are either
|
|
88
|
+
# Proc objects to call from within ruby, or Pathnames to executable files
|
|
89
|
+
# which will take raw JSON on stdin.
|
|
90
|
+
def self.event_handlers
|
|
91
|
+
@event_handlers
|
|
92
|
+
end
|
|
93
|
+
|
|
94
|
+
############################
|
|
95
|
+
# Module Methods
|
|
96
|
+
|
|
97
|
+
# Load all the event handlers from the handler_dir or an arbitrary dir.
|
|
98
|
+
#
|
|
99
|
+
# @param [String, Pathname] from_dir directory from which to
|
|
100
|
+
# load the handlers
|
|
101
|
+
# @param [Boolean] reload should we reload handlers if they've already
|
|
102
|
+
# been loaded?
|
|
103
|
+
#
|
|
104
|
+
# @return [void]
|
|
105
|
+
#
|
|
106
|
+
def self.load_handlers(from_dir = CONFIG.handler_dir, reload = false)
|
|
107
|
+
from_dir ||= DEFAULT_HANDLER_DIR
|
|
108
|
+
|
|
109
|
+
if reload
|
|
110
|
+
@handlers_loaded_from = nil
|
|
111
|
+
@event_handlers = {}
|
|
112
|
+
@loaded_event_handler = nil
|
|
113
|
+
end
|
|
114
|
+
|
|
115
|
+
handler_dir = Pathname.new(from_dir)
|
|
116
|
+
return unless handler_dir.directory? && handler_dir.readable?
|
|
117
|
+
|
|
118
|
+
handler_dir.children.each do |handler_file|
|
|
119
|
+
load_handler(handler_file) if handler_file.file? && handler_file.readable?
|
|
120
|
+
end
|
|
121
|
+
|
|
122
|
+
@handlers_loaded_from = handler_dir
|
|
123
|
+
end # load handlers
|
|
124
|
+
|
|
125
|
+
# Load an even handler from a file.
|
|
126
|
+
# Handler files must begin with the name of the event they handle,
|
|
127
|
+
# e.g. ComputerAdded, followed by: nothing, a dot, a dash, or
|
|
128
|
+
# and underscore. Case doesn't matter.
|
|
129
|
+
# So all of these are OK:
|
|
130
|
+
# ComputerAdded
|
|
131
|
+
# computeradded.sh
|
|
132
|
+
# COMPUTERAdded_notify_team
|
|
133
|
+
# Computeradded-update-ldap
|
|
134
|
+
# There can be as many as desired for each event.
|
|
135
|
+
#
|
|
136
|
+
# Each must be either:
|
|
137
|
+
# - An executable file, which will have the raw JSON from the JSS piped
|
|
138
|
+
# to it's stdin when executed
|
|
139
|
+
# or
|
|
140
|
+
# - A non-executable file of ruby code like this:
|
|
141
|
+
# JSSWebHooks.event_handler do |event|
|
|
142
|
+
# # your code goes here.
|
|
143
|
+
# end
|
|
144
|
+
#
|
|
145
|
+
# (see HERE for details about writing the ruby handlers)
|
|
146
|
+
#
|
|
147
|
+
# @param [Pathname] from_file the file from which to
|
|
148
|
+
#
|
|
149
|
+
# @return [Type] description of returned object
|
|
150
|
+
#
|
|
151
|
+
def self.load_handler(from_file)
|
|
152
|
+
handler_file = Pathname.new from_file
|
|
153
|
+
event_name = event_name_from_handler_filename(handler_file)
|
|
154
|
+
return unless event_name
|
|
155
|
+
|
|
156
|
+
# create an array for this event's handlers, if needed
|
|
157
|
+
@event_handlers[event_name] ||= []
|
|
158
|
+
|
|
159
|
+
if handler_file.executable?
|
|
160
|
+
# store as a Pathname, we'll pipe JSON to it
|
|
161
|
+
@event_handlers[event_name] << handler_file unless \
|
|
162
|
+
@event_handlers[event_name].include? handler_file
|
|
163
|
+
else
|
|
164
|
+
# load the file. If written correctly, it will
|
|
165
|
+
# put a Proc into @loaded_event_handler
|
|
166
|
+
load handler_file.to_s
|
|
167
|
+
# store as a Proc, to be called when the event is handled.
|
|
168
|
+
@event_handlers[event_name] << @loaded_event_handler unless \
|
|
169
|
+
@event_handlers[event_name].include? @loaded_event_handler
|
|
170
|
+
|
|
171
|
+
end # if handler_file.executable?
|
|
172
|
+
end # self.load_handler(handler_file)
|
|
173
|
+
|
|
174
|
+
# Given a handler filename, return the event name it wants to handle
|
|
175
|
+
#
|
|
176
|
+
# @param [Pathname] filename The filename from which to glean the
|
|
177
|
+
# event name.
|
|
178
|
+
#
|
|
179
|
+
# @return [String,nil] The matching event name or nil if no match
|
|
180
|
+
#
|
|
181
|
+
def self.event_name_from_handler_filename(filename)
|
|
182
|
+
@event_names ||= JSSWebHooks::Event.event_to_class_names.keys
|
|
183
|
+
desired_event_name = filename.basename.to_s.split(/\.|-|_/).first
|
|
184
|
+
@event_names.select { |n| desired_event_name.casecmp(n).zero? }.first
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
end # module Handler
|
|
188
|
+
|
|
189
|
+
end # class event
|
|
190
|
+
|
|
191
|
+
end # module
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
### Copyright 2016 Pixar
|
|
2
|
+
###
|
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
4
|
+
### with the following modification; you may not use this file except in
|
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
|
7
|
+
###
|
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
|
12
|
+
###
|
|
13
|
+
### You may obtain a copy of the Apache License at
|
|
14
|
+
###
|
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
###
|
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
### distributed under the Apache License with the above modification is
|
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
|
22
|
+
###
|
|
23
|
+
###
|
|
24
|
+
|
|
25
|
+
module JSSWebHooks
|
|
26
|
+
|
|
27
|
+
class JSSShutdownEvent < Event
|
|
28
|
+
|
|
29
|
+
EVENT_NAME = 'JSSShutdown'.freeze
|
|
30
|
+
OBJECT_CLASS = JSSWebHooks::EventObjects::JSS
|
|
31
|
+
|
|
32
|
+
end # class
|
|
33
|
+
|
|
34
|
+
# map the EVENT_NAME (which comes from the JSS) with this class
|
|
35
|
+
JSSWebHooks::Event.event_to_class_names[JSSShutdownEvent::EVENT_NAME] = JSSShutdownEvent
|
|
36
|
+
|
|
37
|
+
end # module
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
### Copyright 2016 Pixar
|
|
2
|
+
###
|
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
4
|
+
### with the following modification; you may not use this file except in
|
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
|
7
|
+
###
|
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
|
12
|
+
###
|
|
13
|
+
### You may obtain a copy of the Apache License at
|
|
14
|
+
###
|
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
###
|
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
### distributed under the Apache License with the above modification is
|
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
|
22
|
+
###
|
|
23
|
+
###
|
|
24
|
+
|
|
25
|
+
module JSSWebHooks
|
|
26
|
+
|
|
27
|
+
class JSSStartupEvent < Event
|
|
28
|
+
|
|
29
|
+
EVENT_NAME = 'JSSStartup'.freeze
|
|
30
|
+
OBJECT_CLASS = JSSWebHooks::EventObjects::JSS
|
|
31
|
+
|
|
32
|
+
end # class
|
|
33
|
+
|
|
34
|
+
# map the EVENT_NAME (which comes from the JSS) with this class
|
|
35
|
+
JSSWebHooks::Event.event_to_class_names[JSSStartupEvent::EVENT_NAME] = JSSStartupEvent
|
|
36
|
+
|
|
37
|
+
end # module
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
### Copyright 2016 Pixar
|
|
2
|
+
###
|
|
3
|
+
### Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
4
|
+
### with the following modification; you may not use this file except in
|
|
5
|
+
### compliance with the Apache License and the following modification to it:
|
|
6
|
+
### Section 6. Trademarks. is deleted and replaced with:
|
|
7
|
+
###
|
|
8
|
+
### 6. Trademarks. This License does not grant permission to use the trade
|
|
9
|
+
### names, trademarks, service marks, or product names of the Licensor
|
|
10
|
+
### and its affiliates, except as required to comply with Section 4(c) of
|
|
11
|
+
### the License and to reproduce the content of the NOTICE file.
|
|
12
|
+
###
|
|
13
|
+
### You may obtain a copy of the Apache License at
|
|
14
|
+
###
|
|
15
|
+
### http://www.apache.org/licenses/LICENSE-2.0
|
|
16
|
+
###
|
|
17
|
+
### Unless required by applicable law or agreed to in writing, software
|
|
18
|
+
### distributed under the Apache License with the above modification is
|
|
19
|
+
### distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
20
|
+
### KIND, either express or implied. See the Apache License for the specific
|
|
21
|
+
### language governing permissions and limitations under the Apache License.
|
|
22
|
+
###
|
|
23
|
+
###
|
|
24
|
+
|
|
25
|
+
module JSSWebHooks
|
|
26
|
+
|
|
27
|
+
class MobileDeviceCheckInEvent < Event
|
|
28
|
+
|
|
29
|
+
EVENT_NAME = 'MobileDeviceCheckIn'.freeze
|
|
30
|
+
OBJECT_CLASS = JSSWebHooks::EventObjects::MobileDevice
|
|
31
|
+
|
|
32
|
+
end # class
|
|
33
|
+
|
|
34
|
+
# map the EVENT_NAME (which comes from the JSS) with this class
|
|
35
|
+
JSSWebHooks::Event.event_to_class_names[MobileDeviceCheckInEvent::EVENT_NAME] = MobileDeviceCheckInEvent
|
|
36
|
+
|
|
37
|
+
end # module
|