Class: DatadogAPIClient::V2::UsageMeteringAPI

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of UsageMeteringAPI.



22
23
24
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 22

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

Instance Attribute Details

#api_client ⇒ Object

Returns the value of attribute api_client.



20
21
22
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 20

def api_client
  @api_client
end

Instance Method Details

#create_quotas(quota_namespace, body, opts = {}) ⇒ Object

Create or update usage quotas.



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

def create_quotas(quota_namespace, body, opts = {})
  data, _status_code, _headers = create_quotas_with_http_info(quota_namespace, body, opts)
  data
end

#create_quotas_with_http_info(quota_namespace, body, opts = {}) ⇒ Array<(UsageQuotasBulkResponse, Integer, Hash)>

Create or update usage quotas.

Creates or updates one or more usage quotas by scope. If a quota already exists for a supplied scope, it is updated; otherwise, a new quota is created. Requires the billing_edit permission.

Parameters:

  • quota_namespace (String) —

    The product-specific namespace whose usage quotas are being managed.

  • body (UsageQuotasCreateRequest) —

    The usage quotas to create or update.

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

    the optional parameters

Options Hash (opts):

  • :include_descendants (Boolean) —

    Whether to write every item in the request to the caller's organization and all of its descendant organizations, instead of only the caller's organization. Only descendants in the same datacenter are supported. For a user-handle scope, the quota is applied only to the caller's organization and to descendant organizations where that user handle exists; the item fails only if the handle exists in none of them.

Returns:

  • (Array<(UsageQuotasBulkResponse, Integer, Hash)>) —

    UsageQuotasBulkResponse data, response status code and response headers



43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 43

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.create_quotas ...'
  end
  # verify the required parameter 'quota_namespace' is set
  if @api_client.config.client_side_validation && quota_namespace.nil?
    fail ArgumentError, "Missing the required parameter 'quota_namespace' when calling UsageMeteringAPI.create_quotas"
  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 UsageMeteringAPI.create_quotas"
  end
  # resource path
  local_var_path = '/api/v2/usage/quotas/{quota_namespace}'.sub('{quota_namespace}', CGI.escape(quota_namespace.to_s).gsub('%2F', '/'))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'include_descendants'] = opts[:'include_descendants'] if !opts[:'include_descendants'].nil?

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

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

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

#delete_quota(quota_namespace, id, opts = {}) ⇒ Object

Delete a usage quota.



109
110
111
112
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 109

def delete_quota(quota_namespace, id, opts = {})
  delete_quota_with_http_info(quota_namespace, id, opts)
  nil
end

#delete_quota_with_http_info(quota_namespace, id, opts = {}) ⇒ Array<(nil, Integer, Hash)>

Delete a usage quota.

Deletes a usage quota by its opaque identifier. The quota must belong to the caller's organization or one of its descendants, and its opaque identifier must belong to the requested quota namespace. Requires the billing_edit permission.

Parameters:

  • quota_namespace (String) —

    The product-specific namespace whose usage quotas are being managed.

  • id (String) —

    The opaque quota identifier returned by a previous list or create request. Clients must pass this value verbatim.

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

    the optional parameters

Returns:

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

    nil, response status code and response headers



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
173
174
175
176
177
178
179
180
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 122

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.delete_quota ...'
  end
  # verify the required parameter 'quota_namespace' is set
  if @api_client.config.client_side_validation && quota_namespace.nil?
    fail ArgumentError, "Missing the required parameter 'quota_namespace' when calling UsageMeteringAPI.delete_quota"
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling UsageMeteringAPI.delete_quota"
  end
  # resource path
  local_var_path = '/api/v2/usage/quotas/{quota_namespace}/{id}'.sub('{quota_namespace}', CGI.escape(quota_namespace.to_s).gsub('%2F', '/')).sub('{id}', CGI.escape(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_quota,
    :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: UsageMeteringAPI#delete_quota\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_active_billing_dimensions(opts = {}) ⇒ Object

Get active billing dimensions for cost attribution.



185
186
187
188
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 185

def get_active_billing_dimensions(opts = {})
  data, _status_code, _headers = get_active_billing_dimensions_with_http_info(opts)
  data
end

#get_active_billing_dimensions_with_http_info(opts = {}) ⇒ Array<(ActiveBillingDimensionsResponse, Integer, Hash)>

Get active billing dimensions for cost attribution.

Get active billing dimensions for cost attribution. Cost data for a given month becomes available no later than the 19th of the following month.

Parameters:

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

    the optional parameters

Returns:



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

def get_active_billing_dimensions_with_http_info(opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_active_billing_dimensions ...'
  end
  # resource path
  local_var_path = '/api/v2/cost_by_tag/active_billing_dimensions'

  # 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;datetime-format=rfc3339'])

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

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

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

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

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

#get_billing_dimension_mapping(opts = {}) ⇒ Object

Get billing dimension mapping for usage endpoints.



245
246
247
248
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 245

def get_billing_dimension_mapping(opts = {})
  data, _status_code, _headers = get_billing_dimension_mapping_with_http_info(opts)
  data
end

#get_billing_dimension_mapping_with_http_info(opts = {}) ⇒ Array<(BillingDimensionsMappingResponse, Integer, Hash)>

Get billing dimension mapping for usage endpoints.

Get a mapping of billing dimensions to the corresponding keys for the supported usage metering public API endpoints. Mapping data is updated on a monthly cadence.

This endpoint is only accessible to parent-level organizations.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :filter_month (Time) —

    Datetime in ISO-8601 format, UTC, and for mappings beginning this month. Defaults to the current month.

  • :filter_view (String) —

    String to specify whether to retrieve active billing dimension mappings for the contract or for all available mappings. Allowed views have the string active or all. Defaults to active.

Returns:



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
300
301
302
303
304
305
306
307
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 261

def get_billing_dimension_mapping_with_http_info(opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_billing_dimension_mapping ...'
  end
  # resource path
  local_var_path = '/api/v2/usage/billing_dimension_mapping'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'filter[month]'] = opts[:'filter_month'] if !opts[:'filter_month'].nil?
  query_params[:'filter[view]'] = opts[:'filter_view'] if !opts[:'filter_view'].nil?

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

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

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

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

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

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

#get_cost_by_org(start_month, opts = {}) ⇒ Object

Get cost across multi-org account.



312
313
314
315
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 312

def get_cost_by_org(start_month, opts = {})
  data, _status_code, _headers = get_cost_by_org_with_http_info(start_month, opts)
  data
end

#get_cost_by_org_with_http_info(start_month, opts = {}) ⇒ Array<(CostByOrgResponse, Integer, Hash)>

Deprecated.

This API is deprecated.

Get cost across multi-org account.

Get cost across multi-org account. Cost by org data for a given month becomes available no later than the 16th of the following month. Note: This endpoint has been deprecated. Please use the new endpoint /historical_cost instead.

This endpoint is only accessible for parent-level organizations.

Parameters:

  • start_month (Time) —

    Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for cost beginning this month.

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

    the optional parameters

Options Hash (opts):

  • :end_month (Time) —

    Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for cost ending this month.

Returns:

  • (Array<(CostByOrgResponse, Integer, Hash)>) —

    CostByOrgResponse data, response status code and response headers



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
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 333

def get_cost_by_org_with_http_info(start_month, opts = {})
  warn "[DEPRECATION] `GetCostByOrg` is deprecated."

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_cost_by_org ...'
  end
  # verify the required parameter 'start_month' is set
  if @api_client.config.client_side_validation && start_month.nil?
    fail ArgumentError, "Missing the required parameter 'start_month' when calling UsageMeteringAPI.get_cost_by_org"
  end
  # resource path
  local_var_path = '/api/v2/usage/cost_by_org'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_month'] = start_month
  query_params[:'end_month'] = opts[:'end_month'] if !opts[:'end_month'].nil?

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

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

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

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

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

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

#get_estimated_cost_by_org(opts = {}) ⇒ Object

Get estimated cost across your account.



389
390
391
392
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 389

def get_estimated_cost_by_org(opts = {})
  data, _status_code, _headers = get_estimated_cost_by_org_with_http_info(opts)
  data
end

#get_estimated_cost_by_org_with_http_info(opts = {}) ⇒ Array<(CostByOrgResponse, Integer, Hash)>

Get estimated cost across your account.

Get estimated cost across multi-org and single root-org accounts. Estimated cost data is only available for the current month and previous month and is delayed by up to 72 hours from when it was incurred. To access historical costs prior to this, use the /historical_cost endpoint.

This endpoint is only accessible for parent-level organizations.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :view (String) —

    String to specify whether cost is broken down at a parent-org level or at the sub-org level. Available views are summary and sub-org. Defaults to summary.

  • :start_month (Time) —

    Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for cost beginning this month. Either start_month or start_date should be specified, but not both. (start_month cannot go beyond two months in the past). Provide an end_month to view month-over-month cost.

  • :end_month (Time) —

    Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for cost ending this month.

  • :start_date (Time) —

    Datetime in ISO-8601 format, UTC, precise to day: [YYYY-MM-DD] for cost beginning this day. Either start_month or start_date should be specified, but not both. (start_date cannot go beyond two months in the past). Provide an end_date to view day-over-day cumulative cost.

  • :end_date (Time) —

    Datetime in ISO-8601 format, UTC, precise to day: [YYYY-MM-DD] for cost ending this day.

  • :cost_aggregation (CostAggregationType) —

    Controls how costs are aggregated when using start_date. The cumulative option returns month-to-date running totals.

  • :include_connected_accounts (Boolean) —

    Boolean to specify whether to include accounts connected to the current account as partner customers in the Datadog partner network program. Defaults to false.

Returns:

  • (Array<(CostByOrgResponse, Integer, Hash)>) —

    CostByOrgResponse data, response status code and response headers



412
413
414
415
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
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 412

def get_estimated_cost_by_org_with_http_info(opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_estimated_cost_by_org ...'
  end
  allowable_values = ['cumulative']
  if @api_client.config.client_side_validation && opts[:'cost_aggregation'] && !allowable_values.include?(opts[:'cost_aggregation'])
    fail ArgumentError, "invalid value for \"cost_aggregation\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/v2/usage/estimated_cost'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'view'] = opts[:'view'] if !opts[:'view'].nil?
  query_params[:'start_month'] = opts[:'start_month'] if !opts[:'start_month'].nil?
  query_params[:'end_month'] = opts[:'end_month'] if !opts[:'end_month'].nil?
  query_params[:'start_date'] = opts[:'start_date'] if !opts[:'start_date'].nil?
  query_params[:'end_date'] = opts[:'end_date'] if !opts[:'end_date'].nil?
  query_params[:'cost_aggregation'] = opts[:'cost_aggregation'] if !opts[:'cost_aggregation'].nil?
  query_params[:'include_connected_accounts'] = opts[:'include_connected_accounts'] if !opts[:'include_connected_accounts'].nil?

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

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

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

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

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

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

#get_historical_cost_by_org(start_month, opts = {}) ⇒ Object

Get historical cost across your account.



472
473
474
475
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 472

def get_historical_cost_by_org(start_month, opts = {})
  data, _status_code, _headers = get_historical_cost_by_org_with_http_info(start_month, opts)
  data
end

#get_historical_cost_by_org_with_http_info(start_month, opts = {}) ⇒ Array<(CostByOrgResponse, Integer, Hash)>

Get historical cost across your account.

Get historical cost across multi-org and single root-org accounts. Cost data for a given month becomes available no later than the 16th of the following month.

This endpoint is only accessible for parent-level organizations.

Parameters:

  • start_month (Time) —

    Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for cost beginning this month.

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

    the optional parameters

Options Hash (opts):

  • :view (String) —

    String to specify whether cost is broken down at a parent-org level or at the sub-org level. Available views are summary and sub-org. Defaults to summary.

  • :end_month (Time) —

    Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for cost ending this month.

  • :include_connected_accounts (Boolean) —

    Boolean to specify whether to include accounts connected to the current account as partner customers in the Datadog partner network program. Defaults to false.

Returns:

  • (Array<(CostByOrgResponse, Integer, Hash)>) —

    CostByOrgResponse data, response status code and response headers



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
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 490

def get_historical_cost_by_org_with_http_info(start_month, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_historical_cost_by_org ...'
  end
  # verify the required parameter 'start_month' is set
  if @api_client.config.client_side_validation && start_month.nil?
    fail ArgumentError, "Missing the required parameter 'start_month' when calling UsageMeteringAPI.get_historical_cost_by_org"
  end
  # resource path
  local_var_path = '/api/v2/usage/historical_cost'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_month'] = start_month
  query_params[:'view'] = opts[:'view'] if !opts[:'view'].nil?
  query_params[:'end_month'] = opts[:'end_month'] if !opts[:'end_month'].nil?
  query_params[:'include_connected_accounts'] = opts[:'include_connected_accounts'] if !opts[:'include_connected_accounts'].nil?

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

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

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

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

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

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

#get_hourly_usage(filter_timestamp_start, filter_product_families, opts = {}) ⇒ Object

Get hourly usage by product family.



547
548
549
550
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 547

def get_hourly_usage(filter_timestamp_start, filter_product_families, opts = {})
  data, _status_code, _headers = get_hourly_usage_with_http_info(filter_timestamp_start, filter_product_families, opts)
  data
end

#get_hourly_usage_with_http_info(filter_timestamp_start, filter_product_families, opts = {}) ⇒ Array<(HourlyUsageResponse, Integer, Hash)>

Get hourly usage by product family.

Get hourly usage by product family.

Parameters:

  • filter_timestamp_start (Time) —

    Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

  • filter_product_families (String) —

    Comma separated list of product families to retrieve. Available families are all, ai, analyzed_logs, application_performance_monitoring, application_security, audit_trail, bits_ai, serverless, ci_app, cloud_cost_management, cloud_siem, csm_container_enterprise, csm_host_enterprise, csm_host_pro, cspm, custom_events, cws, data_observability, dbm, digital_experience_management, error_tracking, fargate, infra_hosts, incident_management, indexed_logs, indexed_spans, infrastructure_monitoring, ingested_spans, iot, lambda_traced_invocations, llm_observability, log_management, logs, network_flows, network_hosts, network_monitoring, observability_pipelines, online_archive, platform_capabilities, product_analytics, profiling, rum, rum_browser_sessions, rum_mobile_sessions, sds, security, snmp, software_delivery, synthetics_api, synthetics_browser, synthetics_mobile, synthetics_parallel_testing, timeseries, vuln_management and workflow_executions. The following product family has been deprecated: audit_logs.

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

    the optional parameters

Options Hash (opts):

  • :filter_timestamp_end (Time) —

    Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

  • :filter_include_descendants (Boolean) —

    Include child org usage in the response. Defaults to false.

  • :filter_include_connected_accounts (Boolean) —

    Boolean to specify whether to include accounts connected to the current account as partner customers in the Datadog partner network program. Defaults to false.

  • :filter_include_breakdown (Boolean) —

    Include breakdown of usage by subcategories where applicable (for product family logs only). Defaults to false.

  • :filter_versions (String) —

    Comma separated list of product family versions to use in the format product_family:version. For example, infra_hosts:1.0.0. If this parameter is not used, the API will use the latest version of each requested product family. Currently all families have one version 1.0.0.

  • :page_limit (Integer) —

    Maximum number of results to return (between 1 and 500) - defaults to 500 if limit not specified.

  • :page_next_record_id (String) —

    List following results with a next_record_id provided in the previous query.

Returns:

  • (Array<(HourlyUsageResponse, Integer, Hash)>) —

    HourlyUsageResponse data, response status code and response headers



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
598
599
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
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 567

def get_hourly_usage_with_http_info(filter_timestamp_start, filter_product_families, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_hourly_usage ...'
  end
  # verify the required parameter 'filter_timestamp_start' is set
  if @api_client.config.client_side_validation && filter_timestamp_start.nil?
    fail ArgumentError, "Missing the required parameter 'filter_timestamp_start' when calling UsageMeteringAPI.get_hourly_usage"
  end
  # verify the required parameter 'filter_product_families' is set
  if @api_client.config.client_side_validation && filter_product_families.nil?
    fail ArgumentError, "Missing the required parameter 'filter_product_families' when calling UsageMeteringAPI.get_hourly_usage"
  end
  if @api_client.config.client_side_validation && !opts[:'page_limit'].nil? && opts[:'page_limit'] > 500
    fail ArgumentError, 'invalid value for "opts[:"page_limit"]" when calling UsageMeteringAPI.get_hourly_usage, must be smaller than or equal to 500.'
  end
  if @api_client.config.client_side_validation && !opts[:'page_limit'].nil? && opts[:'page_limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page_limit"]" when calling UsageMeteringAPI.get_hourly_usage, must be greater than or equal to 1.'
  end
  # resource path
  local_var_path = '/api/v2/usage/hourly_usage'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'filter[timestamp][start]'] = filter_timestamp_start
  query_params[:'filter[product_families]'] = filter_product_families
  query_params[:'filter[timestamp][end]'] = opts[:'filter_timestamp_end'] if !opts[:'filter_timestamp_end'].nil?
  query_params[:'filter[include_descendants]'] = opts[:'filter_include_descendants'] if !opts[:'filter_include_descendants'].nil?
  query_params[:'filter[include_connected_accounts]'] = opts[:'filter_include_connected_accounts'] if !opts[:'filter_include_connected_accounts'].nil?
  query_params[:'filter[include_breakdown]'] = opts[:'filter_include_breakdown'] if !opts[:'filter_include_breakdown'].nil?
  query_params[:'filter[versions]'] = opts[:'filter_versions'] if !opts[:'filter_versions'].nil?
  query_params[:'page[limit]'] = opts[:'page_limit'] if !opts[:'page_limit'].nil?
  query_params[:'page[next_record_id]'] = opts[:'page_next_record_id'] if !opts[:'page_next_record_id'].nil?

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

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

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

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

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

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

#get_monthly_cost_attribution(start_month, fields, opts = {}) ⇒ Object

Get Monthly Cost Attribution.



639
640
641
642
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 639

def get_monthly_cost_attribution(start_month, fields, opts = {})
  data, _status_code, _headers = get_monthly_cost_attribution_with_http_info(start_month, fields, opts)
  data
end

#get_monthly_cost_attribution_with_http_info(start_month, fields, opts = {}) ⇒ Array<(MonthlyCostAttributionResponse, Integer, Hash)>

Get Monthly Cost Attribution.

Get monthly cost attribution by tag across multi-org and single root-org accounts. Cost Attribution data for a given month becomes available no later than the 19th of the following month. This API endpoint is paginated. To make sure you receive all records, check if the value of next_record_id is set in the response. If it is, make another request and pass next_record_id as a parameter. Pseudo code example:

response := GetMonthlyCostAttribution(start_month, end_month)
cursor := response.metadata.pagination.next_record_id
WHILE cursor != null BEGIN
  sleep(5 seconds)  # Avoid running into rate limit
  response := GetMonthlyCostAttribution(start_month, end_month, next_record_id=cursor)
  cursor := response.metadata.pagination.next_record_id
END

This endpoint is only accessible for parent-level organizations. This endpoint is not available in the Government (US1-FED) site.

Parameters:

  • start_month (Time) —

    Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for cost beginning in this month.

  • fields (String) —

    Comma-separated list specifying cost types (e.g., <billing_dimension>_on_demand_cost, <billing_dimension>_committed_cost, <billing_dimension>_total_cost) and the proportions (<billing_dimension>_percentage_in_org, <billing_dimension>_percentage_in_account). Use * to retrieve all fields. Example: infra_host_on_demand_cost,infra_host_percentage_in_account To obtain the complete list of active billing dimensions that can be used to replace <billing_dimension> in the field names, make a request to the Get active billing dimensions API.

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

    the optional parameters

Options Hash (opts):

  • :end_month (Time) —

    Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM] for cost ending this month.

  • :sort_direction (SortDirection) —

    The direction to sort by: [desc, asc].

  • :sort_name (String) —

    The billing dimension to sort by. Always sorted by total cost. Example: infra_host.

  • :tag_breakdown_keys (String) —

    Comma separated list of tag keys used to group cost. If no value is provided the cost will not be broken down by tags. To see which tags are available, look for the value of tag_config_source in the API response.

  • :next_record_id (String) —

    List following results with a next_record_id provided in the previous query.

  • :include_descendants (Boolean) —

    Include child org cost in the response. Defaults to true.

Returns:



673
674
675
676
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
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 673

def get_monthly_cost_attribution_with_http_info(start_month, fields, opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_monthly_cost_attribution ...'
  end
  # verify the required parameter 'start_month' is set
  if @api_client.config.client_side_validation && start_month.nil?
    fail ArgumentError, "Missing the required parameter 'start_month' when calling UsageMeteringAPI.get_monthly_cost_attribution"
  end
  # verify the required parameter 'fields' is set
  if @api_client.config.client_side_validation && fields.nil?
    fail ArgumentError, "Missing the required parameter 'fields' when calling UsageMeteringAPI.get_monthly_cost_attribution"
  end
  allowable_values = ['desc', 'asc']
  if @api_client.config.client_side_validation && opts[:'sort_direction'] && !allowable_values.include?(opts[:'sort_direction'])
    fail ArgumentError, "invalid value for \"sort_direction\", must be one of #{allowable_values}"
  end
  # resource path
  local_var_path = '/api/v2/cost_by_tag/monthly_cost_attribution'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_month'] = start_month
  query_params[:'fields'] = fields
  query_params[:'end_month'] = opts[:'end_month'] if !opts[:'end_month'].nil?
  query_params[:'sort_direction'] = opts[:'sort_direction'] if !opts[:'sort_direction'].nil?
  query_params[:'sort_name'] = opts[:'sort_name'] if !opts[:'sort_name'].nil?
  query_params[:'tag_breakdown_keys'] = opts[:'tag_breakdown_keys'] if !opts[:'tag_breakdown_keys'].nil?
  query_params[:'next_record_id'] = opts[:'next_record_id'] if !opts[:'next_record_id'].nil?
  query_params[:'include_descendants'] = opts[:'include_descendants'] if !opts[:'include_descendants'].nil?

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

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

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

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

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

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

#get_projected_cost(opts = {}) ⇒ Object

Get projected cost across your account.



742
743
744
745
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 742

def get_projected_cost(opts = {})
  data, _status_code, _headers = get_projected_cost_with_http_info(opts)
  data
end

#get_projected_cost_with_http_info(opts = {}) ⇒ Array<(ProjectedCostResponse, Integer, Hash)>

Get projected cost across your account.

Get projected cost across multi-org and single root-org accounts. Projected cost data is only available for the current month and becomes available around the 12th of the month.

This endpoint is only accessible for parent-level organizations.

Parameters:

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

    the optional parameters

Options Hash (opts):

  • :view (String) —

    String to specify whether cost is broken down at a parent-org level or at the sub-org level. Available views are summary and sub-org. Defaults to summary.

  • :include_connected_accounts (Boolean) —

    Boolean to specify whether to include accounts connected to the current account as partner customers in the Datadog partner network program. Defaults to false.

Returns:

  • (Array<(ProjectedCostResponse, Integer, Hash)>) —

    ProjectedCostResponse data, response status code and response headers



758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 758

def get_projected_cost_with_http_info(opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_projected_cost ...'
  end
  # resource path
  local_var_path = '/api/v2/usage/projected_cost'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'view'] = opts[:'view'] if !opts[:'view'].nil?
  query_params[:'include_connected_accounts'] = opts[:'include_connected_accounts'] if !opts[:'include_connected_accounts'].nil?

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

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

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

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

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

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

#get_usage_application_security_monitoring(start_hr, opts = {}) ⇒ Object

Get hourly usage for application security.



809
810
811
812
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 809

def get_usage_application_security_monitoring(start_hr, opts = {})
  data, _status_code, _headers = get_usage_application_security_monitoring_with_http_info(start_hr, opts)
  data
end

#get_usage_application_security_monitoring_with_http_info(start_hr, opts = {}) ⇒ Array<(UsageApplicationSecurityMonitoringResponse, Integer, Hash)>

Deprecated.

This API is deprecated.

Get hourly usage for application security.

Get hourly usage for application security . Note: This endpoint has been deprecated. Hourly usage data for all products is now available in the Get hourly usage by product family API

Parameters:

  • start_hr (Time) —

    Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

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

    the optional parameters

Options Hash (opts):

  • :end_hr (Time) —

    Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Returns:



825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 825

def get_usage_application_security_monitoring_with_http_info(start_hr, opts = {})
  warn "[DEPRECATION] `GetUsageApplicationSecurityMonitoring` is deprecated."

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_usage_application_security_monitoring ...'
  end
  # verify the required parameter 'start_hr' is set
  if @api_client.config.client_side_validation && start_hr.nil?
    fail ArgumentError, "Missing the required parameter 'start_hr' when calling UsageMeteringAPI.get_usage_application_security_monitoring"
  end
  # resource path
  local_var_path = '/api/v2/usage/application_security'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_hr'] = start_hr
  query_params[:'end_hr'] = opts[:'end_hr'] if !opts[:'end_hr'].nil?

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

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

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

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

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

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

#get_usage_attribution_types(opts = {}) ⇒ Object

Get usage attribution types.



881
882
883
884
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 881

def get_usage_attribution_types(opts = {})
  data, _status_code, _headers = get_usage_attribution_types_with_http_info(opts)
  data
end

#get_usage_attribution_types_with_http_info(opts = {}) ⇒ Array<(UsageAttributionTypesResponse, Integer, Hash)>

Get usage attribution types.

Get usage attribution types.

Parameters:

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

    the optional parameters

Returns:



892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 892

def get_usage_attribution_types_with_http_info(opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_usage_attribution_types ...'
  end
  # resource path
  local_var_path = '/api/v2/usage/usage-attribution-types'

  # 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;datetime-format=rfc3339'])

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

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

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

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

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

#get_usage_lambda_traced_invocations(start_hr, opts = {}) ⇒ Object

Get hourly usage for Lambda traced invocations.



941
942
943
944
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 941

def get_usage_lambda_traced_invocations(start_hr, opts = {})
  data, _status_code, _headers = get_usage_lambda_traced_invocations_with_http_info(start_hr, opts)
  data
end

#get_usage_lambda_traced_invocations_with_http_info(start_hr, opts = {}) ⇒ Array<(UsageLambdaTracedInvocationsResponse, Integer, Hash)>

Deprecated.

This API is deprecated.

Get hourly usage for Lambda traced invocations.

Get hourly usage for Lambda traced invocations. Note: This endpoint has been deprecated.. Hourly usage data for all products is now available in the Get hourly usage by product family API

Parameters:

  • start_hr (Time) —

    Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

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

    the optional parameters

Options Hash (opts):

  • :end_hr (Time) —

    Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Returns:



957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 957

def get_usage_lambda_traced_invocations_with_http_info(start_hr, opts = {})
  warn "[DEPRECATION] `GetUsageLambdaTracedInvocations` is deprecated."

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_usage_lambda_traced_invocations ...'
  end
  # verify the required parameter 'start_hr' is set
  if @api_client.config.client_side_validation && start_hr.nil?
    fail ArgumentError, "Missing the required parameter 'start_hr' when calling UsageMeteringAPI.get_usage_lambda_traced_invocations"
  end
  # resource path
  local_var_path = '/api/v2/usage/lambda_traced_invocations'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_hr'] = start_hr
  query_params[:'end_hr'] = opts[:'end_hr'] if !opts[:'end_hr'].nil?

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

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

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

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

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

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

#get_usage_observability_pipelines(start_hr, opts = {}) ⇒ Object

Get hourly usage for observability pipelines.



1013
1014
1015
1016
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 1013

def get_usage_observability_pipelines(start_hr, opts = {})
  data, _status_code, _headers = get_usage_observability_pipelines_with_http_info(start_hr, opts)
  data
end

#get_usage_observability_pipelines_with_http_info(start_hr, opts = {}) ⇒ Array<(UsageObservabilityPipelinesResponse, Integer, Hash)>

Deprecated.

This API is deprecated.

Get hourly usage for observability pipelines.

Get hourly usage for observability pipelines. Note: This endpoint has been deprecated. Hourly usage data for all products is now available in the Get hourly usage by product family API

Parameters:

  • start_hr (Time) —

    Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour.

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

    the optional parameters

Options Hash (opts):

  • :end_hr (Time) —

    Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending before this hour.

Returns:



1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 1029

def get_usage_observability_pipelines_with_http_info(start_hr, opts = {})
  warn "[DEPRECATION] `GetUsageObservabilityPipelines` is deprecated."

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_usage_observability_pipelines ...'
  end
  # verify the required parameter 'start_hr' is set
  if @api_client.config.client_side_validation && start_hr.nil?
    fail ArgumentError, "Missing the required parameter 'start_hr' when calling UsageMeteringAPI.get_usage_observability_pipelines"
  end
  # resource path
  local_var_path = '/api/v2/usage/observability_pipelines'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'start_hr'] = start_hr
  query_params[:'end_hr'] = opts[:'end_hr'] if !opts[:'end_hr'].nil?

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

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

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

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

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

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

#get_usage_summary_available_fields(opts = {}) ⇒ Object

Get available fields for usage summary.



1085
1086
1087
1088
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 1085

def get_usage_summary_available_fields(opts = {})
  data, _status_code, _headers = get_usage_summary_available_fields_with_http_info(opts)
  data
end

#get_usage_summary_available_fields_with_http_info(opts = {}) ⇒ Array<(UsageSummaryAvailableFieldsResponse, Integer, Hash)>

Get available fields for usage summary.

List the field names returned by GET /api/v1/usage/summary at each of its three response levels. Each list contains every key the data endpoint emits—both typed fields declared in the OpenAPI spec and untyped keys exposed through additionalProperties (the latter used for billing dimensions and usage types added after the v1 schema freeze).

This endpoint is only accessible for parent-level organizations.

Go example:

fields, _, err := api.GetUsageSummaryAvailableFields(ctx)
attr := fields.Data.GetAttributes()

// resp is the *UsageSummaryResponse returned by api.GetUsageSummary(ctx, ...)
// Layer 1: UsageSummaryResponse
for _, key := range attr.GetResponseFields() {
    if val, ok := resp.AdditionalProperties[key]; ok {
        fmt.Println(key, val.(json.Number))
    }
}
// Layer 2: UsageSummaryDate (per month)
for _, date := range resp.GetUsage() {
    for _, key := range attr.GetDateFields() {
        if val, ok := date.AdditionalProperties[key]; ok {
            fmt.Println(key, val.(json.Number))
        }
    }
    // Layer 3: UsageSummaryDateOrg (per org per month)
    for _, org := range date.GetOrgs() {
        for _, key := range attr.GetDateOrgFields() {
            if val, ok := org.AdditionalProperties[key]; ok {
                fmt.Println(key, val.(json.Number))
            }
        }
    }
}

Parameters:

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

    the optional parameters

Returns:



1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 1133

def get_usage_summary_available_fields_with_http_info(opts = {})

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_usage_summary_available_fields ...'
  end
  # resource path
  local_var_path = '/api/v2/usage/summary/available_fields'

  # 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;datetime-format=rfc3339'])

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

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

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

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

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

#list_quotas(quota_namespace, opts = {}) ⇒ Object

List usage quotas.



1182
1183
1184
1185
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 1182

def list_quotas(quota_namespace, opts = {})
  data, _status_code, _headers = list_quotas_with_http_info(quota_namespace, opts)
  data
end

#list_quotas_with_http_info(quota_namespace, opts = {}) ⇒ Array<(UsageQuotasListResponse, Integer, Hash)>

List usage quotas.

Lists usage quotas for the caller's organization in a quota namespace. You can optionally include descendant organizations in the same datacenter as the caller. Requires the billing_read or billing_edit permission.

Parameters:

  • quota_namespace (String) —

    The product-specific namespace whose usage quotas are being managed.

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

    the optional parameters

Options Hash (opts):

  • :include_descendants (Boolean) —

    Whether to include quotas configured on descendant organizations in the caller's organization hierarchy. Only descendants in the same datacenter are supported.

  • :page_cursor (String) —

    An opaque cursor from a previous response's meta.page.next_cursor used to retrieve the next page.

  • :page_limit (Integer) —

    The number of usage quotas to return per page.

Returns:

  • (Array<(UsageQuotasListResponse, Integer, Hash)>) —

    UsageQuotasListResponse data, response status code and response headers



1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 1199

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.list_quotas ...'
  end
  # verify the required parameter 'quota_namespace' is set
  if @api_client.config.client_side_validation && quota_namespace.nil?
    fail ArgumentError, "Missing the required parameter 'quota_namespace' when calling UsageMeteringAPI.list_quotas"
  end
  if @api_client.config.client_side_validation && !opts[:'page_limit'].nil? && opts[:'page_limit'] > 1000
    fail ArgumentError, 'invalid value for "opts[:"page_limit"]" when calling UsageMeteringAPI.list_quotas, must be smaller than or equal to 1000.'
  end
  if @api_client.config.client_side_validation && !opts[:'page_limit'].nil? && opts[:'page_limit'] < 1
    fail ArgumentError, 'invalid value for "opts[:"page_limit"]" when calling UsageMeteringAPI.list_quotas, must be greater than or equal to 1.'
  end
  # resource path
  local_var_path = '/api/v2/usage/quotas/{quota_namespace}'.sub('{quota_namespace}', CGI.escape(quota_namespace.to_s).gsub('%2F', '/'))

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'include_descendants'] = opts[:'include_descendants'] if !opts[:'include_descendants'].nil?
  query_params[:'page[cursor]'] = opts[:'page_cursor'] if !opts[:'page_cursor'].nil?
  query_params[:'page[limit]'] = opts[:'page_limit'] if !opts[:'page_limit'].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] || 'UsageQuotasListResponse'

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

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

#list_quotas_with_pagination(quota_namespace, opts = {}) {|UsageQuotaResponseData| ... } ⇒ Object

List usage quotas.

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

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

Yields:



1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 1271

def list_quotas_with_pagination(quota_namespace, opts = {})
    api_version = "V2"
    page_size = @api_client.get_attribute_from_path(opts, "page_limit", 100)
    @api_client.set_attribute_from_path(api_version, opts, "page_limit", Integer, page_size)
    while true do
        response = list_quotas(quota_namespace, opts)
        @api_client.get_attribute_from_path(response, "data").each { |item| yield(item) }
        if @api_client.get_attribute_from_path(response, "data").length == 0
          break
        end
        @api_client.set_attribute_from_path(api_version, opts, "page_cursor", String, @api_client.get_attribute_from_path(response, "meta.page.next_cursor"))
    end
end

#update_quota(quota_namespace, id, body, opts = {}) ⇒ Object

Update a usage quota.



1288
1289
1290
1291
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 1288

def update_quota(quota_namespace, id, body, opts = {})
  data, _status_code, _headers = update_quota_with_http_info(quota_namespace, id, body, opts)
  data
end

#update_quota_with_http_info(quota_namespace, id, body, opts = {}) ⇒ Array<(UsageQuotaResponse, Integer, Hash)>

Update a usage quota.

Updates the supplied fields on a usage quota and leaves omitted fields unchanged. The quota must belong to the caller's organization or one of its descendants, and its opaque identifier must belong to the requested quota namespace. Requires the billing_edit permission.

Parameters:

  • quota_namespace (String) —

    The product-specific namespace whose usage quotas are being managed.

  • id (String) —

    The opaque quota identifier returned by a previous list or create request. Clients must pass this value verbatim.

  • body (UsageQuotaUpdateRequest) —

    The usage quota fields to update. Omitting an attribute leaves its current value unchanged.

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

    the optional parameters

Returns:

  • (Array<(UsageQuotaResponse, Integer, Hash)>) —

    UsageQuotaResponse data, response status code and response headers



1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
# File 'lib/datadog_api_client/v2/api/usage_metering_api.rb', line 1302

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

  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.update_quota ...'
  end
  # verify the required parameter 'quota_namespace' is set
  if @api_client.config.client_side_validation && quota_namespace.nil?
    fail ArgumentError, "Missing the required parameter 'quota_namespace' when calling UsageMeteringAPI.update_quota"
  end
  # verify the required parameter 'id' is set
  if @api_client.config.client_side_validation && id.nil?
    fail ArgumentError, "Missing the required parameter 'id' when calling UsageMeteringAPI.update_quota"
  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 UsageMeteringAPI.update_quota"
  end
  # resource path
  local_var_path = '/api/v2/usage/quotas/{quota_namespace}/{id}'.sub('{quota_namespace}', CGI.escape(quota_namespace.to_s).gsub('%2F', '/')).sub('{id}', CGI.escape(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] || 'UsageQuotaResponse'

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

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