Class: DatadogAPIClient::V1::ServiceLevelObjectivesAPI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ServiceLevelObjectivesAPI.



22
23
24
# File 'lib/datadog_api_client/v1/api/service_level_objectives_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/service_level_objectives_api.rb', line 20

def api_client
  @api_client
end

Instance Method Details

#check_can_delete_slo(ids, opts = {}) ⇒ Object

Check if SLOs can be safely deleted.



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

def check_can_delete_slo(ids, opts = {})
  data, _status_code, _headers = check_can_delete_slo_with_http_info(ids, opts)
  data
end

#check_can_delete_slo_with_http_info(ids, opts = {}) ⇒ Array<(CheckCanDeleteSLOResponse, Integer, Hash)>

Check if SLOs can be safely deleted.

Check if an SLO can be safely deleted. For example, assure an SLO can be deleted without disrupting a dashboard.

Parameters:

  • ids (String)

    A comma separated list of the IDs of the service level objectives objects.

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

    the optional parameters

Returns:

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

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

def check_can_delete_slo_with_http_info(ids, opts = {})

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

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

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

  # 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] || 'CheckCanDeleteSLOResponse'

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

  new_options = opts.merge(
    :operation => :check_can_delete_slo,
    :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: ServiceLevelObjectivesAPI#check_can_delete_slo\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Create an SLO object.



104
105
106
107
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 104

def create_slo(body, opts = {})
  data, _status_code, _headers = create_slo_with_http_info(body, opts)
  data
end

#create_slo_with_http_info(body, opts = {}) ⇒ Array<(SLOListResponse, Integer, Hash)>

Create an SLO object.

Create a service level objective object.

Parameters:

Returns:

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

    SLOListResponse data, response status code and response headers



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

def create_slo_with_http_info(body, opts = {})

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ServiceLevelObjectivesAPI.create_slo ...'
  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 ServiceLevelObjectivesAPI.create_slo"
  end
  # resource path
  local_var_path = '/api/v1/slo'

  # 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] || 'SLOListResponse'

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

  new_options = opts.merge(
    :operation => :create_slo,
    :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: ServiceLevelObjectivesAPI#create_slo\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_slo(slo_id, opts = {}) ⇒ Object

Delete an SLO.



180
181
182
183
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 180

def delete_slo(slo_id, opts = {})
  data, _status_code, _headers = delete_slo_with_http_info(slo_id, opts)
  data
end

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

Bulk Delete SLO Timeframes.



255
256
257
258
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 255

def delete_slo_timeframe_in_bulk(body, opts = {})
  data, _status_code, _headers = delete_slo_timeframe_in_bulk_with_http_info(body, opts)
  data
end

#delete_slo_timeframe_in_bulk_with_http_info(body, opts = {}) ⇒ Array<(SLOBulkDeleteResponse, Integer, Hash)>

Bulk Delete SLO Timeframes.

Delete (or partially delete) multiple service level objective objects.

This endpoint facilitates deletion of one or more thresholds for one or more service level objective objects. If all thresholds are deleted, the service level objective object is deleted as well.

Parameters:

  • body (Hash<String, Array<SLOTimeframe>>)

    Delete multiple service level objective objects request body.

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

    the optional parameters

Returns:

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

    SLOBulkDeleteResponse data, response status code and response headers



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
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 265

def delete_slo_timeframe_in_bulk_with_http_info(body, opts = {})

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ServiceLevelObjectivesAPI.delete_slo_timeframe_in_bulk ...'
  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 ServiceLevelObjectivesAPI.delete_slo_timeframe_in_bulk"
  end
  # resource path
  local_var_path = '/api/v1/slo/bulk_delete'

  # 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] || 'SLOBulkDeleteResponse'

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

  new_options = opts.merge(
    :operation => :delete_slo_timeframe_in_bulk,
    :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: ServiceLevelObjectivesAPI#delete_slo_timeframe_in_bulk\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_slo_with_http_info(slo_id, opts = {}) ⇒ Array<(SLODeleteResponse, Integer, Hash)>

Delete an SLO.

Permanently delete the specified service level objective object.

If an SLO is used in a dashboard, the DELETE /v1/slo/ endpoint returns a 409 conflict error because the SLO is referenced in a dashboard.

Parameters:

  • slo_id (String)

    The ID of the service level objective.

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

    the optional parameters

Options Hash (opts):

  • :force (String)

    Delete the monitor even if it's referenced by other resources (for example SLO, composite monitor).

Returns:

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

    SLODeleteResponse data, response status code and response headers



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

def delete_slo_with_http_info(slo_id, opts = {})

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

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

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'force'] = opts[:'force'] if !opts[:'force'].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] || 'SLODeleteResponse'

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

  new_options = opts.merge(
    :operation => :delete_slo,
    :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(:DELETE, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ServiceLevelObjectivesAPI#delete_slo\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_slo(slo_id, opts = {}) ⇒ Object

Get an SLO's details.



331
332
333
334
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 331

def get_slo(slo_id, opts = {})
  data, _status_code, _headers = get_slo_with_http_info(slo_id, opts)
  data
end

#get_slo_corrections(slo_id, opts = {}) ⇒ Object

Get Corrections For an SLO.



406
407
408
409
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 406

def get_slo_corrections(slo_id, opts = {})
  data, _status_code, _headers = get_slo_corrections_with_http_info(slo_id, opts)
  data
end

#get_slo_corrections_with_http_info(slo_id, opts = {}) ⇒ Array<(SLOCorrectionListResponse, Integer, Hash)>

Get Corrections For an SLO.

Get corrections applied to an SLO

Parameters:

  • slo_id (String)

    The ID of the service level objective object.

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

    the optional parameters

Returns:

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

    SLOCorrectionListResponse data, response status code and response headers



416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 416

def get_slo_corrections_with_http_info(slo_id, opts = {})

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ServiceLevelObjectivesAPI.get_slo_corrections ...'
  end
  # verify the required parameter 'slo_id' is set
  if @api_client.config.client_side_validation && slo_id.nil?
    fail ArgumentError, "Missing the required parameter 'slo_id' when calling ServiceLevelObjectivesAPI.get_slo_corrections"
  end
  # resource path
  local_var_path = '/api/v1/slo/{slo_id}/corrections'.sub('{' + 'slo_id' + '}', CGI.escape(slo_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] || 'SLOCorrectionListResponse'

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

  new_options = opts.merge(
    :operation => :get_slo_corrections,
    :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: ServiceLevelObjectivesAPI#get_slo_corrections\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_slo_history(slo_id, from_ts, to_ts, opts = {}) ⇒ Object

Get an SLO's history.



483
484
485
486
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 483

def get_slo_history(slo_id, from_ts, to_ts, opts = {})
  data, _status_code, _headers = get_slo_history_with_http_info(slo_id, from_ts, to_ts, opts)
  data
end

#get_slo_history_with_http_info(slo_id, from_ts, to_ts, opts = {}) ⇒ Array<(SLOHistoryResponse, Integer, Hash)>

Get an SLO's history.

Get a specific SLO’s history, regardless of its SLO type.

The detailed history data is structured according to the source data type. For example, metric data is included for event SLOs that use the metric source, and monitor SLO types include the monitor transition history.

Note: There are different response formats for event based and time based SLOs. Examples of both are shown.

Parameters:

  • slo_id (String)

    The ID of the service level objective object.

  • from_ts (Integer)

    The from timestamp for the query window in epoch seconds.

  • to_ts (Integer)

    The to timestamp for the query window in epoch seconds.

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

    the optional parameters

Options Hash (opts):

  • :target (Float)

    The SLO target. If target is passed in, the response will include the remaining error budget and a timeframe value of custom.

  • :apply_correction (Boolean)

    Defaults to true. If any SLO corrections are applied and this parameter is set to false, then the corrections will not be applied and the SLI values will not be affected.

Returns:

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

    SLOHistoryResponse data, response status code and response headers



497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 497

def get_slo_history_with_http_info(slo_id, from_ts, to_ts, opts = {})

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ServiceLevelObjectivesAPI.get_slo_history ...'
  end
  # verify the required parameter 'slo_id' is set
  if @api_client.config.client_side_validation && slo_id.nil?
    fail ArgumentError, "Missing the required parameter 'slo_id' when calling ServiceLevelObjectivesAPI.get_slo_history"
  end
  # verify the required parameter 'from_ts' is set
  if @api_client.config.client_side_validation && from_ts.nil?
    fail ArgumentError, "Missing the required parameter 'from_ts' when calling ServiceLevelObjectivesAPI.get_slo_history"
  end
  # verify the required parameter 'to_ts' is set
  if @api_client.config.client_side_validation && to_ts.nil?
    fail ArgumentError, "Missing the required parameter 'to_ts' when calling ServiceLevelObjectivesAPI.get_slo_history"
  end
  if @api_client.config.client_side_validation && !opts[:'target'].nil? && opts[:'target'] >= 100
    fail ArgumentError, 'invalid value for "opts[:"target"]" when calling ServiceLevelObjectivesAPI.get_slo_history, must be smaller than 100.'
  end

  if @api_client.config.client_side_validation && !opts[:'target'].nil? && opts[:'target'] <= 0
    fail ArgumentError, 'invalid value for "opts[:"target"]" when calling ServiceLevelObjectivesAPI.get_slo_history, must be greater than 0.'
  end

  # resource path
  local_var_path = '/api/v1/slo/{slo_id}/history'.sub('{' + 'slo_id' + '}', CGI.escape(slo_id.to_s))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'from_ts'] = from_ts
  query_params[:'to_ts'] = to_ts
  query_params[:'target'] = opts[:'target'] if !opts[:'target'].nil?
  query_params[:'apply_correction'] = opts[:'apply_correction'] if !opts[:'apply_correction'].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] || 'SLOHistoryResponse'

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

  new_options = opts.merge(
    :operation => :get_slo_history,
    :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: ServiceLevelObjectivesAPI#get_slo_history\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_slo_with_http_info(slo_id, opts = {}) ⇒ Array<(SLOResponse, Integer, Hash)>

Get an SLO's details.

Get a service level objective object.

Parameters:

  • slo_id (String)

    The ID of the service level objective object.

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

    the optional parameters

Options Hash (opts):

  • :with_configured_alert_ids (Boolean)

    Get the IDs of SLO monitors that reference this SLO.

Returns:

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

    SLOResponse data, response status code and response headers



342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 342

def get_slo_with_http_info(slo_id, opts = {})

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

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

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'with_configured_alert_ids'] = opts[:'with_configured_alert_ids'] if !opts[:'with_configured_alert_ids'].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] || 'SLOResponse'

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

  new_options = opts.merge(
    :operation => :get_slo,
    :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: ServiceLevelObjectivesAPI#get_slo\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_slos(opts = {}) ⇒ Object

Get all SLOs.



585
586
587
588
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 585

def list_slos(opts = {})
  data, _status_code, _headers = list_slos_with_http_info(opts)
  data
end

#list_slos_with_http_info(opts = {}) ⇒ Array<(SLOListResponse, Integer, Hash)>

Get all SLOs.

Get a list of service level objective objects for your organization.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :ids (String)

    A comma separated list of the IDs of the service level objectives objects.

  • :query (String)

    The query string to filter results based on SLO names.

  • :tags_query (String)

    The query string to filter results based on a single SLO tag.

  • :metrics_query (String)

    The query string to filter results based on SLO numerator and denominator.

  • :limit (Integer)

    The number of SLOs to return in the response.

  • :offset (Integer)

    The specific offset to use as the beginning of the returned response.

Returns:

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

    SLOListResponse data, response status code and response headers



600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 600

def list_slos_with_http_info(opts = {})

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ServiceLevelObjectivesAPI.list_slos ...'
  end
  # resource path
  local_var_path = '/api/v1/slo'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'ids'] = opts[:'ids'] if !opts[:'ids'].nil?
  query_params[:'query'] = opts[:'query'] if !opts[:'query'].nil?
  query_params[:'tags_query'] = opts[:'tags_query'] if !opts[:'tags_query'].nil?
  query_params[:'metrics_query'] = opts[:'metrics_query'] if !opts[:'metrics_query'].nil?
  query_params[:'limit'] = opts[:'limit'] if !opts[:'limit'].nil?
  query_params[:'offset'] = opts[:'offset'] if !opts[:'offset'].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] || 'SLOListResponse'

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

  new_options = opts.merge(
    :operation => :list_slos,
    :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: ServiceLevelObjectivesAPI#list_slos\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_slos_with_pagination(opts = {}) {|ServiceLevelObjective| ... } ⇒ Object

Get all SLOs.

Provide a paginated version of #list_slos, returning all items.

To use it you need to use a block: list_slos_with_pagination { |item| p item }

Yields:



606
607
608
609
610
611
612
613
614
615
616
617
618
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 606

def list_slos_with_pagination(opts = {})
    api_version = "V1"
    page_size = @api_client.get_attribute_from_path(opts, "limit", 1000)
    @api_client.set_attribute_from_path(api_version, opts, "limit", Integer, page_size)
    while true do
        response = list_slos(opts)
        @api_client.get_attribute_from_path(response, "data").each { |item| yield(item) }
        if @api_client.get_attribute_from_path(response, "data").length < page_size
          break
        end
        @api_client.set_attribute_from_path(api_version, opts, "offset", Integer, @api_client.get_attribute_from_path(opts, "offset", 0) + page_size)
    end
end

#search_slo(opts = {}) ⇒ Object

Search for SLOs.



623
624
625
626
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 623

def search_slo(opts = {})
  data, _status_code, _headers = search_slo_with_http_info(opts)
  data
end

#search_slo_with_http_info(opts = {}) ⇒ Array<(SearchSLOResponse, Integer, Hash)>

Search for SLOs.

Get a list of service level objective objects for your organization.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :query (String)

    The query string to filter results based on SLO names. Some examples of queries include service:<service-name> and <slo-name>.

  • :page_size (Integer)

    The number of files to return in the response [default=10].

  • :page_number (Integer)

    The identifier of the first page to return. This parameter is used for the pagination feature [default=0].

  • :include_facets (Boolean)

    Whether or not to return facet information in the response [default=false].

Returns:

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

    SearchSLOResponse data, response status code and response headers



638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 638

def search_slo_with_http_info(opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ServiceLevelObjectivesAPI.search_slo ...'
  end
  # resource path
  local_var_path = '/api/v1/slo/search'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'query'] = opts[:'query'] if !opts[:'query'].nil?
  query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  query_params[:'page[number]'] = opts[:'page_number'] if !opts[:'page_number'].nil?
  query_params[:'include_facets'] = opts[:'include_facets'] if !opts[:'include_facets'].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] || 'SearchSLOResponse'

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

  new_options = opts.merge(
    :operation => :search_slo,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type,
    :api_version => "V1"
  )

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

#update_slo(slo_id, body, opts = {}) ⇒ Object

Update an SLO.



666
667
668
669
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 666

def update_slo(slo_id, body, opts = {})
  data, _status_code, _headers = update_slo_with_http_info(slo_id, body, opts)
  data
end

#update_slo_with_http_info(slo_id, body, opts = {}) ⇒ Array<(SLOListResponse, Integer, Hash)>

Update an SLO.

Update the specified service level objective object.

Parameters:

  • slo_id (String)

    The ID of the service level objective object.

  • body (ServiceLevelObjective)

    The edited service level objective request object.

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

    the optional parameters

Returns:

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

    SLOListResponse data, response status code and response headers



677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 677

def update_slo_with_http_info(slo_id, body, opts = {})

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ServiceLevelObjectivesAPI.update_slo ...'
  end
  # verify the required parameter 'slo_id' is set
  if @api_client.config.client_side_validation && slo_id.nil?
    fail ArgumentError, "Missing the required parameter 'slo_id' when calling ServiceLevelObjectivesAPI.update_slo"
  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 ServiceLevelObjectivesAPI.update_slo"
  end
  # resource path
  local_var_path = '/api/v1/slo/{slo_id}'.sub('{' + 'slo_id' + '}', CGI.escape(slo_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'])
  # 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] || 'SLOListResponse'

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

  new_options = opts.merge(
    :operation => :update_slo,
    :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(:PUT, local_var_path, new_options)
  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: ServiceLevelObjectivesAPI#update_slo\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end