ruby-jss 0.6.5 → 0.6.6
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of ruby-jss might be problematic. Click here for more details.
- 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 MobileDeviceCommandCompletedEvent < Event
|
28
|
+
|
29
|
+
EVENT_NAME = 'MobileDeviceCommandCompleted'.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[MobileDeviceCommandCompletedEvent::EVENT_NAME] = MobileDeviceCommandCompletedEvent
|
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 MobileDeviceEnrolledEvent < Event
|
28
|
+
|
29
|
+
EVENT_NAME = 'MobileDeviceEnrolled'.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[MobileDeviceEnrolledEvent::EVENT_NAME] = MobileDeviceEnrolledEvent
|
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 MobileDevicePushSentEvent < Event
|
28
|
+
|
29
|
+
EVENT_NAME = 'MobileDevicePushSent'.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[MobileDevicePushSentEvent::EVENT_NAME] = MobileDevicePushSentEvent
|
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 MobileDeviceUnEnrolledEvent < Event
|
28
|
+
|
29
|
+
EVENT_NAME = 'MobileDeviceUnEnrolled'.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[MobileDeviceUnEnrolledEvent::EVENT_NAME] = MobileDeviceUnEnrolledEvent
|
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 PatchSoftwareTitleUpdatedEvent < Event
|
28
|
+
|
29
|
+
EVENT_NAME = 'PatchSoftwareTitleUpdated'.freeze
|
30
|
+
OBJECT_CLASS = JSSWebHooks::EventObjects::PatchSoftwareTitleUpdate
|
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[PatchSoftwareTitleUpdatedEvent::EVENT_NAME] = PatchSoftwareTitleUpdatedEvent
|
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 PushSentEvent < Event
|
28
|
+
|
29
|
+
EVENT_NAME = 'PushSent'.freeze
|
30
|
+
OBJECT_CLASS = JSSWebHooks::EventObjects::Push
|
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[PushSentEvent::EVENT_NAME] = PushSentEvent
|
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 RestAPIOperationEvent < Event
|
28
|
+
|
29
|
+
EVENT_NAME = 'RestAPIOperation'.freeze
|
30
|
+
OBJECT_CLASS = JSSWebHooks::EventObjects::RestAPIOperation
|
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[RestAPIOperationEvent::EVENT_NAME] = RestAPIOperationEvent
|
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 SCEPChallengeEvent < Event
|
28
|
+
|
29
|
+
EVENT_NAME = 'SCEPChallenge'.freeze
|
30
|
+
OBJECT_CLASS = JSSWebHooks::EventObjects::SCEPChallenge
|
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[SCEPChallengeEvent::EVENT_NAME] = SCEPChallengeEvent
|
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 SmartGroupComputerMembershipChangeEvent < Event
|
28
|
+
|
29
|
+
EVENT_NAME = 'SmartGroupComputerMembershipChange'.freeze
|
30
|
+
OBJECT_CLASS = JSSWebHooks::EventObjects::SmartGroup
|
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[SmartGroupComputerMembershipChangeEvent::EVENT_NAME] = SmartGroupComputerMembershipChangeEvent
|
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 SmartGroupMobileDeviceMembershipChangeEvent < Event
|
28
|
+
|
29
|
+
EVENT_NAME = 'SmartGroupMobileDeviceMembershipChange'.freeze
|
30
|
+
OBJECT_CLASS = JSSWebHooks::EventObjects::SmartGroup
|
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[SmartGroupMobileDeviceMembershipChangeEvent::EVENT_NAME] = SmartGroupMobileDeviceMembershipChangeEvent
|
36
|
+
|
37
|
+
end # module
|
@@ -0,0 +1,39 @@
|
|
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 Event
|
28
|
+
|
29
|
+
WEBHOOK_ATTRIBUTES = [
|
30
|
+
:id,
|
31
|
+
:name,
|
32
|
+
:webhookEvent
|
33
|
+
].freeze
|
34
|
+
|
35
|
+
WebHook = ImmutableStruct.new(*WEBHOOK_ATTRIBUTES)
|
36
|
+
|
37
|
+
end # class event
|
38
|
+
|
39
|
+
end # module
|
@@ -0,0 +1,111 @@
|
|
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
|
+
# Event Objects are JSON structures that come from the JSS
|
28
|
+
# with every webhook event. They represent the object that was affected
|
29
|
+
# by the event. For example, A ComputerAdded event affects
|
30
|
+
# a computer, and a RestAPIOperation event affects a REST API
|
31
|
+
# object.
|
32
|
+
#
|
33
|
+
# Since these Event Objects are mostly just short-lived static data
|
34
|
+
# they don't need to be represented full-blown Classes, but they would
|
35
|
+
# be nicer to work with if they weren't just Hashes.
|
36
|
+
#
|
37
|
+
# Ruby's Struct class provides a handy way to create something that's
|
38
|
+
# more than a Hash but less than a full Class. Unfortuantely, Struct-
|
39
|
+
# derived classes are fully mutable, and require positional parameters
|
40
|
+
# when creating instances.
|
41
|
+
#
|
42
|
+
# The ImmutableStruct class, provided by the immutable-struct gem,
|
43
|
+
# (https://github.com/stitchfix/immutable-struct)
|
44
|
+
# creates classes whose instances have immutable attributes, but allow
|
45
|
+
# (nay, require) named parameters when creating instances.
|
46
|
+
#
|
47
|
+
# This module dynamically creates ImmutableStruct classes for the various
|
48
|
+
# Event Objects that come with each webhook event. Each Event Objects class
|
49
|
+
# is defined in the @object_definitions Hash, which is accessible via the
|
50
|
+
# JSSWebHooks::EventObjects::object_definitions method.
|
51
|
+
#
|
52
|
+
# Each object is defined in that Hash thus:
|
53
|
+
#
|
54
|
+
# Key: Symbol, the name of the object e.g. :computer
|
55
|
+
# Value: Hash, the attributes and other data for created the object's Class
|
56
|
+
#
|
57
|
+
# The value hash has these keys:
|
58
|
+
#
|
59
|
+
# :class_name => String, the name of the ImmutableStruct Class for this
|
60
|
+
# object, e.g. "Computer"
|
61
|
+
# :attributes => Array[<Symbol>], The instance-attributes for the Class, to
|
62
|
+
# be passed in as the keys of a hash when creating an instance.
|
63
|
+
# :methods => Array[<Hash>], if any methods are needed for the Class, other
|
64
|
+
# than the default getters for the attributes, each Hash in this array
|
65
|
+
# defines one. The :name key contains a symbol, the name of the method,
|
66
|
+
# and the :proc key contains a Proc object, the method code. See
|
67
|
+
# JSSWebHooks::EventObjects.object_definitions[:patch_software_title_update]
|
68
|
+
# for an example.
|
69
|
+
#
|
70
|
+
module EventObjects
|
71
|
+
|
72
|
+
# This will hold the object definitions for each Event Object
|
73
|
+
# it will be populated by the require statements below.
|
74
|
+
@object_definitions = {}
|
75
|
+
|
76
|
+
# Access to the Module-instance var @object_definitions
|
77
|
+
#
|
78
|
+
# @return [Hash] the @object_definitions Hash
|
79
|
+
#
|
80
|
+
def self.object_definitions
|
81
|
+
@object_definitions
|
82
|
+
end
|
83
|
+
|
84
|
+
# load in the definitions of the Event Objects
|
85
|
+
Pathname.new(__FILE__).parent.+('event_objects').children.each do |file|
|
86
|
+
require file.to_s if file.extname == '.rb'
|
87
|
+
end
|
88
|
+
|
89
|
+
# loop thru the event object definitions,
|
90
|
+
# creating a class for each, via ImmutableStruct
|
91
|
+
@object_definitions.each do |_object_key, object_def|
|
92
|
+
new_class = ImmutableStruct.new(*object_def[:attributes]) do
|
93
|
+
# Class Method to return the list of attributes for this class
|
94
|
+
@attributes = object_def[:attributes]
|
95
|
+
def self.attributes
|
96
|
+
@attributes
|
97
|
+
end
|
98
|
+
|
99
|
+
# if any non-getter methods are needed for this class,
|
100
|
+
# create them here
|
101
|
+
object_def[:methods].to_a.each do |meth|
|
102
|
+
next unless meth[:name] && meth[:proc]
|
103
|
+
define_method meth[:name], meth[:proc]
|
104
|
+
end
|
105
|
+
end
|
106
|
+
const_set object_def[:class_name], new_class
|
107
|
+
end # @object_definitions.each
|
108
|
+
|
109
|
+
end # module event object
|
110
|
+
|
111
|
+
end # module
|