Class: MistApi::Webhook

Inherits:
BaseModel
  • Object
show all
Defined in:
lib/mist_api/models/webhook.rb

Overview

Webhook Model.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from BaseModel

#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json

Constructor Details

#initialize(assetfilter_ids = SKIP, created_time = SKIP, enabled = true, for_site = SKIP, headers = SKIP, id = SKIP, modified_time = SKIP, name = SKIP, oauth2_client_id = SKIP, oauth2_client_secret = SKIP, oauth2_grant_type = SKIP, oauth2_password = SKIP, oauth2_scopes = SKIP, oauth2_token_url = SKIP, oauth2_username = SKIP, org_id = SKIP, secret = SKIP, single_event_per_message = false, site_id = SKIP, splunk_token = SKIP, topics = SKIP, type = WebhookTypeEnum::HTTPPOST, url = SKIP, verify_cert = true, additional_properties = nil) ⇒ Webhook

Returns a new instance of Webhook.



195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
# File 'lib/mist_api/models/webhook.rb', line 195

def initialize(assetfilter_ids = SKIP, created_time = SKIP, enabled = true,
               for_site = SKIP, headers = SKIP, id = SKIP,
               modified_time = SKIP, name = SKIP, oauth2_client_id = SKIP,
               oauth2_client_secret = SKIP, oauth2_grant_type = SKIP,
               oauth2_password = SKIP, oauth2_scopes = SKIP,
               oauth2_token_url = SKIP, oauth2_username = SKIP,
               org_id = SKIP, secret = SKIP,
               single_event_per_message = false, site_id = SKIP,
               splunk_token = SKIP, topics = SKIP,
               type = WebhookTypeEnum::HTTPPOST, url = SKIP,
               verify_cert = true, additional_properties = nil)
  # Add additional model properties to the instance
  additional_properties = {} if additional_properties.nil?

  @assetfilter_ids = assetfilter_ids unless assetfilter_ids == SKIP
  @created_time = created_time unless created_time == SKIP
  @enabled = enabled unless enabled == SKIP
  @for_site = for_site unless for_site == SKIP
  @headers = headers unless headers == SKIP
  @id = id unless id == SKIP
  @modified_time = modified_time unless modified_time == SKIP
  @name = name unless name == SKIP
  @oauth2_client_id = oauth2_client_id unless oauth2_client_id == SKIP
  @oauth2_client_secret = oauth2_client_secret unless oauth2_client_secret == SKIP
  @oauth2_grant_type = oauth2_grant_type unless oauth2_grant_type == SKIP
  @oauth2_password = oauth2_password unless oauth2_password == SKIP
  @oauth2_scopes = oauth2_scopes unless oauth2_scopes == SKIP
  @oauth2_token_url = oauth2_token_url unless oauth2_token_url == SKIP
  @oauth2_username = oauth2_username unless oauth2_username == SKIP
  @org_id = org_id unless org_id == SKIP
  @secret = secret unless secret == SKIP
  @single_event_per_message = single_event_per_message unless single_event_per_message == SKIP
  @site_id = site_id unless site_id == SKIP
  @splunk_token = splunk_token unless splunk_token == SKIP
  @topics = topics unless topics == SKIP
  @type = type unless type == SKIP
  @url = url unless url == SKIP
  @verify_cert = verify_cert unless verify_cert == SKIP
  @additional_properties = additional_properties
end

Instance Attribute Details

#assetfilter_idsArray[UUID | String]

Only if ‘type`==`asset-raw-rssi`. List of ids to associated asset filters. These filters will be applied to messages routed to a filtered-asset-rssi webhook

Returns:

  • (Array[UUID | String])


16
17
18
# File 'lib/mist_api/models/webhook.rb', line 16

def assetfilter_ids
  @assetfilter_ids
end

#created_timeFloat

When the object has been created, in epoch

Returns:

  • (Float)


20
21
22
# File 'lib/mist_api/models/webhook.rb', line 20

def created_time
  @created_time
end

#enabledTrueClass | FalseClass

Whether webhook is enabled

Returns:

  • (TrueClass | FalseClass)


24
25
26
# File 'lib/mist_api/models/webhook.rb', line 24

def enabled
  @enabled
end

#for_siteTrueClass | FalseClass

Whether webhook is enabled

Returns:

  • (TrueClass | FalseClass)


28
29
30
# File 'lib/mist_api/models/webhook.rb', line 28

def for_site
  @for_site
end

#headersHash[String, String]

If ‘type`=`http-post`, additional custom HTTP headers to add. The headers name and value must be string, total bytes of headers name and value must be less than 1000

Returns:

  • (Hash[String, String])


34
35
36
# File 'lib/mist_api/models/webhook.rb', line 34

def headers
  @headers
end

#idUUID | String

Unique ID of the object instance in the Mist Organization

Returns:

  • (UUID | String)


38
39
40
# File 'lib/mist_api/models/webhook.rb', line 38

def id
  @id
end

#modified_timeFloat

When the object has been modified for the last time, in epoch

Returns:

  • (Float)


42
43
44
# File 'lib/mist_api/models/webhook.rb', line 42

def modified_time
  @modified_time
end

#nameString

Name of the webhook

Returns:

  • (String)


46
47
48
# File 'lib/mist_api/models/webhook.rb', line 46

def name
  @name
end

#oauth2_client_idString

Required when ‘oauth2_grant_type`==`client_credentials`

Returns:

  • (String)


50
51
52
# File 'lib/mist_api/models/webhook.rb', line 50

def oauth2_client_id
  @oauth2_client_id
end

#oauth2_client_secretString

Required when ‘oauth2_grant_type`==`client_credentials`

Returns:

  • (String)


54
55
56
# File 'lib/mist_api/models/webhook.rb', line 54

def oauth2_client_secret
  @oauth2_client_secret
end

#oauth2_grant_typeWebhookOauth2GrantTypeEnum

required when ‘type`==`oauth2`. enum: `client_credentials`, `password`



58
59
60
# File 'lib/mist_api/models/webhook.rb', line 58

def oauth2_grant_type
  @oauth2_grant_type
end

#oauth2_passwordString

Required when ‘oauth2_grant_type`==`password`

Returns:

  • (String)


62
63
64
# File 'lib/mist_api/models/webhook.rb', line 62

def oauth2_password
  @oauth2_password
end

#oauth2_scopesArray[String]

Required when ‘type`==`oauth2`, if provided, will be used in the token request

Returns:

  • (Array[String])


67
68
69
# File 'lib/mist_api/models/webhook.rb', line 67

def oauth2_scopes
  @oauth2_scopes
end

#oauth2_token_urlString

Required when ‘type`==`oauth2`

Returns:

  • (String)


71
72
73
# File 'lib/mist_api/models/webhook.rb', line 71

def oauth2_token_url
  @oauth2_token_url
end

#oauth2_usernameString

Required when ‘oauth2_grant_type`==`password`

Returns:

  • (String)


75
76
77
# File 'lib/mist_api/models/webhook.rb', line 75

def oauth2_username
  @oauth2_username
end

#org_idUUID | String

Required when ‘oauth2_grant_type`==`password`

Returns:

  • (UUID | String)


79
80
81
# File 'lib/mist_api/models/webhook.rb', line 79

def org_id
  @org_id
end

#secretString

Only if ‘type`=`http-post` when `secret` is provided, two HTTP headers will be added:

* X-Mist-Signature-v2: HMAC_SHA256(secret, body)
* X-Mist-Signature: HMAC_SHA1(secret, body)

Returns:

  • (String)


86
87
88
# File 'lib/mist_api/models/webhook.rb', line 86

def secret
  @secret
end

#single_event_per_messageTrueClass | FalseClass

Some solutions may not be able to parse multiple events from a single message (e.g. IBM Qradar, DSM). When set to ‘true`, only a single event will be sent per message. this feature is only available on certain topics (see [List Webhook Topics]($e/Constants%20Definitions/listWebhookTopics))

Returns:

  • (TrueClass | FalseClass)


93
94
95
# File 'lib/mist_api/models/webhook.rb', line 93

def single_event_per_message
  @single_event_per_message
end

#site_idUUID | String

Some solutions may not be able to parse multiple events from a single message (e.g. IBM Qradar, DSM). When set to ‘true`, only a single event will be sent per message. this feature is only available on certain topics (see [List Webhook Topics]($e/Constants%20Definitions/listWebhookTopics))

Returns:

  • (UUID | String)


100
101
102
# File 'lib/mist_api/models/webhook.rb', line 100

def site_id
  @site_id
end

#splunk_tokenString

Required if ‘type`=`splunk`. If splunk_token is not defined for a type Splunk webhook, it will not send, regardless if the webhook receiver is configured to accept it.

Returns:

  • (String)


106
107
108
# File 'lib/mist_api/models/webhook.rb', line 106

def splunk_token
  @splunk_token
end

#topicsArray[String]

List of supported webhook topics available with the API Call [List Webhook Topics]($e/Constants%20Definitions/listWebhookTopics)

Returns:

  • (Array[String])


111
112
113
# File 'lib/mist_api/models/webhook.rb', line 111

def topics
  @topics
end

#typeWebhookTypeEnum

enum: ‘aws-sns`, `google-pubsub`, `http-post`, `oauth2`, `splunk`

Returns:



115
116
117
# File 'lib/mist_api/models/webhook.rb', line 115

def type
  @type
end

#urlString

enum: ‘aws-sns`, `google-pubsub`, `http-post`, `oauth2`, `splunk`

Returns:

  • (String)


119
120
121
# File 'lib/mist_api/models/webhook.rb', line 119

def url
  @url
end

#verify_certTrueClass | FalseClass

When url uses HTTPS, whether to verify the certificate

Returns:

  • (TrueClass | FalseClass)


123
124
125
# File 'lib/mist_api/models/webhook.rb', line 123

def verify_cert
  @verify_cert
end

Class Method Details

.from_hash(hash) ⇒ Object

Creates an instance of the object from a hash.



237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
# File 'lib/mist_api/models/webhook.rb', line 237

def self.from_hash(hash)
  return nil unless hash

  # Extract variables from the hash.
  assetfilter_ids =
    hash.key?('assetfilter_ids') ? hash['assetfilter_ids'] : SKIP
  created_time = hash.key?('created_time') ? hash['created_time'] : SKIP
  enabled = hash['enabled'] ||= true
  for_site = hash.key?('for_site') ? hash['for_site'] : SKIP
  headers = hash.key?('headers') ? hash['headers'] : SKIP
  id = hash.key?('id') ? hash['id'] : SKIP
  modified_time = hash.key?('modified_time') ? hash['modified_time'] : SKIP
  name = hash.key?('name') ? hash['name'] : SKIP
  oauth2_client_id =
    hash.key?('oauth2_client_id') ? hash['oauth2_client_id'] : SKIP
  oauth2_client_secret =
    hash.key?('oauth2_client_secret') ? hash['oauth2_client_secret'] : SKIP
  oauth2_grant_type =
    hash.key?('oauth2_grant_type') ? hash['oauth2_grant_type'] : SKIP
  oauth2_password =
    hash.key?('oauth2_password') ? hash['oauth2_password'] : SKIP
  oauth2_scopes = hash.key?('oauth2_scopes') ? hash['oauth2_scopes'] : SKIP
  oauth2_token_url =
    hash.key?('oauth2_token_url') ? hash['oauth2_token_url'] : SKIP
  oauth2_username =
    hash.key?('oauth2_username') ? hash['oauth2_username'] : SKIP
  org_id = hash.key?('org_id') ? hash['org_id'] : SKIP
  secret = hash.key?('secret') ? hash['secret'] : SKIP
  single_event_per_message = hash['single_event_per_message'] ||= false
  site_id = hash.key?('site_id') ? hash['site_id'] : SKIP
  splunk_token = hash.key?('splunk_token') ? hash['splunk_token'] : SKIP
  topics = hash.key?('topics') ? hash['topics'] : SKIP
  type = hash['type'] ||= WebhookTypeEnum::HTTPPOST
  url = hash.key?('url') ? hash['url'] : SKIP
  verify_cert = hash['verify_cert'] ||= true

  # Create a new hash for additional properties, removing known properties.
  new_hash = hash.reject { |k, _| names.value?(k) }

  additional_properties = APIHelper.get_additional_properties(
    new_hash, proc { |value| value }
  )

  # Create object from extracted values.
  Webhook.new(assetfilter_ids,
              created_time,
              enabled,
              for_site,
              headers,
              id,
              modified_time,
              name,
              oauth2_client_id,
              oauth2_client_secret,
              oauth2_grant_type,
              oauth2_password,
              oauth2_scopes,
              oauth2_token_url,
              oauth2_username,
              org_id,
              secret,
              single_event_per_message,
              site_id,
              splunk_token,
              topics,
              type,
              url,
              verify_cert,
              additional_properties)
end

.namesObject

A mapping from model property names to API property names.



126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
# File 'lib/mist_api/models/webhook.rb', line 126

def self.names
  @_hash = {} if @_hash.nil?
  @_hash['assetfilter_ids'] = 'assetfilter_ids'
  @_hash['created_time'] = 'created_time'
  @_hash['enabled'] = 'enabled'
  @_hash['for_site'] = 'for_site'
  @_hash['headers'] = 'headers'
  @_hash['id'] = 'id'
  @_hash['modified_time'] = 'modified_time'
  @_hash['name'] = 'name'
  @_hash['oauth2_client_id'] = 'oauth2_client_id'
  @_hash['oauth2_client_secret'] = 'oauth2_client_secret'
  @_hash['oauth2_grant_type'] = 'oauth2_grant_type'
  @_hash['oauth2_password'] = 'oauth2_password'
  @_hash['oauth2_scopes'] = 'oauth2_scopes'
  @_hash['oauth2_token_url'] = 'oauth2_token_url'
  @_hash['oauth2_username'] = 'oauth2_username'
  @_hash['org_id'] = 'org_id'
  @_hash['secret'] = 'secret'
  @_hash['single_event_per_message'] = 'single_event_per_message'
  @_hash['site_id'] = 'site_id'
  @_hash['splunk_token'] = 'splunk_token'
  @_hash['topics'] = 'topics'
  @_hash['type'] = 'type'
  @_hash['url'] = 'url'
  @_hash['verify_cert'] = 'verify_cert'
  @_hash
end

.nullablesObject

An array for nullable fields



186
187
188
189
190
191
192
193
# File 'lib/mist_api/models/webhook.rb', line 186

def self.nullables
  %w[
    headers
    name
    secret
    splunk_token
  ]
end

.optionalsObject

An array for optional fields



156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
# File 'lib/mist_api/models/webhook.rb', line 156

def self.optionals
  %w[
    assetfilter_ids
    created_time
    enabled
    for_site
    headers
    id
    modified_time
    name
    oauth2_client_id
    oauth2_client_secret
    oauth2_grant_type
    oauth2_password
    oauth2_scopes
    oauth2_token_url
    oauth2_username
    org_id
    secret
    single_event_per_message
    site_id
    splunk_token
    topics
    type
    url
    verify_cert
  ]
end

Instance Method Details

#inspectObject

Provides a debugging-friendly string with detailed object information.



323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
# File 'lib/mist_api/models/webhook.rb', line 323

def inspect
  class_name = self.class.name.split('::').last
  "<#{class_name} assetfilter_ids: #{@assetfilter_ids.inspect}, created_time:"\
  " #{@created_time.inspect}, enabled: #{@enabled.inspect}, for_site: #{@for_site.inspect},"\
  " headers: #{@headers.inspect}, id: #{@id.inspect}, modified_time:"\
  " #{@modified_time.inspect}, name: #{@name.inspect}, oauth2_client_id:"\
  " #{@oauth2_client_id.inspect}, oauth2_client_secret: #{@oauth2_client_secret.inspect},"\
  " oauth2_grant_type: #{@oauth2_grant_type.inspect}, oauth2_password:"\
  " #{@oauth2_password.inspect}, oauth2_scopes: #{@oauth2_scopes.inspect}, oauth2_token_url:"\
  " #{@oauth2_token_url.inspect}, oauth2_username: #{@oauth2_username.inspect}, org_id:"\
  " #{@org_id.inspect}, secret: #{@secret.inspect}, single_event_per_message:"\
  " #{@single_event_per_message.inspect}, site_id: #{@site_id.inspect}, splunk_token:"\
  " #{@splunk_token.inspect}, topics: #{@topics.inspect}, type: #{@type.inspect}, url:"\
  " #{@url.inspect}, verify_cert: #{@verify_cert.inspect}, additional_properties:"\
  " #{@additional_properties}>"
end

#to_sObject

Provides a human-readable string representation of the object.



309
310
311
312
313
314
315
316
317
318
319
320
# File 'lib/mist_api/models/webhook.rb', line 309

def to_s
  class_name = self.class.name.split('::').last
  "<#{class_name} assetfilter_ids: #{@assetfilter_ids}, created_time: #{@created_time},"\
  " enabled: #{@enabled}, for_site: #{@for_site}, headers: #{@headers}, id: #{@id},"\
  " modified_time: #{@modified_time}, name: #{@name}, oauth2_client_id: #{@oauth2_client_id},"\
  " oauth2_client_secret: #{@oauth2_client_secret}, oauth2_grant_type: #{@oauth2_grant_type},"\
  " oauth2_password: #{@oauth2_password}, oauth2_scopes: #{@oauth2_scopes}, oauth2_token_url:"\
  " #{@oauth2_token_url}, oauth2_username: #{@oauth2_username}, org_id: #{@org_id}, secret:"\
  " #{@secret}, single_event_per_message: #{@single_event_per_message}, site_id: #{@site_id},"\
  " splunk_token: #{@splunk_token}, topics: #{@topics}, type: #{@type}, url: #{@url},"\
  " verify_cert: #{@verify_cert}, additional_properties: #{@additional_properties}>"
end