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 = DatadogAPIClient::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.



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

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



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

def check_can_delete_slo_with_http_info(ids, opts = {})

  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, :AuthZ]

  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,
    :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#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.



96
97
98
99
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 96

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



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

def create_slo_with_http_info(body, opts = {})

  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, :AuthZ]

  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,
    :api_version => "V1"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::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.



163
164
165
166
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 163

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.



233
234
235
236
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 233

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



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

def delete_slo_timeframe_in_bulk_with_http_info(body, opts = {})

  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, :AuthZ]

  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,
    :api_version => "V1"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::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



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

def delete_slo_with_http_info(slo_id, opts = {})

  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).gsub('%2F', '/'))

  # 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, :AuthZ]

  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,
    :api_version => "V1"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::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.



304
305
306
307
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 304

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.



371
372
373
374
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 371

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



383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 383

def get_slo_corrections_with_http_info(slo_id, opts = {})

  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).gsub('%2F', '/'))

  # 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] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

  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,
    :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#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.



436
437
438
439
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 436

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



459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
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
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 459

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

  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 or equal to 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 or equal to 0.'
  end
  # resource path
  local_var_path = '/api/v1/slo/{slo_id}/history'.sub('{slo_id}', CGI.escape(slo_id.to_s).gsub('%2F', '/'))

  # 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] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

  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,
    :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#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



317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
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
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 317

def get_slo_with_http_info(slo_id, opts = {})

  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).gsub('%2F', '/'))

  # 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] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

  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,
    :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#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.



530
531
532
533
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 530

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



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
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 547

def list_slos_with_http_info(opts = {})

  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] || [:apiKeyAuth, :appKeyAuth, :AuthZ]

  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,
    :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#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.



691
692
693
694
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 691

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



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
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
# File 'lib/datadog_api_client/v1/api/service_level_objectives_api.rb', line 704

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

  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).gsub('%2F', '/'))

  # 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, :AuthZ]

  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,
    :api_version => "V1"
  )

  data, status_code, headers = @api_client.call_api(Net::HTTP::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