Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix event intake response #763

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
"spec_versions": {
"v1": {
"apigentools_version": "1.6.2",
"regenerated": "2022-02-18 09:34:49.437992",
"spec_repo_commit": "79cdf99"
"regenerated": "2022-02-22 15:54:20.178506",
"spec_repo_commit": "519d93a"
},
"v2": {
"apigentools_version": "1.6.2",
"regenerated": "2022-02-18 09:34:49.457366",
"spec_repo_commit": "79cdf99"
"regenerated": "2022-02-22 15:54:20.197077",
"spec_repo_commit": "519d93a"
}
}
}
69 changes: 3 additions & 66 deletions .generator/schemas/v1/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -1905,75 +1905,11 @@ components:
EventCreateResponse:
description: Object containing an event response.
properties:
alert_type:
$ref: '#/components/schemas/EventAlertType'
date_happened:
description: 'POSIX timestamp of the event. Must be sent as an integer (that
is no quotes).

Limited to events no older than 7 days.'
format: int64
type: integer
device_name:
description: A device name.
type: string
host:
description: 'Host name to associate with the event.

Any tags associated with the host are also applied to this event.'
type: string
id:
description: Integer ID of the event.
format: int64
readOnly: true
type: integer
payload:
description: Payload of the event.
example: '{}'
readOnly: true
type: string
priority:
$ref: '#/components/schemas/EventPriority'
related_event_id:
description: ID of the parent event. Must be sent as an integer (that is
no quotes).
format: int64
type: integer
source_type_name:
description: 'The type of event being posted. Option examples include nagios,
hudson, jenkins, my_apps, chef, puppet, git, bitbucket, etc.

A complete list of source attribute values [available here](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value).'
type: string
event:
$ref: '#/components/schemas/Event'
status:
description: A status.
type: string
tags:
description: A list of tags to apply to the event.
example:
- environment:test
items:
description: A tag.
type: string
type: array
text:
description: 'The body of the event. Limited to 4000 characters. The text
supports markdown.

Use `msg_text` with the Datadog Ruby library.'
example: Oh boy!
maxLength: 4000
type: string
title:
description: The event title. Limited to 100 characters. Use `msg_title`
with the Datadog Ruby library.
example: Did you hear the news today?
maxLength: 100
type: string
url:
description: URL of the event.
readOnly: true
type: string
type: object
EventListResponse:
description: An event list response.
Expand All @@ -1993,6 +1929,7 @@ components:
- normal
- low
example: normal
nullable: true
type: string
x-enum-varnames:
- NORMAL
Expand Down
1 change: 1 addition & 0 deletions features/v1/events.feature
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ Feature: Events
And body with value {"title": "{{ unique }}", "text": "A text message.", "tags": ["test:{{ unique_alnum }}"]}
When the request is sent
Then the response status is 202 OK
And the response "event.text" is equal to "A text message."

@team:DataDog/monitors-evaluation
Scenario: Post an event with a long title returns "OK" response
Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/v1/models/event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ def self.openapi_types
# @!visibility private
def self.openapi_nullable
Set.new([
:'priority',
])
end

Expand Down
1 change: 1 addition & 0 deletions lib/datadog_api_client/v1/models/event_create_request.rb
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ def self.openapi_types
# @!visibility private
def self.openapi_nullable
Set.new([
:'priority',
])
end

Expand Down
178 changes: 11 additions & 167 deletions lib/datadog_api_client/v1/models/event_create_response.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,72 +23,18 @@ class EventCreateResponse
# @!visibility private
attr_accessor :_unparsed

# If an alert event is enabled, set its type.
# For example, `error`, `warning`, `info`, `success`, `user_update`,
# `recommendation`, and `snapshot`.
attr_accessor :alert_type

# POSIX timestamp of the event. Must be sent as an integer (that is no quotes).
# Limited to events no older than 7 days.
attr_accessor :date_happened

# A device name.
attr_accessor :device_name

# Host name to associate with the event.
# Any tags associated with the host are also applied to this event.
attr_accessor :host

# Integer ID of the event.
attr_accessor :id

# Payload of the event.
attr_accessor :payload

# The priority of the event. For example, `normal` or `low`.
attr_accessor :priority

# ID of the parent event. Must be sent as an integer (that is no quotes).
attr_accessor :related_event_id

# The type of event being posted. Option examples include nagios, hudson, jenkins, my_apps, chef, puppet, git, bitbucket, etc.
# A complete list of source attribute values [available here](https://docs.datadoghq.com/integrations/faq/list-of-api-source-attribute-value).
attr_accessor :source_type_name
# Object representing an event.
attr_accessor :event

# A status.
attr_accessor :status

# A list of tags to apply to the event.
attr_accessor :tags

# The body of the event. Limited to 4000 characters. The text supports markdown.
# Use `msg_text` with the Datadog Ruby library.
attr_accessor :text

# The event title. Limited to 100 characters. Use `msg_title` with the Datadog Ruby library.
attr_accessor :title

# URL of the event.
attr_accessor :url

# Attribute mapping from ruby-style variable name to JSON key.
# @!visibility private
def self.attribute_map
{
:'alert_type' => :'alert_type',
:'date_happened' => :'date_happened',
:'device_name' => :'device_name',
:'host' => :'host',
:'id' => :'id',
:'payload' => :'payload',
:'priority' => :'priority',
:'related_event_id' => :'related_event_id',
:'source_type_name' => :'source_type_name',
:'status' => :'status',
:'tags' => :'tags',
:'text' => :'text',
:'title' => :'title',
:'url' => :'url'
:'event' => :'event',
:'status' => :'status'
}
end

Expand All @@ -102,20 +48,8 @@ def self.acceptable_attributes
# @!visibility private
def self.openapi_types
{
:'alert_type' => :'EventAlertType',
:'date_happened' => :'Integer',
:'device_name' => :'String',
:'host' => :'String',
:'id' => :'Integer',
:'payload' => :'String',
:'priority' => :'EventPriority',
:'related_event_id' => :'Integer',
:'source_type_name' => :'String',
:'status' => :'String',
:'tags' => :'Array<String>',
:'text' => :'String',
:'title' => :'String',
:'url' => :'String'
:'event' => :'Event',
:'status' => :'String'
}
end

Expand All @@ -142,128 +76,38 @@ def initialize(attributes = {})
h[k.to_sym] = v
}

if attributes.key?(:'alert_type')
self.alert_type = attributes[:'alert_type']
end

if attributes.key?(:'date_happened')
self.date_happened = attributes[:'date_happened']
end

if attributes.key?(:'device_name')
self.device_name = attributes[:'device_name']
end

if attributes.key?(:'host')
self.host = attributes[:'host']
end

if attributes.key?(:'id')
self.id = attributes[:'id']
end

if attributes.key?(:'payload')
self.payload = attributes[:'payload']
end

if attributes.key?(:'priority')
self.priority = attributes[:'priority']
end

if attributes.key?(:'related_event_id')
self.related_event_id = attributes[:'related_event_id']
end

if attributes.key?(:'source_type_name')
self.source_type_name = attributes[:'source_type_name']
if attributes.key?(:'event')
self.event = attributes[:'event']
end

if attributes.key?(:'status')
self.status = attributes[:'status']
end

if attributes.key?(:'tags')
if (value = attributes[:'tags']).is_a?(Array)
self.tags = value
end
end

if attributes.key?(:'text')
self.text = attributes[:'text']
end

if attributes.key?(:'title')
self.title = attributes[:'title']
end

if attributes.key?(:'url')
self.url = attributes[:'url']
end
end

# Show invalid properties with the reasons. Usually used together with valid?
# @return Array for valid properties with the reasons
# @!visibility private
def list_invalid_properties
invalid_properties = Array.new
if !@text.nil? && @text.to_s.length > 4000
invalid_properties.push('invalid value for "text", the character length must be smaller than or equal to 4000.')
end
if !@title.nil? && @title.to_s.length > 100
invalid_properties.push('invalid value for "title", the character length must be smaller than or equal to 100.')
end
invalid_properties
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 !@text.nil? && @text.to_s.length > 4000
return false if !@title.nil? && @title.to_s.length > 100
true
end

# Custom attribute writer method with validation
# @param text [Object] Object to be assigned
# @!visibility private
def text=(text)
if !text.nil? && text.to_s.length > 4000
fail ArgumentError, 'invalid value for "text", the character length must be smaller than or equal to 4000.'
end
@text = text
end

# Custom attribute writer method with validation
# @param title [Object] Object to be assigned
# @!visibility private
def title=(title)
if !title.nil? && title.to_s.length > 100
fail ArgumentError, 'invalid value for "title", the character length must be smaller than or equal to 100.'
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 &&
alert_type == o.alert_type &&
date_happened == o.date_happened &&
device_name == o.device_name &&
host == o.host &&
id == o.id &&
payload == o.payload &&
priority == o.priority &&
related_event_id == o.related_event_id &&
source_type_name == o.source_type_name &&
status == o.status &&
tags == o.tags &&
text == o.text &&
title == o.title &&
url == o.url
event == o.event &&
status == o.status
end

# @see the `==` method
Expand All @@ -277,7 +121,7 @@ def eql?(o)
# @return [Integer] Hash code
# @!visibility private
def hash
[alert_type, date_happened, device_name, host, id, payload, priority, related_event_id, source_type_name, status, tags, text, title, url].hash
[event, status].hash
end

# Builds the object from hash
Expand Down