diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 7a9926c3d391..c796079b6574 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -92205,6 +92205,91 @@ components: meta: $ref: "#/components/schemas/MonthlyCostAttributionMeta" type: object + MonthlyResource: + description: A resource's usage for the requested billing dimension and month. + properties: + attributes: + $ref: "#/components/schemas/MonthlyResourceAttributes" + id: + description: Identifier for the resource usage record. Treat this value as opaque. + type: string + type: + $ref: "#/components/schemas/MonthlyResourceType" + type: object + MonthlyResourceAttributes: + description: Resource usage and organization details for the requested month. + properties: + data_date: + description: Date of the source usage data. May be empty when unavailable. + type: string + org_name: + description: Name of the organization that owns the resource. + type: string + public_id: + description: Public ID of the organization that owns the resource. + type: string + resource_name: + description: Name of the resource, such as a host name, metric name, or log index. + type: string + tags: + additionalProperties: + type: string + description: Resource tags when available. Empty for resource types without tag data. + type: object + timestamp: + description: Selected billing hour for percentile usage, or the first day of the month for monthly usage. May be empty when unavailable. + type: string + usage_type: + description: Usage type of the resource. Values depend on the billing dimension and are not limited to host types. + type: string + usage_value: + description: Usage attributed to the resource in the units of the requested billing dimension. Values can be fractional. + format: double + nullable: true + type: number + type: object + MonthlyResourceType: + default: monthly_resource + description: Type of a monthly resource usage record. + enum: + - monthly_resource + type: string + x-enum-varnames: + - MONTHLY_RESOURCE + MonthlyResourcesMetadata: + description: Metadata for monthly resource usage. + properties: + pagination: + $ref: "#/components/schemas/MonthlyResourcesPagination" + type: object + MonthlyResourcesPagination: + description: Pagination information for monthly resource usage. + properties: + next_record_id: + description: Cursor for the next request. Pass as `page[next_record_id]` with the same filters. Null when there are no more results. + nullable: true + type: string + type: object + MonthlyResourcesResponse: + description: Monthly usage for host and non-host resources. + properties: + data: + description: Resource usage records. Empty when no matching resources are available. + items: + $ref: "#/components/schemas/MonthlyResource" + type: array + meta: + $ref: "#/components/schemas/MonthlyResourcesMetadata" + type: object + MonthlyResourcesView: + description: Whether to return billable resources or the full monthly resource breakdown. + enum: + - billable + - all + type: string + x-enum-varnames: + - BILLABLE + - ALL MuteDataType: default: mute description: Mute resource type. @@ -270789,6 +270874,164 @@ paths: operator: OR permissions: - usage_read + /api/v2/usage/monthly_resources: + get: + description: |- + Get resource-level usage for a billing dimension and month, using the same + data as the resource breakdown in Plan & Usage. Supports all host and + non-host resource types available in that breakdown. Availability depends + on the billing dimension and the organization's usage data. + + Results are scoped to the authenticated organization. Set `filter[include_descendants]` + to `true` to also return usage from its descendant organizations in all regions. + + Set `filter[view]` to `billable` to return resources that contribute to billable usage. + For dimensions billed at the 99th percentile, this view returns resources at the + selected billing hour. For sum-based dimensions, it returns monthly resource usage. + Set `filter[view]` to `all` to return the full monthly resource breakdown. Requests + for unsupported billing dimensions, or dimensions configured with an unsupported + billing aggregation method, return a `400 Bad Request` error. + + To get the next page of results, pass the `meta.pagination.next_record_id` value + from the previous response as `page[next_record_id]`, and keep all filters unchanged. + A null cursor indicates the last page. Paginated responses contain at most + `page[limit]` resource records, including queries across descendant organizations. + + Exception: for any billing dimension billed at the 99th percentile, + `filter[view]=billable` returns the complete resource breakdown in one response, + including requested descendants. Eligibility depends on the organization's + billing configuration for the requested dimension and month, not on the product + name. For these queries, `page[limit]` and `page[next_record_id]` are ignored, and + `meta.pagination.next_record_id` is null. Sum-based usage and `filter[view]=all` + remain paginated. + operationId: GetUsageMonthlyResources + parameters: + - description: Billing dimension to retrieve, such as `infra_host`, `indexed_points`, or `logs_indexed_30day`. + example: infra_host + in: query + name: filter[billing_dimension] + required: true + schema: + type: string + - description: Month of usage to retrieve in `YYYY-MM` format. + example: "2026-04" + in: query + name: filter[month] + required: true + schema: + pattern: "^[0-9]{4}-(0[1-9]|1[0-2])$" + type: string + - description: |- + Set to `billable` to return resources that contribute to billable usage, or `all` + to return the full monthly resource breakdown. + example: billable + in: query + name: filter[view] + required: true + schema: + $ref: "#/components/schemas/MonthlyResourcesView" + - description: Include usage for descendant organizations of the authenticated organization. + in: query + name: filter[include_descendants] + required: false + schema: + default: false + type: boolean + - description: |- + Maximum number of resource records per paginated response. Must be a positive integer. + Values above 100,000 are capped at 100,000. Ignored for billable queries using + 99th-percentile billing, which return the complete result in one response. + in: query + name: page[limit] + required: false + schema: + default: 100000 + format: int64 + maximum: 100000 + minimum: 1 + type: integer + - description: |- + Opaque cursor from `meta.pagination.next_record_id` in the previous response. + Omit for the first request. Ignored for billable queries using 99th-percentile + billing, which always return the complete result. + in: query + name: page[next_record_id] + required: false + schema: + type: string + responses: + "200": + content: + application/json;datetime-format=rfc3339: + examples: + default: + value: + data: + - attributes: + data_date: "2026-04-30" + org_name: Example organization + public_id: abc123 + resource_name: host-1.prod + tags: + env: prod + timestamp: "2026-04-22 16:00:00+00:00" + usage_type: agent + usage_value: 1 + id: abc123_agent_host-1.prod + type: monthly_resource + meta: + pagination: + next_record_id: + non_host: + value: + data: + - attributes: + data_date: "2026-04-30" + org_name: Example organization + public_id: abc123 + resource_name: app.requests + tags: {} + timestamp: "2026-04-01" + usage_type: post_threshold_indexed + usage_value: 1250.5 + id: abc123_post_threshold_indexed_app.requests + type: monthly_resource + meta: + pagination: + next_record_id: + schema: + $ref: "#/components/schemas/MonthlyResourcesResponse" + description: OK + "400": + content: + application/json;datetime-format=rfc3339: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Bad Request + "403": + content: + application/json;datetime-format=rfc3339: + schema: + $ref: "#/components/schemas/JSONAPIErrorResponse" + description: Forbidden - User is not authorized + "429": + content: + application/json;datetime-format=rfc3339: + schema: + $ref: "#/components/schemas/APIErrorResponse" + description: Too many requests + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - usage_read + summary: Get monthly usage by resource + tags: + - Usage Metering + "x-permission": + operator: OR + permissions: + - usage_read /api/v2/usage/observability_pipelines: get: deprecated: true diff --git a/examples/v2/usage-metering/GetUsageMonthlyResources.rb b/examples/v2/usage-metering/GetUsageMonthlyResources.rb new file mode 100644 index 000000000000..79ecca5676c9 --- /dev/null +++ b/examples/v2/usage-metering/GetUsageMonthlyResources.rb @@ -0,0 +1,11 @@ +# Get monthly usage by resource returns "OK" response + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] +end +api_instance = DatadogAPIClient::V2::UsageMeteringAPI.new +opts = { + page_limit: 1, +} +p api_instance.get_usage_monthly_resources("infra_host", "2026-04", MonthlyResourcesView::ALL, opts) diff --git a/examples/v2/usage-metering/GetUsageMonthlyResources_1935480325.rb b/examples/v2/usage-metering/GetUsageMonthlyResources_1935480325.rb new file mode 100644 index 000000000000..580400eecad5 --- /dev/null +++ b/examples/v2/usage-metering/GetUsageMonthlyResources_1935480325.rb @@ -0,0 +1,11 @@ +# Get monthly usage by resource supports non-host resources + +require "datadog_api_client" +DatadogAPIClient.configure do |config| + config.access_token = ENV["DD_BEARER_TOKEN"] +end +api_instance = DatadogAPIClient::V2::UsageMeteringAPI.new +opts = { + page_limit: 1, +} +p api_instance.get_usage_monthly_resources("indexed_points", "2026-04", MonthlyResourcesView::ALL, opts) diff --git a/features/scenarios_model_mapping.rb b/features/scenarios_model_mapping.rb index 07274057c608..caf9e0842df9 100644 --- a/features/scenarios_model_mapping.rb +++ b/features/scenarios_model_mapping.rb @@ -3436,6 +3436,14 @@ "start_hr" => "Time", "end_hr" => "Time", }, + "v2.GetUsageMonthlyResources" => { + "filter_billing_dimension" => "String", + "filter_month" => "String", + "filter_view" => "MonthlyResourcesView", + "filter_include_descendants" => "Boolean", + "page_limit" => "Integer", + "page_next_record_id" => "String", + }, "v2.GetUsageObservabilityPipelines" => { "start_hr" => "Time", "end_hr" => "Time", diff --git a/features/v2/undo.json b/features/v2/undo.json index 0d9b33aa46f6..481c29dd4790 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -11713,6 +11713,12 @@ "type": "safe" } }, + "GetUsageMonthlyResources": { + "tag": "Usage Metering", + "undo": { + "type": "safe" + } + }, "GetUsageObservabilityPipelines": { "tag": "Usage Metering", "undo": { diff --git a/features/v2/usage_metering.feature b/features/v2/usage_metering.feature index 67ba7beacefa..783eab95a1d2 100644 --- a/features/v2/usage_metering.feature +++ b/features/v2/usage_metering.feature @@ -451,6 +451,42 @@ Feature: Usage Metering And the response "data[0].type" is equal to "usage_timeseries" And the response "data[0].attributes.product_family" is equal to "observability-pipelines" + @integration-only @team:ddoghq/billing-hub + Scenario: Get monthly usage by resource returns "Bad Request" response + Given new "GetUsageMonthlyResources" request + And request contains "filter[billing_dimension]" parameter with value "infra_host" + And request contains "filter[month]" parameter with value "not-a-month" + And request contains "filter[view]" parameter with value "all" + When the request is sent + Then the response status is 400 Bad Request + And the response "errors[0].status" is equal to "400" + And the response "errors[0].title" is equal to "Bad Request" + And the response "errors[0]" has field "detail" + + @integration-only @team:ddoghq/billing-hub + Scenario: Get monthly usage by resource returns "OK" response + Given new "GetUsageMonthlyResources" request + And request contains "filter[billing_dimension]" parameter with value "infra_host" + And request contains "filter[month]" parameter with value "2026-04" + And request contains "filter[view]" parameter with value "all" + And request contains "page[limit]" parameter with value 1 + When the request is sent + Then the response status is 200 OK + And the response "meta" has field "pagination" + And the response "meta.pagination" has field "next_record_id" + + @integration-only @team:ddoghq/billing-hub + Scenario: Get monthly usage by resource supports non-host resources + Given new "GetUsageMonthlyResources" request + And request contains "filter[billing_dimension]" parameter with value "indexed_points" + And request contains "filter[month]" parameter with value "2026-04" + And request contains "filter[view]" parameter with value "all" + And request contains "page[limit]" parameter with value 1 + When the request is sent + Then the response status is 200 OK + And the response "meta" has field "pagination" + And the response "meta.pagination" has field "next_record_id" + @generated @skip @team:ddoghq/billing-hub Scenario: Get projected cost across your account returns "Bad Request" response Given new "GetProjectedCost" request diff --git a/lib/datadog_api_client/inflector.rb b/lib/datadog_api_client/inflector.rb index 36ab8f2db077..095015703dad 100644 --- a/lib/datadog_api_client/inflector.rb +++ b/lib/datadog_api_client/inflector.rb @@ -6410,6 +6410,13 @@ def overrides "v2.monthly_cost_attribution_meta" => "MonthlyCostAttributionMeta", "v2.monthly_cost_attribution_pagination" => "MonthlyCostAttributionPagination", "v2.monthly_cost_attribution_response" => "MonthlyCostAttributionResponse", + "v2.monthly_resource" => "MonthlyResource", + "v2.monthly_resource_attributes" => "MonthlyResourceAttributes", + "v2.monthly_resources_metadata" => "MonthlyResourcesMetadata", + "v2.monthly_resources_pagination" => "MonthlyResourcesPagination", + "v2.monthly_resources_response" => "MonthlyResourcesResponse", + "v2.monthly_resources_view" => "MonthlyResourcesView", + "v2.monthly_resource_type" => "MonthlyResourceType", "v2.ms_teams_integration_metadata" => "MSTeamsIntegrationMetadata", "v2.ms_teams_integration_metadata_teams_item" => "MSTeamsIntegrationMetadataTeamsItem", "v2.mute_data_type" => "MuteDataType", diff --git a/lib/datadog_api_client/v2/api/usage_metering_api.rb b/lib/datadog_api_client/v2/api/usage_metering_api.rb index f41144300bac..de63c77591a9 100644 --- a/lib/datadog_api_client/v2/api/usage_metering_api.rb +++ b/lib/datadog_api_client/v2/api/usage_metering_api.rb @@ -1564,6 +1564,131 @@ def get_usage_lambda_traced_invocations_with_http_info(start_hr, opts = {}) return data, status_code, headers end + # Get monthly usage by resource. + # + # @see #get_usage_monthly_resources_with_http_info + def get_usage_monthly_resources(filter_billing_dimension, filter_month, filter_view, opts = {}) + data, _status_code, _headers = get_usage_monthly_resources_with_http_info(filter_billing_dimension, filter_month, filter_view, opts) + data + end + + # Get monthly usage by resource. + # + # Get resource-level usage for a billing dimension and month, using the same + # data as the resource breakdown in Plan & Usage. Supports all host and + # non-host resource types available in that breakdown. Availability depends + # on the billing dimension and the organization's usage data. + # + # Results are scoped to the authenticated organization. Set `filter[include_descendants]` + # to `true` to also return usage from its descendant organizations in all regions. + # + # Set `filter[view]` to `billable` to return resources that contribute to billable usage. + # For dimensions billed at the 99th percentile, this view returns resources at the + # selected billing hour. For sum-based dimensions, it returns monthly resource usage. + # Set `filter[view]` to `all` to return the full monthly resource breakdown. Requests + # for unsupported billing dimensions, or dimensions configured with an unsupported + # billing aggregation method, return a `400 Bad Request` error. + # + # To get the next page of results, pass the `meta.pagination.next_record_id` value + # from the previous response as `page[next_record_id]`, and keep all filters unchanged. + # A null cursor indicates the last page. Paginated responses contain at most + # `page[limit]` resource records, including queries across descendant organizations. + # + # Exception: for any billing dimension billed at the 99th percentile, + # `filter[view]=billable` returns the complete resource breakdown in one response, + # including requested descendants. Eligibility depends on the organization's + # billing configuration for the requested dimension and month, not on the product + # name. For these queries, `page[limit]` and `page[next_record_id]` are ignored, and + # `meta.pagination.next_record_id` is null. Sum-based usage and `filter[view]=all` + # remain paginated. + # + # @param filter_billing_dimension [String] Billing dimension to retrieve, such as `infra_host`, `indexed_points`, or `logs_indexed_30day`. + # @param filter_month [String] Month of usage to retrieve in `YYYY-MM` format. + # @param filter_view [MonthlyResourcesView] Set to `billable` to return resources that contribute to billable usage, or `all` to return the full monthly resource breakdown. + # @param opts [Hash] the optional parameters + # @option opts [Boolean] :filter_include_descendants Include usage for descendant organizations of the authenticated organization. + # @option opts [Integer] :page_limit Maximum number of resource records per paginated response. Must be a positive integer. Values above 100,000 are capped at 100,000. Ignored for billable queries using 99th-percentile billing, which return the complete result in one response. + # @option opts [String] :page_next_record_id Opaque cursor from `meta.pagination.next_record_id` in the previous response. Omit for the first request. Ignored for billable queries using 99th-percentile billing, which always return the complete result. + # @return [Array<(MonthlyResourcesResponse, Integer, Hash)>] MonthlyResourcesResponse data, response status code and response headers + def get_usage_monthly_resources_with_http_info(filter_billing_dimension, filter_month, filter_view, opts = {}) + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_usage_monthly_resources ...' + end + # verify the required parameter 'filter_billing_dimension' is set + if @api_client.config.client_side_validation && filter_billing_dimension.nil? + fail ArgumentError, "Missing the required parameter 'filter_billing_dimension' when calling UsageMeteringAPI.get_usage_monthly_resources" + end + # verify the required parameter 'filter_month' is set + if @api_client.config.client_side_validation && filter_month.nil? + fail ArgumentError, "Missing the required parameter 'filter_month' when calling UsageMeteringAPI.get_usage_monthly_resources" + end + pattern = Regexp.new("^[0-9]{4}-(0[1-9]|1[0-2])$") + if @api_client.config.client_side_validation && filter_month !~ pattern + fail ArgumentError, "invalid value for 'filter_month' when calling UsageMeteringAPI.get_usage_monthly_resources, must conform to the pattern #{pattern}." + end + # verify the required parameter 'filter_view' is set + if @api_client.config.client_side_validation && filter_view.nil? + fail ArgumentError, "Missing the required parameter 'filter_view' when calling UsageMeteringAPI.get_usage_monthly_resources" + end + # verify enum value + allowable_values = ['billable', 'all'] + if @api_client.config.client_side_validation && !allowable_values.include?(filter_view) + fail ArgumentError, "invalid value for \"filter_view\", must be one of #{allowable_values}" + end + if @api_client.config.client_side_validation && !opts[:'page_limit'].nil? && opts[:'page_limit'] > 100000 + fail ArgumentError, 'invalid value for "opts[:"page_limit"]" when calling UsageMeteringAPI.get_usage_monthly_resources, must be smaller than or equal to 100000.' + 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_usage_monthly_resources, must be greater than or equal to 1.' + end + # resource path + local_var_path = '/api/v2/usage/monthly_resources' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'filter[billing_dimension]'] = filter_billing_dimension + query_params[:'filter[month]'] = filter_month + query_params[:'filter[view]'] = filter_view + query_params[:'filter[include_descendants]'] = opts[:'filter_include_descendants'] if !opts[:'filter_include_descendants'].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] || 'MonthlyResourcesResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :get_usage_monthly_resources, + :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_monthly_resources\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get hourly usage for observability pipelines. # # @see #get_usage_observability_pipelines_with_http_info diff --git a/lib/datadog_api_client/v2/models/monthly_resource.rb b/lib/datadog_api_client/v2/models/monthly_resource.rb new file mode 100644 index 000000000000..e8a4c5485ba8 --- /dev/null +++ b/lib/datadog_api_client/v2/models/monthly_resource.rb @@ -0,0 +1,125 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # A resource's usage for the requested billing dimension and month. + class MonthlyResource + include BaseGenericModel + + # Resource usage and organization details for the requested month. + attr_accessor :attributes + + # Identifier for the resource usage record. Treat this value as opaque. + attr_accessor :id + + # Type of a monthly resource usage record. + attr_accessor :type + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'MonthlyResourceAttributes', + :'id' => :'String', + :'type' => :'MonthlyResourceType' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::MonthlyResource` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + attributes == o.attributes && + id == o.id && + type == o.type && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/monthly_resource_attributes.rb b/lib/datadog_api_client/v2/models/monthly_resource_attributes.rb new file mode 100644 index 000000000000..b8db7a483759 --- /dev/null +++ b/lib/datadog_api_client/v2/models/monthly_resource_attributes.rb @@ -0,0 +1,183 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Resource usage and organization details for the requested month. + class MonthlyResourceAttributes + include BaseGenericModel + + # Date of the source usage data. May be empty when unavailable. + attr_accessor :data_date + + # Name of the organization that owns the resource. + attr_accessor :org_name + + # Public ID of the organization that owns the resource. + attr_accessor :public_id + + # Name of the resource, such as a host name, metric name, or log index. + attr_accessor :resource_name + + # Resource tags when available. Empty for resource types without tag data. + attr_accessor :tags + + # Selected billing hour for percentile usage, or the first day of the month for monthly usage. May be empty when unavailable. + attr_accessor :timestamp + + # Usage type of the resource. Values depend on the billing dimension and are not limited to host types. + attr_accessor :usage_type + + # Usage attributed to the resource in the units of the requested billing dimension. Values can be fractional. + attr_accessor :usage_value + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data_date' => :'data_date', + :'org_name' => :'org_name', + :'public_id' => :'public_id', + :'resource_name' => :'resource_name', + :'tags' => :'tags', + :'timestamp' => :'timestamp', + :'usage_type' => :'usage_type', + :'usage_value' => :'usage_value' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data_date' => :'String', + :'org_name' => :'String', + :'public_id' => :'String', + :'resource_name' => :'String', + :'tags' => :'Hash', + :'timestamp' => :'String', + :'usage_type' => :'String', + :'usage_value' => :'Float' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'usage_value', + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::MonthlyResourceAttributes` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data_date') + self.data_date = attributes[:'data_date'] + end + + if attributes.key?(:'org_name') + self.org_name = attributes[:'org_name'] + end + + if attributes.key?(:'public_id') + self.public_id = attributes[:'public_id'] + end + + if attributes.key?(:'resource_name') + self.resource_name = attributes[:'resource_name'] + end + + if attributes.key?(:'tags') + self.tags = attributes[:'tags'] + end + + if attributes.key?(:'timestamp') + self.timestamp = attributes[:'timestamp'] + end + + if attributes.key?(:'usage_type') + self.usage_type = attributes[:'usage_type'] + end + + if attributes.key?(:'usage_value') + self.usage_value = attributes[:'usage_value'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data_date == o.data_date && + org_name == o.org_name && + public_id == o.public_id && + resource_name == o.resource_name && + tags == o.tags && + timestamp == o.timestamp && + usage_type == o.usage_type && + usage_value == o.usage_value && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data_date, org_name, public_id, resource_name, tags, timestamp, usage_type, usage_value, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/monthly_resource_type.rb b/lib/datadog_api_client/v2/models/monthly_resource_type.rb new file mode 100644 index 000000000000..339338e4f68e --- /dev/null +++ b/lib/datadog_api_client/v2/models/monthly_resource_type.rb @@ -0,0 +1,26 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Type of a monthly resource usage record. + class MonthlyResourceType + include BaseEnumModel + + MONTHLY_RESOURCE = "monthly_resource".freeze + end +end diff --git a/lib/datadog_api_client/v2/models/monthly_resources_metadata.rb b/lib/datadog_api_client/v2/models/monthly_resources_metadata.rb new file mode 100644 index 000000000000..4011bf632f3c --- /dev/null +++ b/lib/datadog_api_client/v2/models/monthly_resources_metadata.rb @@ -0,0 +1,105 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Metadata for monthly resource usage. + class MonthlyResourcesMetadata + include BaseGenericModel + + # Pagination information for monthly resource usage. + attr_accessor :pagination + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'pagination' => :'pagination' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'pagination' => :'MonthlyResourcesPagination' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::MonthlyResourcesMetadata` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'pagination') + self.pagination = attributes[:'pagination'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + pagination == o.pagination && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [pagination, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/monthly_resources_pagination.rb b/lib/datadog_api_client/v2/models/monthly_resources_pagination.rb new file mode 100644 index 000000000000..ac3b46dd68c6 --- /dev/null +++ b/lib/datadog_api_client/v2/models/monthly_resources_pagination.rb @@ -0,0 +1,113 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Pagination information for monthly resource usage. + class MonthlyResourcesPagination + include BaseGenericModel + + # Cursor for the next request. Pass as `page[next_record_id]` with the same filters. Null when there are no more results. + attr_accessor :next_record_id + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'next_record_id' => :'next_record_id' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'next_record_id' => :'String' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'next_record_id', + ]) + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::MonthlyResourcesPagination` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'next_record_id') + self.next_record_id = attributes[:'next_record_id'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + next_record_id == o.next_record_id && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [next_record_id, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/monthly_resources_response.rb b/lib/datadog_api_client/v2/models/monthly_resources_response.rb new file mode 100644 index 000000000000..5d63c102e57a --- /dev/null +++ b/lib/datadog_api_client/v2/models/monthly_resources_response.rb @@ -0,0 +1,117 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Monthly usage for host and non-host resources. + class MonthlyResourcesResponse + include BaseGenericModel + + # Resource usage records. Empty when no matching resources are available. + attr_accessor :data + + # Metadata for monthly resource usage. + attr_accessor :meta + + attr_accessor :additional_properties + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data', + :'meta' => :'meta' + } + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array', + :'meta' => :'MonthlyResourcesMetadata' + } + end + + # Initializes the object + # @param attributes [Hash] Model attributes in the form of hash + # @!visibility private + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V2::MonthlyResourcesResponse` initialize method" + end + + self.additional_properties = {} + # check to see if the attribute exists and convert string to symbol for hash key + attributes = attributes.each_with_object({}) { |(k, v), h| + if (!self.class.attribute_map.key?(k.to_sym)) + self.additional_properties[k.to_sym] = v + else + h[k.to_sym] = v + end + } + + if attributes.key?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'meta') + self.meta = attributes[:'meta'] + end + end + + # Returns the object in the form of hash, with additionalProperties support. + # @return [Hash] Returns the object in the form of hash + # @!visibility private + def to_hash + hash = {} + self.class.attribute_map.each_pair do |attr, param| + value = self.send(attr) + if value.nil? + is_nullable = self.class.openapi_nullable.include?(attr) + next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) + end + + hash[param] = _to_hash(value) + end + self.additional_properties.each_pair do |attr, value| + hash[attr] = value + end + hash + end + + # Checks equality by comparing each attribute. + # @param o [Object] Object to be compared + # @!visibility private + def ==(o) + return true if self.equal?(o) + self.class == o.class && + data == o.data && + meta == o.meta && + additional_properties == o.additional_properties + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, meta, additional_properties].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/monthly_resources_view.rb b/lib/datadog_api_client/v2/models/monthly_resources_view.rb new file mode 100644 index 000000000000..af2d8f32a1bc --- /dev/null +++ b/lib/datadog_api_client/v2/models/monthly_resources_view.rb @@ -0,0 +1,27 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Whether to return billable resources or the full monthly resource breakdown. + class MonthlyResourcesView + include BaseEnumModel + + BILLABLE = "billable".freeze + ALL = "all".freeze + end +end