Class: DatadogAPIClient::V1::EventsAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog_api_client/v1/api/events_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = DatadogAPIClient::APIClient.default) ⇒ EventsAPI

Returns a new instance of EventsAPI.



22
23
24
# File 'lib/datadog_api_client/v1/api/events_api.rb', line 22

def initialize(api_client = APIClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



20
21
22
# File 'lib/datadog_api_client/v1/api/events_api.rb', line 20

def api_client
  @api_client
end

Instance Method Details

#create_event(body, opts = {}) ⇒ Object

Post an event.



30
31
32
33
# File 'lib/datadog_api_client/v1/api/events_api.rb', line 30

def create_event(body, opts = {})
  data, _status_code, _headers = create_event_with_http_info(body, opts)
  data
end

#create_event_with_http_info(body, opts = {}) ⇒ Array<(EventCreateResponse, Integer, Hash)>

Post an event.

This endpoint allows you to post events to the stream. Tag them, set priority and event aggregate them with other events.

Parameters:

  • body (EventCreateRequest)

    Event request object

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(EventCreateResponse, Integer, Hash)>)

    EventCreateResponse data, response status code and response headers



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
# File 'lib/datadog_api_client/v1/api/events_api.rb', line 40

def create_event_with_http_info(body, opts = {})

  if @api_client.config.unstable_operations.has_key?(:create_event)
    unstable_enabled = @api_client.config.unstable_operations[:create_event]
    if unstable_enabled
      @api_client.config.logger.warn format("Using unstable operation '%s'", "create_event")
    else
      raise APIError.new(message: format("Unstable operation '%s' is disabled", "create_event"))
    end
  end

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EventsAPI.create_event ...'
  end
  # verify the required parameter 'body' is set
  if @api_client.config.client_side_validation && body.nil?
    fail ArgumentError, "Missing the required parameter 'body' when calling EventsAPI.create_event"
  end
  # resource path
  local_var_path = '/api/v1/events'

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])
  # HTTP header 'Content-Type'
  header_params['Content-Type'] = @api_client.select_header_content_type(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body] || @api_client.object_to_http_body(body)

  # return_type
  return_type = opts[:debug_return_type] || 'EventCreateResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:apiKeyAuth]

  new_options = opts.merge(
    :operation => :create_event,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:POST, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: EventsAPI#create_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_event(event_id, opts = {}) ⇒ Object

Get an event.



105
106
107
108
# File 'lib/datadog_api_client/v1/api/events_api.rb', line 105

def get_event(event_id, opts = {})
  data, _status_code, _headers = get_event_with_http_info(event_id, opts)
  data
end

#get_event_with_http_info(event_id, opts = {}) ⇒ Array<(EventResponse, Integer, Hash)>

Get an event.

This endpoint allows you to query for event details.

Note: If the event you’re querying contains markdown formatting of any kind, you may see characters such as %,\,n in your output.

Parameters:

  • event_id (Integer)

    The ID of the event.

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(EventResponse, Integer, Hash)>)

    EventResponse data, response status code and response headers



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
# File 'lib/datadog_api_client/v1/api/events_api.rb', line 115

def get_event_with_http_info(event_id, opts = {})

  if @api_client.config.unstable_operations.has_key?(:get_event)
    unstable_enabled = @api_client.config.unstable_operations[:get_event]
    if unstable_enabled
      @api_client.config.logger.warn format("Using unstable operation '%s'", "get_event")
    else
      raise APIError.new(message: format("Unstable operation '%s' is disabled", "get_event"))
    end
  end

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EventsAPI.get_event ...'
  end
  # verify the required parameter 'event_id' is set
  if @api_client.config.client_side_validation && event_id.nil?
    fail ArgumentError, "Missing the required parameter 'event_id' when calling EventsAPI.get_event"
  end
  # resource path
  local_var_path = '/api/v1/events/{event_id}'.sub('{' + 'event_id' + '}', CGI.escape(event_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'EventResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:AuthZ, :apiKeyAuth, :appKeyAuth]

  new_options = opts.merge(
    :operation => :get_event,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: EventsAPI#get_event\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_events(start, _end, opts = {}) ⇒ Object

Get a list of events.



185
186
187
188
# File 'lib/datadog_api_client/v1/api/events_api.rb', line 185

def list_events(start, _end, opts = {})
  data, _status_code, _headers = list_events_with_http_info(start, _end, opts)
  data
end

#list_events_with_http_info(start, _end, opts = {}) ⇒ Array<(EventListResponse, Integer, Hash)>

Get a list of events.

The event stream can be queried and filtered by time, priority, sources and tags.

Notes:

  • If the event you’re querying contains markdown formatting of any kind, you may see characters such as %,\,n in your output.

  • This endpoint returns a maximum of 1000 most recent results. To return additional results, identify the last timestamp of the last result and set that as the end query time to paginate the results. You can also use the page parameter to specify which set of 1000 results to return.

Parameters:

  • start (Integer)

    POSIX timestamp.

  • _end (Integer)

    POSIX timestamp.

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :priority (EventPriority)

    Priority of your events, either low or normal.

  • :sources (String)

    A comma separated string of sources.

  • :tags (String)

    A comma separated list indicating what tags, if any, should be used to filter the list of events.

  • :unaggregated (Boolean)

    Set unaggregated to true to return all events within the specified [start,end] timeframe. Otherwise if an event is aggregated to a parent event with a timestamp outside of the timeframe, it won't be available in the output. Aggregated events with is_aggregate=true in the response will still be returned unless exclude_aggregate is set to true.

  • :exclude_aggregate (Boolean)

    Set exclude_aggregate to true to only return unaggregated events where is_aggregate=false in the response. If the exclude_aggregate parameter is set to true, then the unaggregated parameter is ignored and will be true by default.

  • :page (Integer)

    By default 1000 results are returned per request. Set page to the number of the page to return with 0 being the first page. The page parameter can only be used when either unaggregated or exclude_aggregate is set to true.

Returns:

  • (Array<(EventListResponse, Integer, Hash)>)

    EventListResponse data, response status code and response headers



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
274
# File 'lib/datadog_api_client/v1/api/events_api.rb', line 202

def list_events_with_http_info(start, _end, opts = {})

  if @api_client.config.unstable_operations.has_key?(:list_events)
    unstable_enabled = @api_client.config.unstable_operations[:list_events]
    if unstable_enabled
      @api_client.config.logger.warn format("Using unstable operation '%s'", "list_events")
    else
      raise APIError.new(message: format("Unstable operation '%s' is disabled", "list_events"))
    end
  end

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: EventsAPI.list_events ...'
  end
  # verify the required parameter 'start' is set
  if @api_client.config.client_side_validation && start.nil?
    fail ArgumentError, "Missing the required parameter 'start' when calling EventsAPI.list_events"
  end
  # verify the required parameter '_end' is set
  if @api_client.config.client_side_validation && _end.nil?
    fail ArgumentError, "Missing the required parameter '_end' when calling EventsAPI.list_events"
  end
  if @api_client.config.client_side_validation && !opts[:'page'].nil? && opts[:'page'] > 2147483647
    fail ArgumentError, 'invalid value for "opts[:"page"]" when calling EventsAPI.list_events, must be smaller than or equal to 2147483647.'
  end

  # resource path
  local_var_path = '/api/v1/events'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start'] = start
  query_params[:'end'] = _end
  query_params[:'priority'] = opts[:'priority'] if !opts[:'priority'].nil?
  query_params[:'sources'] = opts[:'sources'] if !opts[:'sources'].nil?
  query_params[:'tags'] = opts[:'tags'] if !opts[:'tags'].nil?
  query_params[:'unaggregated'] = opts[:'unaggregated'] if !opts[:'unaggregated'].nil?
  query_params[:'exclude_aggregate'] = opts[:'exclude_aggregate'] if !opts[:'exclude_aggregate'].nil?
  query_params[:'page'] = opts[:'page'] if !opts[:'page'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:debug_body]

  # return_type
  return_type = opts[:debug_return_type] || 'EventListResponse'

  # auth_names
  auth_names = opts[:debug_auth_names] || [:AuthZ, :apiKeyAuth, :appKeyAuth]

  new_options = opts.merge(
    :operation => :list_events,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type
  )

  data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: EventsAPI#list_events\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end