-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathevent_payload.rb
More file actions
273 lines (235 loc) · 9.67 KB
/
Copy pathevent_payload.rb
File metadata and controls
273 lines (235 loc) · 9.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
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
154
155
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
184
185
186
187
188
189
190
191
192
193
194
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
235
236
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
=begin
#Datadog API V2 Collection
#Collection of all Datadog Public endpoints.
The version of the OpenAPI document: 1.0
Contact: support@datadoghq.com
Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator
Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
This product includes software developed at Datadog (https://www.datadoghq.com/).
Copyright 2020-Present Datadog, Inc.
=end
require 'date'
require 'time'
module DatadogAPIClient::V2
# Event attributes.
class EventPayload
include BaseGenericModel
# A string used for aggregation when [correlating](https://docs.datadoghq.com/service_management/events/correlation/) events. If you specify a key, events are deduplicated to alerts based on this key. Limited to 100 characters.
attr_reader :aggregation_key
# JSON object for category-specific attributes. Schema is different per event category.
attr_reader :attributes
# Event category identifying the type of event.
attr_reader :category
# Host name to associate with the event. Any tags associated with the host are also applied to this event. Limited to 255 characters.
attr_reader :host
# Integration ID sourced from integration manifests.
attr_accessor :integration_id
# Free formed text associated with the event. It's suggested to use `data.attributes.attributes.custom` for well-structured attributes. Limited to 4000 characters.
attr_reader :message
# A list of tags associated with the event. Maximum of 100 tags allowed.
# Refer to [Tags docs](https://docs.datadoghq.com/getting_started/tagging/).
attr_reader :tags
# Timestamp when the event occurred. Must follow [ISO 8601](https://www.iso.org/iso-8601-date-and-time-format.html) format.
# For example `"2017-01-15T01:30:15.010000Z"`.
# Defaults to the timestamp of receipt. Limited to values no older than 18 hours.
attr_accessor :timestamp
# The title of the event. Limited to 500 characters.
attr_reader :title
# Attribute mapping from ruby-style variable name to JSON key.
# @!visibility private
def self.attribute_map
{
:'aggregation_key' => :'aggregation_key',
:'attributes' => :'attributes',
:'category' => :'category',
:'host' => :'host',
:'integration_id' => :'integration_id',
:'message' => :'message',
:'tags' => :'tags',
:'timestamp' => :'timestamp',
:'title' => :'title'
}
end
# Attribute type mapping.
# @!visibility private
def self.openapi_types
{
:'aggregation_key' => :'String',
:'attributes' => :'EventPayloadAttributes',
:'category' => :'EventCategory',
:'host' => :'String',
:'integration_id' => :'EventPayloadIntegrationId',
:'message' => :'String',
:'tags' => :'Array<String>',
:'timestamp' => :'String',
:'title' => :'String'
}
end
# Initializes the object
# @param attributes [Hash] Model attributes in the form of hash
# @!visibility private
def initialize(attributes = {})
if (!attributes.is_a?(Hash))
fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::EventPayload` initialize method"
end
# check to see if the attribute exists and convert string to symbol for hash key
attributes = attributes.each_with_object({}) { |(k, v), h|
if (!self.class.attribute_map.key?(k.to_sym))
fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V2::EventPayload`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect
end
h[k.to_sym] = v
}
if attributes.key?(:'aggregation_key')
self.aggregation_key = attributes[:'aggregation_key']
end
if attributes.key?(:'attributes')
self.attributes = attributes[:'attributes']
end
if attributes.key?(:'category')
self.category = attributes[:'category']
end
if attributes.key?(:'host')
self.host = attributes[:'host']
end
if attributes.key?(:'integration_id')
self.integration_id = attributes[:'integration_id']
end
if attributes.key?(:'message')
self.message = attributes[:'message']
end
if attributes.key?(:'tags')
if (value = attributes[:'tags']).is_a?(Array)
self.tags = value
end
end
if attributes.key?(:'timestamp')
self.timestamp = attributes[:'timestamp']
end
if attributes.key?(:'title')
self.title = attributes[:'title']
end
end
# Check to see if the all the properties in the model are valid
# @return true if the model is valid
# @!visibility private
def valid?
return false if !@aggregation_key.nil? && @aggregation_key.to_s.length > 100
return false if !@aggregation_key.nil? && @aggregation_key.to_s.length < 1
return false if @attributes.nil?
return false if @category.nil?
return false if !@host.nil? && @host.to_s.length > 255
return false if !@host.nil? && @host.to_s.length < 1
return false if !@message.nil? && @message.to_s.length > 4000
return false if !@message.nil? && @message.to_s.length < 1
return false if !@tags.nil? && @tags.length > 100
return false if !@tags.nil? && @tags.length < 1
return false if @title.nil?
return false if @title.to_s.length > 500
return false if @title.to_s.length < 1
true
end
# Custom attribute writer method with validation
# @param aggregation_key [Object] Object to be assigned
# @!visibility private
def aggregation_key=(aggregation_key)
if !aggregation_key.nil? && aggregation_key.to_s.length > 100
fail ArgumentError, 'invalid value for "aggregation_key", the character length must be smaller than or equal to 100.'
end
if !aggregation_key.nil? && aggregation_key.to_s.length < 1
fail ArgumentError, 'invalid value for "aggregation_key", the character length must be great than or equal to 1.'
end
@aggregation_key = aggregation_key
end
# Custom attribute writer method with validation
# @param attributes [Object] Object to be assigned
# @!visibility private
def attributes=(attributes)
if attributes.nil?
fail ArgumentError, 'invalid value for "attributes", attributes cannot be nil.'
end
@attributes = attributes
end
# Custom attribute writer method with validation
# @param category [Object] Object to be assigned
# @!visibility private
def category=(category)
if category.nil?
fail ArgumentError, 'invalid value for "category", category cannot be nil.'
end
@category = category
end
# Custom attribute writer method with validation
# @param host [Object] Object to be assigned
# @!visibility private
def host=(host)
if !host.nil? && host.to_s.length > 255
fail ArgumentError, 'invalid value for "host", the character length must be smaller than or equal to 255.'
end
if !host.nil? && host.to_s.length < 1
fail ArgumentError, 'invalid value for "host", the character length must be great than or equal to 1.'
end
@host = host
end
# Custom attribute writer method with validation
# @param message [Object] Object to be assigned
# @!visibility private
def message=(message)
if !message.nil? && message.to_s.length > 4000
fail ArgumentError, 'invalid value for "message", the character length must be smaller than or equal to 4000.'
end
if !message.nil? && message.to_s.length < 1
fail ArgumentError, 'invalid value for "message", the character length must be great than or equal to 1.'
end
@message = message
end
# Custom attribute writer method with validation
# @param tags [Object] Object to be assigned
# @!visibility private
def tags=(tags)
if !tags.nil? && tags.length > 100
fail ArgumentError, 'invalid value for "tags", number of items must be less than or equal to 100.'
end
if !tags.nil? && tags.length < 1
fail ArgumentError, 'invalid value for "tags", number of items must be greater than or equal to 1.'
end
@tags = tags
end
# Custom attribute writer method with validation
# @param title [Object] Object to be assigned
# @!visibility private
def title=(title)
if title.nil?
fail ArgumentError, 'invalid value for "title", title cannot be nil.'
end
if title.to_s.length > 500
fail ArgumentError, 'invalid value for "title", the character length must be smaller than or equal to 500.'
end
if title.to_s.length < 1
fail ArgumentError, 'invalid value for "title", the character length must be great than or equal to 1.'
end
@title = title
end
# Checks equality by comparing each attribute.
# @param o [Object] Object to be compared
# @!visibility private
def ==(o)
return true if self.equal?(o)
self.class == o.class &&
aggregation_key == o.aggregation_key &&
attributes == o.attributes &&
category == o.category &&
host == o.host &&
integration_id == o.integration_id &&
message == o.message &&
tags == o.tags &&
timestamp == o.timestamp &&
title == o.title
end
# Calculates hash code according to all attributes.
# @return [Integer] Hash code
# @!visibility private
def hash
[aggregation_key, attributes, category, host, integration_id, message, tags, timestamp, title].hash
end
end
end