Class: DatadogAPIClient::V2::ServiceScorecardsAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/datadog_api_client/v2/api/service_scorecards_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of ServiceScorecardsAPI.



22
23
24
# File 'lib/datadog_api_client/v2/api/service_scorecards_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/v2/api/service_scorecards_api.rb', line 20

def api_client
  @api_client
end

Instance Method Details

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

Create outcomes batch.



29
30
31
32
# File 'lib/datadog_api_client/v2/api/service_scorecards_api.rb', line 29

def create_scorecard_outcomes_batch(body, opts = {})
  data, _status_code, _headers = create_scorecard_outcomes_batch_with_http_info(body, opts)
  data
end

#create_scorecard_outcomes_batch_with_http_info(body, opts = {}) ⇒ Array<(OutcomesBatchResponse, Integer, Hash)>

Create outcomes batch.

Sets multiple service-rule outcomes in a single batched request.

Parameters:

  • body (OutcomesBatchRequest)

    Set of scorecard outcomes.

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

    the optional parameters

Returns:

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

    OutcomesBatchResponse data, response status code and response headers



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/v2/api/service_scorecards_api.rb', line 41

def create_scorecard_outcomes_batch_with_http_info(body, opts = {})
  unstable_enabled = @api_client.config.unstable_operations["v2.create_scorecard_outcomes_batch".to_sym]
  if unstable_enabled
    @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.create_scorecard_outcomes_batch")
  else
    raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.create_scorecard_outcomes_batch"))
  end

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ServiceScorecardsAPI.create_scorecard_outcomes_batch ...'
  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 ServiceScorecardsAPI.create_scorecard_outcomes_batch"
  end
  # resource path
  local_var_path = '/api/v2/scorecard/outcomes/batch'

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

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

  new_options = opts.merge(
    :operation => :create_scorecard_outcomes_batch,
    :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 => "V2"
  )

  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: ServiceScorecardsAPI#create_scorecard_outcomes_batch\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

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

Create a new rule.



102
103
104
105
# File 'lib/datadog_api_client/v2/api/service_scorecards_api.rb', line 102

def create_scorecard_rule(body, opts = {})
  data, _status_code, _headers = create_scorecard_rule_with_http_info(body, opts)
  data
end

#create_scorecard_rule_with_http_info(body, opts = {}) ⇒ Array<(CreateRuleResponse, Integer, Hash)>

Create a new rule.

Creates a new rule.

Parameters:

  • body (CreateRuleRequest)

    Rule attributes.

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

    the optional parameters

Returns:

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

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

def create_scorecard_rule_with_http_info(body, opts = {})
  unstable_enabled = @api_client.config.unstable_operations["v2.create_scorecard_rule".to_sym]
  if unstable_enabled
    @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.create_scorecard_rule")
  else
    raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.create_scorecard_rule"))
  end

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ServiceScorecardsAPI.create_scorecard_rule ...'
  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 ServiceScorecardsAPI.create_scorecard_rule"
  end
  # resource path
  local_var_path = '/api/v2/scorecard/rules'

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

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

  new_options = opts.merge(
    :operation => :create_scorecard_rule,
    :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 => "V2"
  )

  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: ServiceScorecardsAPI#create_scorecard_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#delete_scorecard_rule(rule_id, opts = {}) ⇒ Object

Delete a rule.



175
176
177
178
# File 'lib/datadog_api_client/v2/api/service_scorecards_api.rb', line 175

def delete_scorecard_rule(rule_id, opts = {})
  delete_scorecard_rule_with_http_info(rule_id, opts)
  nil
end

#delete_scorecard_rule_with_http_info(rule_id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete a rule.

Deletes a single rule.

Parameters:

  • rule_id (String)

    The ID of the rule/scorecard.

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
# File 'lib/datadog_api_client/v2/api/service_scorecards_api.rb', line 187

def delete_scorecard_rule_with_http_info(rule_id, opts = {})
  unstable_enabled = @api_client.config.unstable_operations["v2.delete_scorecard_rule".to_sym]
  if unstable_enabled
    @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.delete_scorecard_rule")
  else
    raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.delete_scorecard_rule"))
  end

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ServiceScorecardsAPI.delete_scorecard_rule ...'
  end
  # verify the required parameter 'rule_id' is set
  if @api_client.config.client_side_validation && rule_id.nil?
    fail ArgumentError, "Missing the required parameter 'rule_id' when calling ServiceScorecardsAPI.delete_scorecard_rule"
  end
  # resource path
  local_var_path = '/api/v2/scorecard/rules/{rule_id}'.sub('{rule_id}', CGI.escape(rule_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(['*/*'])

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

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

  # return_type
  return_type = opts[:debug_return_type]

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

  new_options = opts.merge(
    :operation => :delete_scorecard_rule,
    :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 => "V2"
  )

  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: ServiceScorecardsAPI#delete_scorecard_rule\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_scorecard_outcomes(opts = {}) ⇒ Object

List all rule outcomes.



246
247
248
249
# File 'lib/datadog_api_client/v2/api/service_scorecards_api.rb', line 246

def list_scorecard_outcomes(opts = {})
  data, _status_code, _headers = list_scorecard_outcomes_with_http_info(opts)
  data
end

#list_scorecard_outcomes_with_http_info(opts = {}) ⇒ Array<(OutcomesResponse, Integer, Hash)>

List all rule outcomes.

Fetches all rule outcomes.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :page_size (Integer)

    Size for a given page. The maximum allowed value is 100.

  • :page_offset (Integer)

    Specific offset to use as the beginning of the returned page.

  • :include (String)

    Include related rule details in the response.

  • :fields_outcome (String)

    Return only specified values in the outcome attributes.

  • :fields_rule (String)

    Return only specified values in the included rule details.

  • :filter_outcome_service_name (String)

    Filter the outcomes on a specific service name.

  • :filter_outcome_state (String)

    Filter the outcomes by a specific state.

  • :filter_rule_enabled (Boolean)

    Filter outcomes on whether a rule is enabled/disabled.

  • :filter_rule_id (String)

    Filter outcomes based on rule ID.

  • :filter_rule_name (String)

    Filter outcomes based on rule name.

Returns:

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

    OutcomesResponse data, response status code and response headers



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
324
325
326
327
# File 'lib/datadog_api_client/v2/api/service_scorecards_api.rb', line 267

def list_scorecard_outcomes_with_http_info(opts = {})
  unstable_enabled = @api_client.config.unstable_operations["v2.list_scorecard_outcomes".to_sym]
  if unstable_enabled
    @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.list_scorecard_outcomes")
  else
    raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.list_scorecard_outcomes"))
  end

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ServiceScorecardsAPI.list_scorecard_outcomes ...'
  end
  # resource path
  local_var_path = '/api/v2/scorecard/outcomes'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  query_params[:'page[offset]'] = opts[:'page_offset'] if !opts[:'page_offset'].nil?
  query_params[:'include'] = opts[:'include'] if !opts[:'include'].nil?
  query_params[:'fields[outcome]'] = opts[:'fields_outcome'] if !opts[:'fields_outcome'].nil?
  query_params[:'fields[rule]'] = opts[:'fields_rule'] if !opts[:'fields_rule'].nil?
  query_params[:'filter[outcome][service_name]'] = opts[:'filter_outcome_service_name'] if !opts[:'filter_outcome_service_name'].nil?
  query_params[:'filter[outcome][state]'] = opts[:'filter_outcome_state'] if !opts[:'filter_outcome_state'].nil?
  query_params[:'filter[rule][enabled]'] = opts[:'filter_rule_enabled'] if !opts[:'filter_rule_enabled'].nil?
  query_params[:'filter[rule][id]'] = opts[:'filter_rule_id'] if !opts[:'filter_rule_id'].nil?
  query_params[:'filter[rule][name]'] = opts[:'filter_rule_name'] if !opts[:'filter_rule_name'].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] || 'OutcomesResponse'

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

  new_options = opts.merge(
    :operation => :list_scorecard_outcomes,
    :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 => "V2"
  )

  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: ServiceScorecardsAPI#list_scorecard_outcomes\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_scorecard_outcomes_with_pagination(opts = {}) {|OutcomesResponseDataItem| ... } ⇒ Object

List all rule outcomes.

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

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

Yields:



336
337
338
339
340
341
342
343
344
345
346
347
348
# File 'lib/datadog_api_client/v2/api/service_scorecards_api.rb', line 336

def list_scorecard_outcomes_with_pagination(opts = {})
    api_version = "V2"
    page_size = @api_client.get_attribute_from_path(opts, "page_size", 10)
    @api_client.set_attribute_from_path(api_version, opts, "page_size", Integer, page_size)
    while true do
        response = list_scorecard_outcomes(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, "page_offset", Integer, @api_client.get_attribute_from_path(opts, "page_offset", 0) + page_size)
    end
end

#list_scorecard_rules(opts = {}) ⇒ Object

List all rules.



353
354
355
356
# File 'lib/datadog_api_client/v2/api/service_scorecards_api.rb', line 353

def list_scorecard_rules(opts = {})
  data, _status_code, _headers = list_scorecard_rules_with_http_info(opts)
  data
end

#list_scorecard_rules_with_http_info(opts = {}) ⇒ Array<(ListRulesResponse, Integer, Hash)>

List all rules.

Fetch all rules.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :page_size (Integer)

    Size for a given page. The maximum allowed value is 100.

  • :page_offset (Integer)

    Specific offset to use as the beginning of the returned page.

  • :include (String)

    Include related scorecard details in the response.

  • :filter_rule_id (String)

    Filter the rules on a rule ID.

  • :filter_rule_enabled (Boolean)

    Filter for enabled rules only.

  • :filter_rule_custom (Boolean)

    Filter for custom rules only.

  • :filter_rule_name (String)

    Filter rules on the rule name.

  • :filter_rule_description (String)

    Filter rules on the rule description.

  • :fields_rule (String)

    Return only specific fields in the response for rule attributes.

  • :fields_scorecard (String)

    Return only specific fields in the included response for scorecard attributes.

Returns:

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

    ListRulesResponse data, response status code and response headers



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
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
432
433
434
# File 'lib/datadog_api_client/v2/api/service_scorecards_api.rb', line 374

def list_scorecard_rules_with_http_info(opts = {})
  unstable_enabled = @api_client.config.unstable_operations["v2.list_scorecard_rules".to_sym]
  if unstable_enabled
    @api_client.config.logger.warn format("Using unstable operation '%s'", "v2.list_scorecard_rules")
  else
    raise DatadogAPIClient::APIError.new(message: format("Unstable operation '%s' is disabled", "v2.list_scorecard_rules"))
  end

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: ServiceScorecardsAPI.list_scorecard_rules ...'
  end
  # resource path
  local_var_path = '/api/v2/scorecard/rules'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'page[size]'] = opts[:'page_size'] if !opts[:'page_size'].nil?
  query_params[:'page[offset]'] = opts[:'page_offset'] if !opts[:'page_offset'].nil?
  query_params[:'include'] = opts[:'include'] if !opts[:'include'].nil?
  query_params[:'filter[rule][id]'] = opts[:'filter_rule_id'] if !opts[:'filter_rule_id'].nil?
  query_params[:'filter[rule][enabled]'] = opts[:'filter_rule_enabled'] if !opts[:'filter_rule_enabled'].nil?
  query_params[:'filter[rule][custom]'] = opts[:'filter_rule_custom'] if !opts[:'filter_rule_custom'].nil?
  query_params[:'filter[rule][name]'] = opts[:'filter_rule_name'] if !opts[:'filter_rule_name'].nil?
  query_params[:'filter[rule][description]'] = opts[:'filter_rule_description'] if !opts[:'filter_rule_description'].nil?
  query_params[:'fields[rule]'] = opts[:'fields_rule'] if !opts[:'fields_rule'].nil?
  query_params[:'fields[scorecard]'] = opts[:'fields_scorecard'] if !opts[:'fields_scorecard'].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] || 'ListRulesResponse'

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

  new_options = opts.merge(
    :operation => :list_scorecard_rules,
    :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 => "V2"
  )

  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: ServiceScorecardsAPI#list_scorecard_rules\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#list_scorecard_rules_with_pagination(opts = {}) {|ListRulesResponseDataItem| ... } ⇒ Object

List all rules.

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

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

Yields:



443
444
445
446
447
448
449
450
451
452
453
454
455
# File 'lib/datadog_api_client/v2/api/service_scorecards_api.rb', line 443

def list_scorecard_rules_with_pagination(opts = {})
    api_version = "V2"
    page_size = @api_client.get_attribute_from_path(opts, "page_size", 10)
    @api_client.set_attribute_from_path(api_version, opts, "page_size", Integer, page_size)
    while true do
        response = list_scorecard_rules(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, "page_offset", Integer, @api_client.get_attribute_from_path(opts, "page_offset", 0) + page_size)
    end
end