Class: JSS::WebHook
- Defined in:
- lib/jss/api_object/webhook.rb,
lib/jss.rb
Overview
A webhook as defined in JamfPro.
Constant Summary collapse
- RSRC_BASE =
The base for REST resources of this class
'webhooks'.freeze
- RSRC_LIST_KEY =
the hash key used for the JSON list output of all objects in the JSS
:webhooks
- RSRC_OBJECT_KEY =
The hash key used for the JSON object output. It's also used in various error messages
:webhook
- CONTENT_TYPES =
the content types available for webhooks, internally we use Symbols, but the API wants the proper MIME strings
{ xml: 'text/xml', json: 'application/json' }.freeze
- EVENTS =
The available webhook events.
%w( ComputerAdded ComputerCheckIn ComputerInventoryCompleted ComputerPolicyFinished ComputerPushCapabilityChanged JSSShutdown JSSStartup MobileDeviceCheckIn MobileDeviceCommandCompleted MobileDeviceEnrolled MobileDevicePushSent MobileDeviceUnEnrolled PatchSoftwareTitleUpdated PushSent RestAPIOperation SCEPChallenge SmartGroupComputerMembershipChange SmartGroupMobileDeviceMembershipChange ).freeze
- OBJECT_HISTORY_OBJECT_TYPE =
the object type for this object in the object history table. See APIObject#add_object_history_entry
500
Instance Attribute Summary collapse
-
#content_type ⇒ Symbols
The content_type, one of the keys of CONTENT_TYPES.
-
#enabled ⇒ Boolean
(also: #enabled?)
Is this webhook enabled?.
-
#event ⇒ String
The event name to which this webhook responds.
-
#need_to_update ⇒ Boolean
included
from Updatable
readonly
Do we have unsaved changes?.
-
#url ⇒ String
The URL accessed by this webhook.
Instance Method Summary collapse
-
#clone(new_name, api: nil) ⇒ APIObject
included
from Creatable
make a clone of this API object, with a new name.
-
#create ⇒ Integer
included
from Creatable
Create a new object in the JSS.
-
#disable ⇒ void
Disable this webhook, saving the new state immediately.
-
#enable ⇒ void
Enable this webhook, saving the new state immediately.
-
#initialize(**args) ⇒ WebHook
constructor
See JSS::APIObject#initialize.
-
#name=(newname) ⇒ void
included
from Updatable
Change the name of this item Remember to #update to push changes to the server.
-
#update ⇒ Boolean
included
from Updatable
Save changes to the JSS.
Constructor Details
#initialize(**args) ⇒ WebHook
See JSS::APIObject#initialize
110 111 112 113 114 115 116 117 118 119 120 121 122 |
# File 'lib/jss/api_object/webhook.rb', line 110 def initialize(**args) super # now we have pkg_data with something in it, so fill out the instance vars @enabled = @init_data[:enabled] @url = @init_data[:url] @content_type = CONTENT_TYPES.invert[@init_data[:content_type]] @event = @init_data[:event] # defaults @content_type ||= :json @enabled = false if @enabled.nil? end |
Instance Attribute Details
#content_type ⇒ Symbols
Returns the content_type, one of the keys of CONTENT_TYPES.
101 102 103 |
# File 'lib/jss/api_object/webhook.rb', line 101 def content_type @content_type end |
#enabled ⇒ Boolean Also known as: enabled?
Returns is this webhook enabled?.
95 96 97 |
# File 'lib/jss/api_object/webhook.rb', line 95 def enabled @enabled end |
#event ⇒ String
Returns the event name to which this webhook responds.
104 105 106 |
# File 'lib/jss/api_object/webhook.rb', line 104 def event @event end |
#need_to_update ⇒ Boolean (readonly) Originally defined in module Updatable
Returns do we have unsaved changes?.
#url ⇒ String
Returns the URL accessed by this webhook.
98 99 100 |
# File 'lib/jss/api_object/webhook.rb', line 98 def url @url end |
Instance Method Details
#clone(new_name, api: nil) ⇒ APIObject Originally defined in module Creatable
make a clone of this API object, with a new name. The class must be creatable
#create ⇒ Integer Originally defined in module Creatable
Create a new object in the JSS.
#disable ⇒ void
This method returns an undefined value.
Disable this webhook, saving the new state immediately
206 207 208 209 210 |
# File 'lib/jss/api_object/webhook.rb', line 206 def disable raise JSS::NoSuchItemError, 'Save the webhook before disabling it' unless @in_jss self.enabled = false save end |
#enable ⇒ void
This method returns an undefined value.
Enable this webhook, saving the new state immediately
196 197 198 199 200 |
# File 'lib/jss/api_object/webhook.rb', line 196 def enable raise JSS::NoSuchItemError, 'Save the webhook before enabling it' unless @in_jss self.enabled = true save end |
#name=(newname) ⇒ void Originally defined in module Updatable
This method returns an undefined value.
Change the name of this item Remember to #update to push changes to the server.
#update ⇒ Boolean Originally defined in module Updatable
Save changes to the JSS