Class: Jamf::WebHook

Inherits:
APIObject show all
Includes:
Creatable, Updatable
Defined in:
lib/jamf/api/classic/api_objects/web_hook.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

Instance Method Summary collapse

Constructor Details

#initialize(**args) ⇒ WebHook

See Jamf::APIObject#initialize



110
111
112
113
114
115
116
117
118
119
120
121
122
# File 'lib/jamf/api/classic/api_objects/web_hook.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_typeSymbols

Returns the content_type, one of the keys of CONTENT_TYPES.

Returns:

  • (Symbols)

    the content_type, one of the keys of CONTENT_TYPES



101
102
103
# File 'lib/jamf/api/classic/api_objects/web_hook.rb', line 101

def content_type
  @content_type
end

#enabledBoolean Also known as: enabled?

Returns is this webhook enabled?.

Returns:

  • (Boolean)

    is this webhook enabled?



95
96
97
# File 'lib/jamf/api/classic/api_objects/web_hook.rb', line 95

def enabled
  @enabled
end

#eventString

Returns the event name to which this webhook responds.

Returns:

  • (String)

    the event name to which this webhook responds



104
105
106
# File 'lib/jamf/api/classic/api_objects/web_hook.rb', line 104

def event
  @event
end

#need_to_updateBoolean (readonly) Originally defined in module Updatable

Returns do we have unsaved changes?.

Returns:

  • (Boolean)

    do we have unsaved changes?

#urlString

Returns the URL accessed by this webhook.

Returns:

  • (String)

    the URL accessed by this webhook



98
99
100
# File 'lib/jamf/api/classic/api_objects/web_hook.rb', line 98

def url
  @url
end

Instance Method Details

#clone(new_name, api: nil, cnx: nil) ⇒ APIObject Originally defined in module Creatable

make a clone of this API object, with a new name. The class must be creatable

Parameters:

  • name (String)

    the name for the new object

  • cnx (Jamf::Connection) (defaults to: nil)

    the API in which to create the object Defaults to the API used to instantiate this object

Returns:

  • (APIObject)

    An unsaved clone of this APIObject with the given name

Raises:

#disablevoid

This method returns an undefined value.

Disable this webhook, saving the new state immediately



206
207
208
209
210
# File 'lib/jamf/api/classic/api_objects/web_hook.rb', line 206

def disable
  raise Jamf::NoSuchItemError, 'Save the webhook before disabling it' unless @in_jss
  self.enabled = false
  save
end

#enablevoid

This method returns an undefined value.

Enable this webhook, saving the new state immediately



196
197
198
199
200
# File 'lib/jamf/api/classic/api_objects/web_hook.rb', line 196

def enable
  raise Jamf::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.

Parameters:

  • newname (String)

    the new name

Raises: