From af6f91be8e162b76ac3dfcc48102540f8200f487 Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Thu, 19 Nov 2020 10:00:01 +0000 Subject: [PATCH] Regenerate client from commit ee26c54 of spec repo --- .apigentools-info | 8 +- data/v1/openapi.yaml | 273 +++++++++++++ docs/v1/README.md | 8 + docs/v1/UsageAttributionAggregatesBody.md | 21 + docs/v1/UsageAttributionBody.md | 25 ++ docs/v1/UsageAttributionMetadata.md | 19 + docs/v1/UsageAttributionPagination.md | 25 ++ docs/v1/UsageAttributionResponse.md | 19 + docs/v1/UsageAttributionSort.md | 16 + docs/v1/UsageAttributionValues.md | 51 +++ docs/v1/UsageMeteringApi.md | 72 ++++ features/v1/usage_metering.feature | 6 + lib/datadog_api_client/v1.rb | 7 + .../v1/api/usage_metering_api.rb | 93 +++++ .../usage_attribution_aggregates_body.rb | 232 +++++++++++ .../v1/models/usage_attribution_body.rb | 253 ++++++++++++ .../v1/models/usage_attribution_metadata.rb | 223 ++++++++++ .../v1/models/usage_attribution_pagination.rb | 252 ++++++++++++ .../v1/models/usage_attribution_response.rb | 223 ++++++++++ .../v1/models/usage_attribution_sort.rb | 53 +++ .../v1/models/usage_attribution_values.rb | 382 ++++++++++++++++++ 21 files changed, 2257 insertions(+), 4 deletions(-) create mode 100644 docs/v1/UsageAttributionAggregatesBody.md create mode 100644 docs/v1/UsageAttributionBody.md create mode 100644 docs/v1/UsageAttributionMetadata.md create mode 100644 docs/v1/UsageAttributionPagination.md create mode 100644 docs/v1/UsageAttributionResponse.md create mode 100644 docs/v1/UsageAttributionSort.md create mode 100644 docs/v1/UsageAttributionValues.md create mode 100644 lib/datadog_api_client/v1/models/usage_attribution_aggregates_body.rb create mode 100644 lib/datadog_api_client/v1/models/usage_attribution_body.rb create mode 100644 lib/datadog_api_client/v1/models/usage_attribution_metadata.rb create mode 100644 lib/datadog_api_client/v1/models/usage_attribution_pagination.rb create mode 100644 lib/datadog_api_client/v1/models/usage_attribution_response.rb create mode 100644 lib/datadog_api_client/v1/models/usage_attribution_sort.rb create mode 100644 lib/datadog_api_client/v1/models/usage_attribution_values.rb diff --git a/.apigentools-info b/.apigentools-info index 10bf891c2cac..6eca055c9f65 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.3.0", - "regenerated": "2020-11-18 17:04:49.196168", - "spec_repo_commit": "e3c8008" + "regenerated": "2020-11-19 09:59:51.028039", + "spec_repo_commit": "ee26c54" }, "v2": { "apigentools_version": "1.3.0", - "regenerated": "2020-11-18 17:04:58.549741", - "spec_repo_commit": "e3c8008" + "regenerated": "2020-11-19 09:59:59.914277", + "spec_repo_commit": "ee26c54" } } } \ No newline at end of file diff --git a/data/v1/openapi.yaml b/data/v1/openapi.yaml index b11c01c44c8f..68081f5ea6e5 100644 --- a/data/v1/openapi.yaml +++ b/data/v1/openapi.yaml @@ -7303,6 +7303,215 @@ components: $ref: '#/components/schemas/UsageAnalyzedLogsHour' type: array type: object + UsageAttributionAggregates: + description: An array of available aggregates. + items: + $ref: '#/components/schemas/UsageAttributionAggregatesBody' + type: array + UsageAttributionAggregatesBody: + description: The object containing the aggregates. + properties: + agg_type: + description: The aggregate type. + example: sum + type: string + field: + description: The field. + example: custom_timeseries_usage + type: string + value: + description: The value for a given field. + format: double + type: number + type: object + UsageAttributionBody: + description: Usage Summary by tag usage for a given organization. + properties: + month: + description: 'Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM].' + format: date-time + type: string + public_id: + description: The organization public ID. + type: string + tags: + $ref: '#/components/schemas/UsageAttributionTagNames' + updated_at: + description: Shows the the most recent hour in the current months for all + organizations for which all usages were calculated. + type: string + values: + $ref: '#/components/schemas/UsageAttributionValues' + type: object + UsageAttributionMetadata: + description: The object containing document metadata. + properties: + aggregates: + $ref: '#/components/schemas/UsageAttributionAggregates' + pagination: + $ref: '#/components/schemas/UsageAttributionPagination' + type: object + UsageAttributionPagination: + description: The page count for the current pagination. + properties: + limit: + description: Maximum amount of records to be returned. + format: int64 + type: integer + offset: + description: Records to be skipped before beginning to return. + format: int64 + type: integer + sort_direction: + description: Direction to sort by. + type: string + sort_name: + description: Field to sort by. + type: string + total_number_of_records: + description: Total number of records. + format: int64 + type: integer + type: object + UsageAttributionResponse: + description: Response containing the Usage Summary by tag(s). + properties: + metadata: + $ref: '#/components/schemas/UsageAttributionMetadata' + usage: + description: Get Usage Summary by tag(s). + items: + $ref: '#/components/schemas/UsageAttributionBody' + type: array + type: object + UsageAttributionSort: + default: custom_timeseries_usage + description: The field to sort by. + enum: + - api_percentage + - snmp_usage + - lambda_percentage + - apm_host_usage + - api_usage + - container_usage + - custom_timeseries_percentage + - container_percentage + - lambda_usage + - apm_host_percentage + - npm_host_percentage + - browser_percentage + - browser_usage + - infra_host_percentage + - snmp_percentage + - npm_host_usage + - infra_host_usage + - custom_timeseries_usage + type: string + x-enum-varnames: + - API_PERCENTAGE + - SNMP_USAGE + - LAMBDA_PERCENTAGE + - APM_HOST_USAGE + - API_USAGE + - CONTAINER_USAGE + - CUSTOM_TIMESERIES_PERCENTAGE + - CONTAINER_PERCENTAGE + - LAMBDA_USAGE + - APM_HOST_PERCENTAGE + - NPM_HOST_PERCENTAGE + - BROWSER_PERCENTAGE + - BROWSER_USAGE + - INFRA_HOST_PERCENTAGE + - SNMP_PERCENTAGE + - NPM_HOST_USAGE + - INFRA_HOST_USAGE + - CUSTOM_TIMESERIES_USAGE + UsageAttributionTagNames: + additionalProperties: + description: A list of tag values. + items: + description: A given tag in a list. + example: datadog-integrations-lab + type: string + type: array + description: Usage Summary by tag names. + type: object + UsageAttributionValues: + description: Fields in Usage Summary by tag(s). + properties: + api_percentage: + description: The percentage of synthetic API test usage by tag(s). + format: double + type: number + api_usage: + description: The synthetic API test usage by tag(s). + format: double + type: number + apm_host_percentage: + description: The percentage of APM host usage by tag(s). + format: double + type: number + apm_host_usage: + description: The APM host usage by tag(s). + format: double + type: number + browser_percentage: + description: The percentage of synthetic browser test usage by tag(s). + format: double + type: number + browser_usage: + description: The synthetic browser test usage by tag(s). + format: double + type: number + container_percentage: + description: The percentage of container usage by tag(s). + format: double + type: number + container_usage: + description: The container usage by tag(s). + format: double + type: number + custom_timeseries_percentage: + description: The percentage of custom metrics usage by tag(s). + format: double + type: number + custom_timeseries_usage: + description: The custom metrics usage by tag(s). + format: double + type: number + infra_host_percentage: + description: The percentage of infrastructure host usage by tag(s). + format: double + type: number + infra_host_usage: + description: The infrastructure host usage by tag(s). + format: double + type: number + lambda_percentage: + description: The percentage of lambda function usage by tag(s). + format: double + type: number + lambda_usage: + description: The lambda function usage by tag(s). + format: double + type: number + npm_host_percentage: + description: The percentage of network host usage by tag(s). + format: double + type: number + npm_host_usage: + description: The network host usage by tag(s). + format: double + type: number + snmp_percentage: + description: The percentage of network device usage by tag(s). + format: double + type: number + snmp_usage: + description: The network device usage by tag(s). + format: double + type: number + type: object UsageBillableSummaryBody: description: Response with properties for each aggregated usage type. properties: @@ -14492,6 +14701,70 @@ paths: summary: Get hourly usage for analyzed logs tags: - Usage Metering + /api/v1/usage/attribution: + get: + description: Get Usage Attribution. + operationId: GetUsageAttribution + parameters: + - description: 'Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` + for usage beginning in this month. + + Maximum of 15 months ago.' + in: query + name: start_month + required: true + schema: + format: date-time + type: string + - description: The specified field to search results for. + in: query + name: fields + required: true + schema: + type: string + - description: 'Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` + for usage ending this month.' + in: query + name: end_month + required: false + schema: + format: date-time + type: string + - description: Include usage summaries for each sub-org. + in: query + name: org_id + required: false + schema: + format: int64 + type: integer + - description: 'The direction to sort by: `[desc, asc]`.' + in: query + name: sort_direction + required: false + schema: + $ref: '#/components/schemas/UsageSortDirection' + - description: The field to sort by. + in: query + name: sort_name + required: false + schema: + $ref: '#/components/schemas/UsageAttributionSort' + responses: + '200': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/UsageAttributionResponse' + description: OK + '403': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden - User is not authorized + summary: Get Usage Attribution + tags: + - Usage Metering /api/v1/usage/aws_lambda: get: description: Get hourly usage for lambda. diff --git a/docs/v1/README.md b/docs/v1/README.md index 66de3503d08d..f6237d6ff46f 100644 --- a/docs/v1/README.md +++ b/docs/v1/README.md @@ -218,6 +218,7 @@ Class | Method | HTTP request | Description *DatadogAPIClient::V1::UsageMeteringApi* | [**get_specified_monthly_custom_reports**](docs/UsageMeteringApi.md#get_specified_monthly_custom_reports) | **GET** /api/v1/monthly_custom_reports/{report_id} | Get specified monthly custom reports *DatadogAPIClient::V1::UsageMeteringApi* | [**get_tracing_without_limits**](docs/UsageMeteringApi.md#get_tracing_without_limits) | **GET** /api/v1/usage/tracing-without-limits | Get hourly usage for tracing without limits *DatadogAPIClient::V1::UsageMeteringApi* | [**get_usage_analyzed_logs**](docs/UsageMeteringApi.md#get_usage_analyzed_logs) | **GET** /api/v1/usage/analyzed_logs | Get hourly usage for analyzed logs +*DatadogAPIClient::V1::UsageMeteringApi* | [**get_usage_attribution**](docs/UsageMeteringApi.md#get_usage_attribution) | **GET** /api/v1/usage/attribution | Get Usage Attribution *DatadogAPIClient::V1::UsageMeteringApi* | [**get_usage_billable_summary**](docs/UsageMeteringApi.md#get_usage_billable_summary) | **GET** /api/v1/usage/billable-summary | Get billable usage across your multi-org account *DatadogAPIClient::V1::UsageMeteringApi* | [**get_usage_fargate**](docs/UsageMeteringApi.md#get_usage_fargate) | **GET** /api/v1/usage/fargate | Get hourly usage for Fargate *DatadogAPIClient::V1::UsageMeteringApi* | [**get_usage_hosts**](docs/UsageMeteringApi.md#get_usage_hosts) | **GET** /api/v1/usage/hosts | Get hourly usage for hosts and containers @@ -565,6 +566,13 @@ Class | Method | HTTP request | Description - [DatadogAPIClient::V1::ToplistWidgetRequest](docs/ToplistWidgetRequest.md) - [DatadogAPIClient::V1::UsageAnalyzedLogsHour](docs/UsageAnalyzedLogsHour.md) - [DatadogAPIClient::V1::UsageAnalyzedLogsResponse](docs/UsageAnalyzedLogsResponse.md) + - [DatadogAPIClient::V1::UsageAttributionAggregatesBody](docs/UsageAttributionAggregatesBody.md) + - [DatadogAPIClient::V1::UsageAttributionBody](docs/UsageAttributionBody.md) + - [DatadogAPIClient::V1::UsageAttributionMetadata](docs/UsageAttributionMetadata.md) + - [DatadogAPIClient::V1::UsageAttributionPagination](docs/UsageAttributionPagination.md) + - [DatadogAPIClient::V1::UsageAttributionResponse](docs/UsageAttributionResponse.md) + - [DatadogAPIClient::V1::UsageAttributionSort](docs/UsageAttributionSort.md) + - [DatadogAPIClient::V1::UsageAttributionValues](docs/UsageAttributionValues.md) - [DatadogAPIClient::V1::UsageBillableSummaryBody](docs/UsageBillableSummaryBody.md) - [DatadogAPIClient::V1::UsageBillableSummaryHour](docs/UsageBillableSummaryHour.md) - [DatadogAPIClient::V1::UsageBillableSummaryKeys](docs/UsageBillableSummaryKeys.md) diff --git a/docs/v1/UsageAttributionAggregatesBody.md b/docs/v1/UsageAttributionAggregatesBody.md new file mode 100644 index 000000000000..106153bed6cb --- /dev/null +++ b/docs/v1/UsageAttributionAggregatesBody.md @@ -0,0 +1,21 @@ +# DatadogAPIClient::V1::UsageAttributionAggregatesBody + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**agg_type** | **String** | The aggregate type. | [optional] +**field** | **String** | The field. | [optional] +**value** | **Float** | The value for a given field. | [optional] + +## Code Sample + +```ruby +require 'DatadogAPIClient::V1' + +instance = DatadogAPIClient::V1::UsageAttributionAggregatesBody.new(agg_type: sum, + field: custom_timeseries_usage, + value: null) +``` + + diff --git a/docs/v1/UsageAttributionBody.md b/docs/v1/UsageAttributionBody.md new file mode 100644 index 000000000000..b31aaa4d5325 --- /dev/null +++ b/docs/v1/UsageAttributionBody.md @@ -0,0 +1,25 @@ +# DatadogAPIClient::V1::UsageAttributionBody + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**month** | **Time** | Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM]. | [optional] +**public_id** | **String** | The organization public ID. | [optional] +**tags** | **Hash<String, Array<String>>** | Usage Summary by tag names. | [optional] +**updated_at** | **String** | Shows the the most recent hour in the current months for all organizations for which all usages were calculated. | [optional] +**values** | [**UsageAttributionValues**](UsageAttributionValues.md) | | [optional] + +## Code Sample + +```ruby +require 'DatadogAPIClient::V1' + +instance = DatadogAPIClient::V1::UsageAttributionBody.new(month: null, + public_id: null, + tags: null, + updated_at: null, + values: null) +``` + + diff --git a/docs/v1/UsageAttributionMetadata.md b/docs/v1/UsageAttributionMetadata.md new file mode 100644 index 000000000000..cc1e9044480c --- /dev/null +++ b/docs/v1/UsageAttributionMetadata.md @@ -0,0 +1,19 @@ +# DatadogAPIClient::V1::UsageAttributionMetadata + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**aggregates** | [**Array<UsageAttributionAggregatesBody>**](UsageAttributionAggregatesBody.md) | An array of available aggregates. | [optional] +**pagination** | [**UsageAttributionPagination**](UsageAttributionPagination.md) | | [optional] + +## Code Sample + +```ruby +require 'DatadogAPIClient::V1' + +instance = DatadogAPIClient::V1::UsageAttributionMetadata.new(aggregates: null, + pagination: null) +``` + + diff --git a/docs/v1/UsageAttributionPagination.md b/docs/v1/UsageAttributionPagination.md new file mode 100644 index 000000000000..d18b4b570230 --- /dev/null +++ b/docs/v1/UsageAttributionPagination.md @@ -0,0 +1,25 @@ +# DatadogAPIClient::V1::UsageAttributionPagination + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**limit** | **Integer** | Maximum amount of records to be returned. | [optional] +**offset** | **Integer** | Records to be skipped before beginning to return. | [optional] +**sort_direction** | **String** | Direction to sort by. | [optional] +**sort_name** | **String** | Field to sort by. | [optional] +**total_number_of_records** | **Integer** | Total number of records. | [optional] + +## Code Sample + +```ruby +require 'DatadogAPIClient::V1' + +instance = DatadogAPIClient::V1::UsageAttributionPagination.new(limit: null, + offset: null, + sort_direction: null, + sort_name: null, + total_number_of_records: null) +``` + + diff --git a/docs/v1/UsageAttributionResponse.md b/docs/v1/UsageAttributionResponse.md new file mode 100644 index 000000000000..6a987fbef308 --- /dev/null +++ b/docs/v1/UsageAttributionResponse.md @@ -0,0 +1,19 @@ +# DatadogAPIClient::V1::UsageAttributionResponse + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**metadata** | [**UsageAttributionMetadata**](UsageAttributionMetadata.md) | | [optional] +**usage** | [**Array<UsageAttributionBody>**](UsageAttributionBody.md) | Get Usage Summary by tag(s). | [optional] + +## Code Sample + +```ruby +require 'DatadogAPIClient::V1' + +instance = DatadogAPIClient::V1::UsageAttributionResponse.new(metadata: null, + usage: null) +``` + + diff --git a/docs/v1/UsageAttributionSort.md b/docs/v1/UsageAttributionSort.md new file mode 100644 index 000000000000..4260c922f5b5 --- /dev/null +++ b/docs/v1/UsageAttributionSort.md @@ -0,0 +1,16 @@ +# DatadogAPIClient::V1::UsageAttributionSort + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- + +## Code Sample + +```ruby +require 'DatadogAPIClient::V1' + +instance = DatadogAPIClient::V1::UsageAttributionSort.new() +``` + + diff --git a/docs/v1/UsageAttributionValues.md b/docs/v1/UsageAttributionValues.md new file mode 100644 index 000000000000..6d1d9f7ef2c1 --- /dev/null +++ b/docs/v1/UsageAttributionValues.md @@ -0,0 +1,51 @@ +# DatadogAPIClient::V1::UsageAttributionValues + +## Properties + +Name | Type | Description | Notes +------------ | ------------- | ------------- | ------------- +**api_percentage** | **Float** | The percentage of synthetic API test usage by tag(s). | [optional] +**api_usage** | **Float** | The synthetic API test usage by tag(s). | [optional] +**apm_host_percentage** | **Float** | The percentage of APM host usage by tag(s). | [optional] +**apm_host_usage** | **Float** | The APM host usage by tag(s). | [optional] +**browser_percentage** | **Float** | The percentage of synthetic browser test usage by tag(s). | [optional] +**browser_usage** | **Float** | The synthetic browser test usage by tag(s). | [optional] +**container_percentage** | **Float** | The percentage of container usage by tag(s). | [optional] +**container_usage** | **Float** | The container usage by tag(s). | [optional] +**custom_timeseries_percentage** | **Float** | The percentage of custom metrics usage by tag(s). | [optional] +**custom_timeseries_usage** | **Float** | The custom metrics usage by tag(s). | [optional] +**infra_host_percentage** | **Float** | The percentage of infrastructure host usage by tag(s). | [optional] +**infra_host_usage** | **Float** | The infrastructure host usage by tag(s). | [optional] +**lambda_percentage** | **Float** | The percentage of lambda function usage by tag(s). | [optional] +**lambda_usage** | **Float** | The lambda function usage by tag(s). | [optional] +**npm_host_percentage** | **Float** | The percentage of network host usage by tag(s). | [optional] +**npm_host_usage** | **Float** | The network host usage by tag(s). | [optional] +**snmp_percentage** | **Float** | The percentage of network device usage by tag(s). | [optional] +**snmp_usage** | **Float** | The network device usage by tag(s). | [optional] + +## Code Sample + +```ruby +require 'DatadogAPIClient::V1' + +instance = DatadogAPIClient::V1::UsageAttributionValues.new(api_percentage: null, + api_usage: null, + apm_host_percentage: null, + apm_host_usage: null, + browser_percentage: null, + browser_usage: null, + container_percentage: null, + container_usage: null, + custom_timeseries_percentage: null, + custom_timeseries_usage: null, + infra_host_percentage: null, + infra_host_usage: null, + lambda_percentage: null, + lambda_usage: null, + npm_host_percentage: null, + npm_host_usage: null, + snmp_percentage: null, + snmp_usage: null) +``` + + diff --git a/docs/v1/UsageMeteringApi.md b/docs/v1/UsageMeteringApi.md index 1fbf5b0e5277..65b12850235a 100644 --- a/docs/v1/UsageMeteringApi.md +++ b/docs/v1/UsageMeteringApi.md @@ -12,6 +12,7 @@ Method | HTTP request | Description [**get_specified_monthly_custom_reports**](UsageMeteringApi.md#get_specified_monthly_custom_reports) | **GET** /api/v1/monthly_custom_reports/{report_id} | Get specified monthly custom reports [**get_tracing_without_limits**](UsageMeteringApi.md#get_tracing_without_limits) | **GET** /api/v1/usage/tracing-without-limits | Get hourly usage for tracing without limits [**get_usage_analyzed_logs**](UsageMeteringApi.md#get_usage_analyzed_logs) | **GET** /api/v1/usage/analyzed_logs | Get hourly usage for analyzed logs +[**get_usage_attribution**](UsageMeteringApi.md#get_usage_attribution) | **GET** /api/v1/usage/attribution | Get Usage Attribution [**get_usage_billable_summary**](UsageMeteringApi.md#get_usage_billable_summary) | **GET** /api/v1/usage/billable-summary | Get billable usage across your multi-org account [**get_usage_fargate**](UsageMeteringApi.md#get_usage_fargate) | **GET** /api/v1/usage/fargate | Get hourly usage for Fargate [**get_usage_hosts**](UsageMeteringApi.md#get_usage_hosts) | **GET** /api/v1/usage/hosts | Get hourly usage for hosts and containers @@ -538,6 +539,77 @@ Name | Type | Description | Notes - **Accept**: application/json;datetime-format=rfc3339 +## get_usage_attribution + +> UsageAttributionResponse get_usage_attribution(start_month, fields, opts) + +Get Usage Attribution + +Get Usage Attribution. + +### Example + +```ruby +# load the gem +require 'datadog_api_client/v1' +# setup authorization +DatadogAPIClient::V1.configure do |config| + # Configure API key authorization: apiKeyAuth + config.api_key['apiKeyAuth'] = ENV["DD_CLIENT_API_KEY"] + # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) + #config.api_key_prefix['apiKeyAuth'] = 'Bearer' + + # Configure API key authorization: appKeyAuth + config.api_key['appKeyAuth'] = ENV["DD_CLIENT_APP_KEY"] + # Uncomment the following line to set a prefix for the API key, e.g. 'Bearer' (defaults to nil) + #config.api_key_prefix['appKeyAuth'] = 'Bearer' +end + +api_instance = DatadogAPIClient::V1::UsageMeteringApi.new +start_month = Time.parse('2013-10-20T19:20:30+01:00') # Time | Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for usage beginning in this month. Maximum of 15 months ago. +fields = 'fields_example' # String | The specified field to search results for. +opts = { + end_month: Time.parse('2013-10-20T19:20:30+01:00'), # Time | Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for usage ending this month. + org_id: 56, # Integer | Include usage summaries for each sub-org. + sort_direction: 'desc', # UsageSortDirection | The direction to sort by: `[desc, asc]`. + sort_name: 'custom_timeseries_usage' # UsageAttributionSort | The field to sort by. +} + +begin + #Get Usage Attribution + result = api_instance.get_usage_attribution(start_month, fields, opts) + p result +rescue DatadogAPIClient::V1::ApiError => e + puts "Exception when calling UsageMeteringApi->get_usage_attribution: #{e}" +end +``` + +### Parameters + + +Name | Type | Description | Notes +------------- | ------------- | ------------- | ------------- + **start_month** | **Time**| Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for usage beginning in this month. Maximum of 15 months ago. | + **fields** | **String**| The specified field to search results for. | + **end_month** | **Time**| Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for usage ending this month. | [optional] + **org_id** | **Integer**| Include usage summaries for each sub-org. | [optional] + **sort_direction** | [**UsageSortDirection**](.md)| The direction to sort by: `[desc, asc]`. | [optional] [default to 'desc'] + **sort_name** | [**UsageAttributionSort**](.md)| The field to sort by. | [optional] [default to 'custom_timeseries_usage'] + +### Return type + +[**UsageAttributionResponse**](UsageAttributionResponse.md) + +### Authorization + +[apiKeyAuth](../README.md#apiKeyAuth), [appKeyAuth](../README.md#appKeyAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json;datetime-format=rfc3339 + + ## get_usage_billable_summary > UsageBillableSummaryResponse get_usage_billable_summary(opts) diff --git a/features/v1/usage_metering.feature b/features/v1/usage_metering.feature index 7a396c7390dc..0f15ba18dd83 100644 --- a/features/v1/usage_metering.feature +++ b/features/v1/usage_metering.feature @@ -179,3 +179,9 @@ Feature: Usage Metering Given new "GetIncidentManagement" request When the request is sent Then the response status is 200 OK + + @generated @skip + Scenario: Get Usage Attribution returns "OK" response + Given new "GetUsageAttribution" request + When the request is sent + Then the response status is 200 OK diff --git a/lib/datadog_api_client/v1.rb b/lib/datadog_api_client/v1.rb index a1066420d285..5ba4e28c267c 100644 --- a/lib/datadog_api_client/v1.rb +++ b/lib/datadog_api_client/v1.rb @@ -336,6 +336,13 @@ require 'datadog_api_client/v1/models/toplist_widget_request' require 'datadog_api_client/v1/models/usage_analyzed_logs_hour' require 'datadog_api_client/v1/models/usage_analyzed_logs_response' +require 'datadog_api_client/v1/models/usage_attribution_aggregates_body' +require 'datadog_api_client/v1/models/usage_attribution_body' +require 'datadog_api_client/v1/models/usage_attribution_metadata' +require 'datadog_api_client/v1/models/usage_attribution_pagination' +require 'datadog_api_client/v1/models/usage_attribution_response' +require 'datadog_api_client/v1/models/usage_attribution_sort' +require 'datadog_api_client/v1/models/usage_attribution_values' require 'datadog_api_client/v1/models/usage_billable_summary_body' require 'datadog_api_client/v1/models/usage_billable_summary_hour' require 'datadog_api_client/v1/models/usage_billable_summary_keys' diff --git a/lib/datadog_api_client/v1/api/usage_metering_api.rb b/lib/datadog_api_client/v1/api/usage_metering_api.rb index d1493fd8267e..8bc1893567f4 100644 --- a/lib/datadog_api_client/v1/api/usage_metering_api.rb +++ b/lib/datadog_api_client/v1/api/usage_metering_api.rb @@ -631,6 +631,99 @@ def get_usage_analyzed_logs_with_http_info(start_hr, opts = {}) return data, status_code, headers end + # Get Usage Attribution + # Get Usage Attribution. + # @param start_month [Time] Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for usage beginning in this month. Maximum of 15 months ago. + # @param fields [String] The specified field to search results for. + # @param [Hash] opts the optional parameters + # @option opts [Time] :end_month Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for usage ending this month. + # @option opts [Integer] :org_id Include usage summaries for each sub-org. + # @option opts [UsageSortDirection] :sort_direction The direction to sort by: `[desc, asc]`. (default to 'desc') + # @option opts [UsageAttributionSort] :sort_name The field to sort by. (default to 'custom_timeseries_usage') + # @return [UsageAttributionResponse] + def get_usage_attribution(start_month, fields, opts = {}) + data, _status_code, _headers = get_usage_attribution_with_http_info(start_month, fields, opts) + data + end + + # Get Usage Attribution + # Get Usage Attribution. + # @param start_month [Time] Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for usage beginning in this month. Maximum of 15 months ago. + # @param fields [String] The specified field to search results for. + # @param [Hash] opts the optional parameters + # @option opts [Time] :end_month Datetime in ISO-8601 format, UTC, precise to month: `[YYYY-MM]` for usage ending this month. + # @option opts [Integer] :org_id Include usage summaries for each sub-org. + # @option opts [UsageSortDirection] :sort_direction The direction to sort by: `[desc, asc]`. + # @option opts [UsageAttributionSort] :sort_name The field to sort by. + # @return [Array<(UsageAttributionResponse, Integer, Hash)>] UsageAttributionResponse data, response status code and response headers + def get_usage_attribution_with_http_info(start_month, fields, opts = {}) + + if @api_client.config.unstable_operations.has_key?(:get_usage_attribution) + unstable_enabled = @api_client.config.unstable_operations[:get_usage_attribution] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "get_usage_attribution") + else + raise ApiError.new(message: format("Unstable operation '%s' is disabled", "get_usage_attribution")) + end + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UsageMeteringApi.get_usage_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_usage_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_usage_attribution" + end + # resource path + local_var_path = '/api/v1/usage/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[:'org_id'] = opts[:'org_id'] if !opts[:'org_id'].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? + + # 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] || 'UsageAttributionResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || ['apiKeyAuth', 'appKeyAuth'] + + new_options = opts.merge( + :operation => :"UsageMeteringApi.get_usage_attribution", + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(:GET, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UsageMeteringApi#get_usage_attribution\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get billable usage across your multi-org account # Get billable usage across your multi-org account. # @param [Hash] opts the optional parameters diff --git a/lib/datadog_api_client/v1/models/usage_attribution_aggregates_body.rb b/lib/datadog_api_client/v1/models/usage_attribution_aggregates_body.rb new file mode 100644 index 000000000000..daea16777131 --- /dev/null +++ b/lib/datadog_api_client/v1/models/usage_attribution_aggregates_body.rb @@ -0,0 +1,232 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 5.0.0-SNAPSHOT + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # The object containing the aggregates. + class UsageAttributionAggregatesBody + # The aggregate type. + attr_accessor :agg_type + + # The field. + attr_accessor :field + + # The value for a given field. + attr_accessor :value + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'agg_type' => :'agg_type', + :'field' => :'field', + :'value' => :'value' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'agg_type' => :'String', + :'field' => :'String', + :'value' => :'Float' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::UsageAttributionAggregatesBody` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::UsageAttributionAggregatesBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'agg_type') + self.agg_type = attributes[:'agg_type'] + end + + if attributes.key?(:'field') + self.field = attributes[:'field'] + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + agg_type == o.agg_type && + field == o.field && + value == o.value + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [agg_type, field, value].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + DatadogAPIClient::V1.const_get(type).build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + 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 + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end +end diff --git a/lib/datadog_api_client/v1/models/usage_attribution_body.rb b/lib/datadog_api_client/v1/models/usage_attribution_body.rb new file mode 100644 index 000000000000..8d92578526b4 --- /dev/null +++ b/lib/datadog_api_client/v1/models/usage_attribution_body.rb @@ -0,0 +1,253 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 5.0.0-SNAPSHOT + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # Usage Summary by tag usage for a given organization. + class UsageAttributionBody + # Datetime in ISO-8601 format, UTC, precise to month: [YYYY-MM]. + attr_accessor :month + + # The organization public ID. + attr_accessor :public_id + + # Usage Summary by tag names. + attr_accessor :tags + + # Shows the the most recent hour in the current months for all organizations for which all usages were calculated. + attr_accessor :updated_at + + attr_accessor :values + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'month' => :'month', + :'public_id' => :'public_id', + :'tags' => :'tags', + :'updated_at' => :'updated_at', + :'values' => :'values' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'month' => :'Time', + :'public_id' => :'String', + :'tags' => :'Hash>', + :'updated_at' => :'String', + :'values' => :'UsageAttributionValues' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::UsageAttributionBody` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::UsageAttributionBody`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'month') + self.month = attributes[:'month'] + end + + if attributes.key?(:'public_id') + self.public_id = attributes[:'public_id'] + end + + if attributes.key?(:'tags') + if (value = attributes[:'tags']).is_a?(Hash) + self.tags = value + end + end + + if attributes.key?(:'updated_at') + self.updated_at = attributes[:'updated_at'] + end + + if attributes.key?(:'values') + self.values = attributes[:'values'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + month == o.month && + public_id == o.public_id && + tags == o.tags && + updated_at == o.updated_at && + values == o.values + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [month, public_id, tags, updated_at, values].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + DatadogAPIClient::V1.const_get(type).build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + 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 + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end +end diff --git a/lib/datadog_api_client/v1/models/usage_attribution_metadata.rb b/lib/datadog_api_client/v1/models/usage_attribution_metadata.rb new file mode 100644 index 000000000000..e996150ab473 --- /dev/null +++ b/lib/datadog_api_client/v1/models/usage_attribution_metadata.rb @@ -0,0 +1,223 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 5.0.0-SNAPSHOT + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # The object containing document metadata. + class UsageAttributionMetadata + # An array of available aggregates. + attr_accessor :aggregates + + attr_accessor :pagination + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'aggregates' => :'aggregates', + :'pagination' => :'pagination' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'aggregates' => :'Array', + :'pagination' => :'UsageAttributionPagination' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::UsageAttributionMetadata` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::UsageAttributionMetadata`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'aggregates') + if (value = attributes[:'aggregates']).is_a?(Array) + self.aggregates = value + end + end + + if attributes.key?(:'pagination') + self.pagination = attributes[:'pagination'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + aggregates == o.aggregates && + pagination == o.pagination + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [aggregates, pagination].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + DatadogAPIClient::V1.const_get(type).build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + 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 + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end +end diff --git a/lib/datadog_api_client/v1/models/usage_attribution_pagination.rb b/lib/datadog_api_client/v1/models/usage_attribution_pagination.rb new file mode 100644 index 000000000000..a1a476fa28c8 --- /dev/null +++ b/lib/datadog_api_client/v1/models/usage_attribution_pagination.rb @@ -0,0 +1,252 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 5.0.0-SNAPSHOT + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # The page count for the current pagination. + class UsageAttributionPagination + # Maximum amount of records to be returned. + attr_accessor :limit + + # Records to be skipped before beginning to return. + attr_accessor :offset + + # Direction to sort by. + attr_accessor :sort_direction + + # Field to sort by. + attr_accessor :sort_name + + # Total number of records. + attr_accessor :total_number_of_records + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'limit' => :'limit', + :'offset' => :'offset', + :'sort_direction' => :'sort_direction', + :'sort_name' => :'sort_name', + :'total_number_of_records' => :'total_number_of_records' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'limit' => :'Integer', + :'offset' => :'Integer', + :'sort_direction' => :'String', + :'sort_name' => :'String', + :'total_number_of_records' => :'Integer' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::UsageAttributionPagination` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::UsageAttributionPagination`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'limit') + self.limit = attributes[:'limit'] + end + + if attributes.key?(:'offset') + self.offset = attributes[:'offset'] + end + + if attributes.key?(:'sort_direction') + self.sort_direction = attributes[:'sort_direction'] + end + + if attributes.key?(:'sort_name') + self.sort_name = attributes[:'sort_name'] + end + + if attributes.key?(:'total_number_of_records') + self.total_number_of_records = attributes[:'total_number_of_records'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + limit == o.limit && + offset == o.offset && + sort_direction == o.sort_direction && + sort_name == o.sort_name && + total_number_of_records == o.total_number_of_records + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [limit, offset, sort_direction, sort_name, total_number_of_records].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + DatadogAPIClient::V1.const_get(type).build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + 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 + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end +end diff --git a/lib/datadog_api_client/v1/models/usage_attribution_response.rb b/lib/datadog_api_client/v1/models/usage_attribution_response.rb new file mode 100644 index 000000000000..45dea32c83e4 --- /dev/null +++ b/lib/datadog_api_client/v1/models/usage_attribution_response.rb @@ -0,0 +1,223 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 5.0.0-SNAPSHOT + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # Response containing the Usage Summary by tag(s). + class UsageAttributionResponse + attr_accessor :metadata + + # Get Usage Summary by tag(s). + attr_accessor :usage + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'metadata' => :'metadata', + :'usage' => :'usage' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'metadata' => :'UsageAttributionMetadata', + :'usage' => :'Array' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::UsageAttributionResponse` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::UsageAttributionResponse`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'metadata') + self.metadata = attributes[:'metadata'] + end + + if attributes.key?(:'usage') + if (value = attributes[:'usage']).is_a?(Array) + self.usage = value + end + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + metadata == o.metadata && + usage == o.usage + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [metadata, usage].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + DatadogAPIClient::V1.const_get(type).build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + 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 + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end +end diff --git a/lib/datadog_api_client/v1/models/usage_attribution_sort.rb b/lib/datadog_api_client/v1/models/usage_attribution_sort.rb new file mode 100644 index 000000000000..bd7e4c5970d7 --- /dev/null +++ b/lib/datadog_api_client/v1/models/usage_attribution_sort.rb @@ -0,0 +1,53 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 5.0.0-SNAPSHOT + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + class UsageAttributionSort + API_PERCENTAGE = "api_percentage".freeze + SNMP_USAGE = "snmp_usage".freeze + LAMBDA_PERCENTAGE = "lambda_percentage".freeze + APM_HOST_USAGE = "apm_host_usage".freeze + API_USAGE = "api_usage".freeze + CONTAINER_USAGE = "container_usage".freeze + CUSTOM_TIMESERIES_PERCENTAGE = "custom_timeseries_percentage".freeze + CONTAINER_PERCENTAGE = "container_percentage".freeze + LAMBDA_USAGE = "lambda_usage".freeze + APM_HOST_PERCENTAGE = "apm_host_percentage".freeze + NPM_HOST_PERCENTAGE = "npm_host_percentage".freeze + BROWSER_PERCENTAGE = "browser_percentage".freeze + BROWSER_USAGE = "browser_usage".freeze + INFRA_HOST_PERCENTAGE = "infra_host_percentage".freeze + SNMP_PERCENTAGE = "snmp_percentage".freeze + NPM_HOST_USAGE = "npm_host_usage".freeze + INFRA_HOST_USAGE = "infra_host_usage".freeze + CUSTOM_TIMESERIES_USAGE = "custom_timeseries_usage".freeze + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def self.build_from_hash(value) + new.build_from_hash(value) + end + + # Builds the enum from string + # @param [String] The enum value in the form of the string + # @return [String] The enum value + def build_from_hash(value) + constantValues = UsageAttributionSort.constants.select { |c| UsageAttributionSort::const_get(c) == value } + raise "Invalid ENUM value #{value} for class #UsageAttributionSort" if constantValues.empty? + value + end + end +end diff --git a/lib/datadog_api_client/v1/models/usage_attribution_values.rb b/lib/datadog_api_client/v1/models/usage_attribution_values.rb new file mode 100644 index 000000000000..e24d861569c1 --- /dev/null +++ b/lib/datadog_api_client/v1/models/usage_attribution_values.rb @@ -0,0 +1,382 @@ +=begin +#Datadog API V1 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://openapi-generator.tech +OpenAPI Generator version: 5.0.0-SNAPSHOT + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V1 + # Fields in Usage Summary by tag(s). + class UsageAttributionValues + # The percentage of synthetic API test usage by tag(s). + attr_accessor :api_percentage + + # The synthetic API test usage by tag(s). + attr_accessor :api_usage + + # The percentage of APM host usage by tag(s). + attr_accessor :apm_host_percentage + + # The APM host usage by tag(s). + attr_accessor :apm_host_usage + + # The percentage of synthetic browser test usage by tag(s). + attr_accessor :browser_percentage + + # The synthetic browser test usage by tag(s). + attr_accessor :browser_usage + + # The percentage of container usage by tag(s). + attr_accessor :container_percentage + + # The container usage by tag(s). + attr_accessor :container_usage + + # The percentage of custom metrics usage by tag(s). + attr_accessor :custom_timeseries_percentage + + # The custom metrics usage by tag(s). + attr_accessor :custom_timeseries_usage + + # The percentage of infrastructure host usage by tag(s). + attr_accessor :infra_host_percentage + + # The infrastructure host usage by tag(s). + attr_accessor :infra_host_usage + + # The percentage of lambda function usage by tag(s). + attr_accessor :lambda_percentage + + # The lambda function usage by tag(s). + attr_accessor :lambda_usage + + # The percentage of network host usage by tag(s). + attr_accessor :npm_host_percentage + + # The network host usage by tag(s). + attr_accessor :npm_host_usage + + # The percentage of network device usage by tag(s). + attr_accessor :snmp_percentage + + # The network device usage by tag(s). + attr_accessor :snmp_usage + + # Attribute mapping from ruby-style variable name to JSON key. + def self.attribute_map + { + :'api_percentage' => :'api_percentage', + :'api_usage' => :'api_usage', + :'apm_host_percentage' => :'apm_host_percentage', + :'apm_host_usage' => :'apm_host_usage', + :'browser_percentage' => :'browser_percentage', + :'browser_usage' => :'browser_usage', + :'container_percentage' => :'container_percentage', + :'container_usage' => :'container_usage', + :'custom_timeseries_percentage' => :'custom_timeseries_percentage', + :'custom_timeseries_usage' => :'custom_timeseries_usage', + :'infra_host_percentage' => :'infra_host_percentage', + :'infra_host_usage' => :'infra_host_usage', + :'lambda_percentage' => :'lambda_percentage', + :'lambda_usage' => :'lambda_usage', + :'npm_host_percentage' => :'npm_host_percentage', + :'npm_host_usage' => :'npm_host_usage', + :'snmp_percentage' => :'snmp_percentage', + :'snmp_usage' => :'snmp_usage' + } + end + + # Attribute type mapping. + def self.openapi_types + { + :'api_percentage' => :'Float', + :'api_usage' => :'Float', + :'apm_host_percentage' => :'Float', + :'apm_host_usage' => :'Float', + :'browser_percentage' => :'Float', + :'browser_usage' => :'Float', + :'container_percentage' => :'Float', + :'container_usage' => :'Float', + :'custom_timeseries_percentage' => :'Float', + :'custom_timeseries_usage' => :'Float', + :'infra_host_percentage' => :'Float', + :'infra_host_usage' => :'Float', + :'lambda_percentage' => :'Float', + :'lambda_usage' => :'Float', + :'npm_host_percentage' => :'Float', + :'npm_host_usage' => :'Float', + :'snmp_percentage' => :'Float', + :'snmp_usage' => :'Float' + } + end + + # List of attributes with nullable: true + def self.openapi_nullable + Set.new([ + ]) + end + + # Initializes the object + # @param [Hash] attributes Model attributes in the form of hash + def initialize(attributes = {}) + if (!attributes.is_a?(Hash)) + fail ArgumentError, "The input argument (attributes) must be a hash in `DatadogAPIClient::V1::UsageAttributionValues` initialize method" + end + + # 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)) + fail ArgumentError, "`#{k}` is not a valid attribute in `DatadogAPIClient::V1::UsageAttributionValues`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect + end + h[k.to_sym] = v + } + + if attributes.key?(:'api_percentage') + self.api_percentage = attributes[:'api_percentage'] + end + + if attributes.key?(:'api_usage') + self.api_usage = attributes[:'api_usage'] + end + + if attributes.key?(:'apm_host_percentage') + self.apm_host_percentage = attributes[:'apm_host_percentage'] + end + + if attributes.key?(:'apm_host_usage') + self.apm_host_usage = attributes[:'apm_host_usage'] + end + + if attributes.key?(:'browser_percentage') + self.browser_percentage = attributes[:'browser_percentage'] + end + + if attributes.key?(:'browser_usage') + self.browser_usage = attributes[:'browser_usage'] + end + + if attributes.key?(:'container_percentage') + self.container_percentage = attributes[:'container_percentage'] + end + + if attributes.key?(:'container_usage') + self.container_usage = attributes[:'container_usage'] + end + + if attributes.key?(:'custom_timeseries_percentage') + self.custom_timeseries_percentage = attributes[:'custom_timeseries_percentage'] + end + + if attributes.key?(:'custom_timeseries_usage') + self.custom_timeseries_usage = attributes[:'custom_timeseries_usage'] + end + + if attributes.key?(:'infra_host_percentage') + self.infra_host_percentage = attributes[:'infra_host_percentage'] + end + + if attributes.key?(:'infra_host_usage') + self.infra_host_usage = attributes[:'infra_host_usage'] + end + + if attributes.key?(:'lambda_percentage') + self.lambda_percentage = attributes[:'lambda_percentage'] + end + + if attributes.key?(:'lambda_usage') + self.lambda_usage = attributes[:'lambda_usage'] + end + + if attributes.key?(:'npm_host_percentage') + self.npm_host_percentage = attributes[:'npm_host_percentage'] + end + + if attributes.key?(:'npm_host_usage') + self.npm_host_usage = attributes[:'npm_host_usage'] + end + + if attributes.key?(:'snmp_percentage') + self.snmp_percentage = attributes[:'snmp_percentage'] + end + + if attributes.key?(:'snmp_usage') + self.snmp_usage = attributes[:'snmp_usage'] + end + end + + # Show invalid properties with the reasons. Usually used together with valid? + # @return Array for valid properties with the reasons + def list_invalid_properties + invalid_properties = Array.new + invalid_properties + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + def valid? + true + end + + # Checks equality by comparing each attribute. + # @param [Object] Object to be compared + def ==(o) + return true if self.equal?(o) + self.class == o.class && + api_percentage == o.api_percentage && + api_usage == o.api_usage && + apm_host_percentage == o.apm_host_percentage && + apm_host_usage == o.apm_host_usage && + browser_percentage == o.browser_percentage && + browser_usage == o.browser_usage && + container_percentage == o.container_percentage && + container_usage == o.container_usage && + custom_timeseries_percentage == o.custom_timeseries_percentage && + custom_timeseries_usage == o.custom_timeseries_usage && + infra_host_percentage == o.infra_host_percentage && + infra_host_usage == o.infra_host_usage && + lambda_percentage == o.lambda_percentage && + lambda_usage == o.lambda_usage && + npm_host_percentage == o.npm_host_percentage && + npm_host_usage == o.npm_host_usage && + snmp_percentage == o.snmp_percentage && + snmp_usage == o.snmp_usage + end + + # @see the `==` method + # @param [Object] Object to be compared + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + def hash + [api_percentage, api_usage, apm_host_percentage, apm_host_usage, browser_percentage, browser_usage, container_percentage, container_usage, custom_timeseries_percentage, custom_timeseries_usage, infra_host_percentage, infra_host_usage, lambda_percentage, lambda_usage, npm_host_percentage, npm_host_usage, snmp_percentage, snmp_usage].hash + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def self.build_from_hash(attributes) + new.build_from_hash(attributes) + end + + # Builds the object from hash + # @param [Hash] attributes Model attributes in the form of hash + # @return [Object] Returns the model itself + def build_from_hash(attributes) + return nil unless attributes.is_a?(Hash) + self.class.openapi_types.each_pair do |key, type| + if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) + self.send("#{key}=", nil) + elsif type =~ /\AArray<(.*)>/i + # check to ensure the input is an array given that the attribute + # is documented as an array but the input is not + if attributes[self.class.attribute_map[key]].is_a?(Array) + self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) + end + elsif !attributes[self.class.attribute_map[key]].nil? + self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) + end + end + + self + end + + # Deserializes the data based on type + # @param string type Data type + # @param string value Value to be deserialized + # @return [Object] Deserialized data + def _deserialize(type, value) + case type.to_sym + when :Time + Time.parse(value) + when :Date + Date.parse(value) + when :String + value.to_s + when :Integer + value.to_i + when :Float + value.to_f + when :Boolean + if value.to_s =~ /\A(true|t|yes|y|1)\z/i + true + else + false + end + when :Object + # generic object (usually a Hash), return directly + value + when /\AArray<(?.+)>\z/ + inner_type = Regexp.last_match[:inner_type] + value.map { |v| _deserialize(inner_type, v) } + when /\AHash<(?.+?), (?.+)>\z/ + k_type = Regexp.last_match[:k_type] + v_type = Regexp.last_match[:v_type] + {}.tap do |hash| + value.each do |k, v| + hash[_deserialize(k_type, k)] = _deserialize(v_type, v) + end + end + else # model + DatadogAPIClient::V1.const_get(type).build_from_hash(value) + end + end + + # Returns the string representation of the object + # @return [String] String presentation of the object + def to_s + to_hash.to_s + end + + # to_body is an alias to to_hash (backward compatibility) + # @return [Hash] Returns the object in the form of hash + def to_body + to_hash + end + + # Returns the object in the form of hash + # @return [Hash] Returns the object in the form of hash + 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 + hash + end + + # Outputs non-array value in the form of hash + # For object, use to_hash. Otherwise, just return the value + # @param [Object] value Any valid value + # @return [Hash] Returns the value in the form of hash + def _to_hash(value) + if value.is_a?(Array) + value.compact.map { |v| _to_hash(v) } + elsif value.is_a?(Hash) + {}.tap do |hash| + value.each { |k, v| hash[k] = _to_hash(v) } + end + elsif value.respond_to? :to_hash + value.to_hash + else + value + end + end + + end +end