diff --git a/.apigentools-info b/.apigentools-info index 4207af802633..97cf1394ea32 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.2", - "regenerated": "2022-07-19 15:15:22.045487", - "spec_repo_commit": "d2c0157b" + "regenerated": "2022-07-19 16:28:25.621288", + "spec_repo_commit": "448d6aae" }, "v2": { "apigentools_version": "1.6.2", - "regenerated": "2022-07-19 15:15:22.084854", - "spec_repo_commit": "d2c0157b" + "regenerated": "2022-07-19 16:28:25.640110", + "spec_repo_commit": "448d6aae" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 64d9b05edf97..dce734d240dc 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1683,6 +1683,84 @@ components: required: - message type: object + HourlyUsage: + description: Hourly usage for a product family for an org. + properties: + attributes: + $ref: '#/components/schemas/HourlyUsageAttributes' + id: + description: Unique ID of the response. + type: string + type: + $ref: '#/components/schemas/UsageTimeSeriesType' + type: object + HourlyUsageAttributes: + description: Attributes of hourly usage for a product family for an org for + a time period. + properties: + measurements: + description: List of the measured usage values for the product family for + the org for the time period. + items: + $ref: '#/components/schemas/HourlyUsageMeasurement' + type: array + org_name: + description: The organization name. + type: string + product_family: + description: The product for which usage is being reported. + type: string + public_id: + description: The organization public ID. + type: string + region: + description: The region of the Datadog instance that the organization belongs + to. + type: string + timestamp: + description: Datetime in ISO-8601 format, UTC. The hour for the usage. + format: date-time + type: string + type: object + HourlyUsageMeasurement: + description: Usage amount for a given usage type. + properties: + usage_type: + description: Type of usage. + type: string + value: + description: Contains the number measured for the given usage_type during + the hour. + format: int64 + nullable: true + type: integer + type: object + HourlyUsageMetadata: + description: The object containing document metadata. + properties: + pagination: + $ref: '#/components/schemas/HourlyUsagePagination' + type: object + HourlyUsagePagination: + description: The metadata for the current pagination. + properties: + next_record_id: + description: The cursor to get the next results (if any). To make the next + request, use the same parameters and add `next_record_id`. + nullable: true + type: string + type: object + HourlyUsageResponse: + description: Hourly usage response. + properties: + data: + description: Response containing hourly usage. + items: + $ref: '#/components/schemas/HourlyUsage' + type: array + meta: + $ref: '#/components/schemas/HourlyUsageMetadata' + type: object HourlyUsageType: description: Usage type that is being measured. enum: @@ -13382,6 +13460,120 @@ paths: x-menu-order: 39 x-undo: type: safe + /api/v2/usage/hourly_usage: + get: + description: Get hourly usage by product family + operationId: GetHourlyUsage + parameters: + - description: 'Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] + for usage beginning at this hour.' + in: query + name: filter[timestamp][start] + required: true + schema: + format: date-time + type: string + - description: 'Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] + for usage ending **before** this hour.' + in: query + name: filter[timestamp][end] + required: false + schema: + format: date-time + type: string + - description: 'Comma separated list of product families to retrieve. Available + families are `all`, `analyzed_logs`, + + `application_security`, `audit_logs`, `serverless`, `ci_app`, `cspm`, `cws`, + `dbm`, `fargate`, + + `infra_hosts`, `incident_management`, `indexed_logs`, `indexed_spans`, `ingested_spans`, + `iot`, + + `lambda_traced_invocations`, `logs`, `network_flows`, `network_hosts`, `observability_pipelines`, + + `online_archive`, `profiling`, `rum`, `rum_browser_sessions`, `rum_mobile_sessions`, + `sds`, `snmp`, + + `synthetics_api`, `synthetics_browser`, and `timeseries`.' + in: query + name: filter[product_families] + required: true + schema: + type: string + - description: Include child org usage in the response. Defaults to false. + in: query + name: filter[include_descendants] + required: false + schema: + default: false + type: boolean + - description: 'Comma separated list of product family versions to use in the + format `product_family:version`. For example, + + `infra_hosts:1.0.0`. If this parameter is not used, the API will use the + latest version of each requested + + product family. Currently all families have one version `1.0.0`.' + in: query + name: filter[versions] + required: false + schema: + type: string + - description: Maximum number of results to return (between 1 and 500) - defaults + to 500 if limit not specified. + in: query + name: page[limit] + required: false + schema: + default: 500 + format: int32 + maximum: 500 + minimum: 1 + type: integer + - description: List following results with a next_record_id provided in the + previous query. + in: query + name: page[next_record_id] + required: false + schema: + type: string + responses: + '200': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/HourlyUsageResponse' + description: OK + '400': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Bad Request + '403': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/APIErrorResponse' + 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 hourly usage by product family + tags: + - Usage Metering + x-menu-order: 40 + x-undo: + type: safe /api/v2/usage/lambda_traced_invocations: get: description: Get hourly usage for Lambda Traced Invocations. diff --git a/cassettes/features/v2/usage_metering/Get-hourly-usage-by-product-family-returns-Bad-Request-response.frozen b/cassettes/features/v2/usage_metering/Get-hourly-usage-by-product-family-returns-Bad-Request-response.frozen new file mode 100644 index 000000000000..ae53da8685e0 --- /dev/null +++ b/cassettes/features/v2/usage_metering/Get-hourly-usage-by-product-family-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2022-07-19T14:57:41.335Z \ No newline at end of file diff --git a/cassettes/features/v2/usage_metering/Get-hourly-usage-by-product-family-returns-Bad-Request-response.yml b/cassettes/features/v2/usage_metering/Get-hourly-usage-by-product-family-returns-Bad-Request-response.yml new file mode 100644 index 000000000000..b146b0caa9d0 --- /dev/null +++ b/cassettes/features/v2/usage_metering/Get-hourly-usage-by-product-family-returns-Bad-Request-response.yml @@ -0,0 +1,22 @@ +http_interactions: +- recorded_at: Tue, 19 Jul 2022 14:57:41 GMT + request: + body: null + headers: + Accept: + - application/json;datetime-format=rfc3339 + method: GET + uri: https://api.datadoghq.com/api/v2/usage/hourly_usage?filter%5Btimestamp%5D%5Bstart%5D=2022-07-16T14%3A57%3A41.335Z&filter%5Btimestamp%5D%5Bend%5D=2022-07-14T14%3A57%3A41.335Z&filter%5Bproduct_families%5D=infra_hosts + response: + body: + encoding: UTF-8 + string: '{"errors":["start_hr [YYYY-MM-DDThh] must be before end_hr [YYYY-MM-DDThh]"]} + + ' + headers: + Content-Type: + - application/json + status: + code: 400 + message: Bad Request +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v2/usage_metering/Get-hourly-usage-by-product-family-returns-OK-response.frozen b/cassettes/features/v2/usage_metering/Get-hourly-usage-by-product-family-returns-OK-response.frozen new file mode 100644 index 000000000000..306317fb78d5 --- /dev/null +++ b/cassettes/features/v2/usage_metering/Get-hourly-usage-by-product-family-returns-OK-response.frozen @@ -0,0 +1 @@ +2022-07-19T14:57:41.821Z \ No newline at end of file diff --git a/cassettes/features/v2/usage_metering/Get-hourly-usage-by-product-family-returns-OK-response.yml b/cassettes/features/v2/usage_metering/Get-hourly-usage-by-product-family-returns-OK-response.yml new file mode 100644 index 000000000000..9d3fb1e80841 --- /dev/null +++ b/cassettes/features/v2/usage_metering/Get-hourly-usage-by-product-family-returns-OK-response.yml @@ -0,0 +1,45 @@ +http_interactions: +- recorded_at: Tue, 19 Jul 2022 14:57:41 GMT + request: + body: null + headers: + Accept: + - application/json;datetime-format=rfc3339 + method: GET + uri: https://api.datadoghq.com/api/v2/usage/hourly_usage?filter%5Btimestamp%5D%5Bstart%5D=2022-07-16T14%3A57%3A41.821Z&filter%5Bproduct_families%5D=infra_hosts + response: + body: + encoding: UTF-8 + string: '{"data":[{"attributes":{"org_name":"DD Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-16T14:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"c2d81d3ab0e2330402ba194f525ac02b0e561dbaf1e30fdc9d900551ca104e6c"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-16T15:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"aab388e6fa569317272aec7a7b8769bf6400c8b3e3163e34c5ba8fc8b1ea962c"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-16T16:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"a7480a9641c6bb5609a623c24f9be58f6bd0e0f8b39c23813be2e5e9f37465df"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-16T17:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"3ece398146b5e6863932aaabb340a35dc3f678a10b8731dd1aa6cefb01a05a50"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-16T18:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"db5610645e040ceb1e34726488331e256688b629700b0fab78c62ed4e681232e"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-16T19:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"317972994b0ef9e9c7b003ab0f1a28db970c738229bc8eb99b5f40863bd31ae7"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-16T20:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"7b4af48ad0743367a787bff94d6fb23dc4f6bd1721846b656aefcaa0c97094af"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-16T21:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"a26d4f98ebefc52c3e3ff41947df05bf792c12fff32a450c208b8a5579ea636c"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-16T22:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"284445d0d64b997e3a799f9a9c0b37a75979f17da92d3b87c102b334ff2e8c55"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-16T23:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"27cd01fcc3390288a50d1e9bd56fdf2e65db299ff59fd167eae5dcc6afefacbe"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-17T00:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"31c2b4d1ad3e227ee84c29aca58c3a82fa29d334434d9192c7c488ab125a831c"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-17T01:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"773dd70bab3e291c460d1263d4b8f2fed2f649b5c31227acd34819b6b8fa93cf"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-17T02:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"adda5d505c6d83890ca97ecdfd9d0dab915da014b4b87abd43a909c3453cb60d"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-17T03:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"d7b5724fb49109e31700bf34aa6527e0a097359f3917288c351617d5042e6930"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-17T04:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"826bc80a5789a931a674eecf3491b3aea9cf11a01749f57ae45496c7bede96a7"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-17T05:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"b8f4c50da05e3413a2618ec30ae193482b28ef2eb318541de68751ad32f267d0"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-17T06:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"bc403917f58538e7cc57934de186bb0975e1667780030e77464c46bcc07a108e"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-17T07:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"15aff389986ebee357e66194ba015afcf4ce87f262e0cbe635fda457abf36bbb"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-17T08:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"a92fa8990a961de5fbc1813a004587fc01eba595bd382d75b85fe88e63bafea6"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-17T09:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"a8c6b8633bb710eb4eff1bdb6046354635b9bb1e99c3de3fd2f4efab6a5c177f"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-17T10:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"6623ba9e88fb7491794d262f121dec195afb88ac8a85653805c8dff1b604da1c"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-17T11:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"b690150b84610dbc7a4fd2c37da96e69bc43ce8ce7ee51af7d47c32054c6df44"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-17T12:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"a03a5f4b9967b962f1de6cc80b696e3a1562ff733834b8cec6540f9cb884236b"},{"attributes":{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","timestamp":"2022-07-17T13:00:00+00:00","region":"us","measurements":[{"usage_type":"agent_host_count","value":14},{"usage_type":"alibaba_host_count","value":0},{"usage_type":"apm_azure_app_service_host_count","value":0},{"usage_type":"apm_host_count","value":4},{"usage_type":"aws_host_count","value":0},{"usage_type":"azure_host_count","value":0},{"usage_type":"container_count","value":null},{"usage_type":"gcp_host_count","value":0},{"usage_type":"heroku_host_count","value":0},{"usage_type":"host_count","value":14},{"usage_type":"infra_azure_app_service","value":0},{"usage_type":"opentelemetry_host_count","value":0},{"usage_type":"vsphere_host_count","value":0}],"product_family":"infra_hosts"},"type":"usage_timeseries","id":"07e22e70cfb7efe81ffdd0265cdea8417b0fbf4d9e8cb9f862bbff581fe7e5ac"}]} + + ' + headers: + Content-Type: + - application/json + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/features/v2/undo.json b/features/v2/undo.json index 2e43ba5c8002..e30e412c859f 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -867,6 +867,12 @@ "type": "safe" } }, + "GetHourlyUsage": { + "tag": "Usage Metering", + "undo": { + "type": "safe" + } + }, "GetUsageLambdaTracedInvocations": { "tag": "Usage Metering", "undo": { diff --git a/features/v2/usage_metering.feature b/features/v2/usage_metering.feature index c5d528f996d3..39352e607292 100644 --- a/features/v2/usage_metering.feature +++ b/features/v2/usage_metering.feature @@ -58,6 +58,23 @@ Feature: Usage Metering When the request is sent Then the response status is 200 OK + @team:DataDog/red-zone-revenue-query + Scenario: Get hourly usage by product family returns "Bad Request" response + Given new "GetHourlyUsage" request + And request contains "filter[timestamp][start]" parameter with value "{{ timeISO('now - 3d') }}" + And request contains "filter[product_families]" parameter with value "infra_hosts" + And request contains "filter[timestamp][end]" parameter with value "{{ timeISO('now - 5d') }}" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/red-zone-revenue-query + Scenario: Get hourly usage by product family returns "OK" response + Given new "GetHourlyUsage" request + And request contains "filter[timestamp][start]" parameter with value "{{ timeISO('now - 3d') }}" + And request contains "filter[product_families]" parameter with value "infra_hosts" + When the request is sent + Then the response status is 200 OK + @team:DataDog/red-zone-revenue-query Scenario: Get hourly usage for Application Security returns "Bad Request" response Given new "GetUsageApplicationSecurityMonitoring" request diff --git a/lib/datadog_api_client/v2.rb b/lib/datadog_api_client/v2.rb index 709744ef60fe..bc25afe2fbbf 100644 --- a/lib/datadog_api_client/v2.rb +++ b/lib/datadog_api_client/v2.rb @@ -111,6 +111,12 @@ require 'datadog_api_client/v2/models/full_api_key_attributes' require 'datadog_api_client/v2/models/full_application_key' require 'datadog_api_client/v2/models/full_application_key_attributes' +require 'datadog_api_client/v2/models/hourly_usage' +require 'datadog_api_client/v2/models/hourly_usage_attributes' +require 'datadog_api_client/v2/models/hourly_usage_measurement' +require 'datadog_api_client/v2/models/hourly_usage_metadata' +require 'datadog_api_client/v2/models/hourly_usage_pagination' +require 'datadog_api_client/v2/models/hourly_usage_response' require 'datadog_api_client/v2/models/hourly_usage_type' require 'datadog_api_client/v2/models/http_log_error' require 'datadog_api_client/v2/models/http_log_errors' 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 eeaeb04252e1..8743a8f11215 100644 --- a/lib/datadog_api_client/v2/api/usage_metering_api.rb +++ b/lib/datadog_api_client/v2/api/usage_metering_api.rb @@ -175,6 +175,102 @@ def get_estimated_cost_by_org_with_http_info(opts = {}) return data, status_code, headers end + # Get hourly usage by product family. + # + # @see #get_hourly_usage_with_http_info + def get_hourly_usage(filter_timestamp_start, filter_product_families, opts = {}) + data, _status_code, _headers = get_hourly_usage_with_http_info(filter_timestamp_start, filter_product_families, opts) + data + end + + # Get hourly usage by product family. + # + # Get hourly usage by product family + # + # @param filter_timestamp_start [Time] Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage beginning at this hour. + # @param filter_product_families [String] Comma separated list of product families to retrieve. Available families are `all`, `analyzed_logs`, `application_security`, `audit_logs`, `serverless`, `ci_app`, `cspm`, `cws`, `dbm`, `fargate`, `infra_hosts`, `incident_management`, `indexed_logs`, `indexed_spans`, `ingested_spans`, `iot`, `lambda_traced_invocations`, `logs`, `network_flows`, `network_hosts`, `observability_pipelines`, `online_archive`, `profiling`, `rum`, `rum_browser_sessions`, `rum_mobile_sessions`, `sds`, `snmp`, `synthetics_api`, `synthetics_browser`, and `timeseries`. + # @param opts [Hash] the optional parameters + # @option opts [Time] :filter_timestamp_end Datetime in ISO-8601 format, UTC, precise to hour: [YYYY-MM-DDThh] for usage ending **before** this hour. + # @option opts [Boolean] :filter_include_descendants Include child org usage in the response. Defaults to false. + # @option opts [String] :filter_versions Comma separated list of product family versions to use in the format `product_family:version`. For example, `infra_hosts:1.0.0`. If this parameter is not used, the API will use the latest version of each requested product family. Currently all families have one version `1.0.0`. + # @option opts [Integer] :page_limit Maximum number of results to return (between 1 and 500) - defaults to 500 if limit not specified. + # @option opts [String] :page_next_record_id List following results with a next_record_id provided in the previous query. + # @return [Array<(HourlyUsageResponse, Integer, Hash)>] HourlyUsageResponse data, response status code and response headers + def get_hourly_usage_with_http_info(filter_timestamp_start, filter_product_families, opts = {}) + + if @api_client.config.unstable_operations.has_key?(:get_hourly_usage) + unstable_enabled = @api_client.config.unstable_operations[:get_hourly_usage] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "get_hourly_usage") + else + raise APIError.new(message: format("Unstable operation '%s' is disabled", "get_hourly_usage")) + end + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_hourly_usage ...' + end + # verify the required parameter 'filter_timestamp_start' is set + if @api_client.config.client_side_validation && filter_timestamp_start.nil? + fail ArgumentError, "Missing the required parameter 'filter_timestamp_start' when calling UsageMeteringAPI.get_hourly_usage" + end + # verify the required parameter 'filter_product_families' is set + if @api_client.config.client_side_validation && filter_product_families.nil? + fail ArgumentError, "Missing the required parameter 'filter_product_families' when calling UsageMeteringAPI.get_hourly_usage" + end + if @api_client.config.client_side_validation && !opts[:'page_limit'].nil? && opts[:'page_limit'] > 500 + fail ArgumentError, 'invalid value for "opts[:"page_limit"]" when calling UsageMeteringAPI.get_hourly_usage, must be smaller than or equal to 500.' + end + if @api_client.config.client_side_validation && !opts[:'page_limit'].nil? && opts[:'page_limit'] < 1 + fail ArgumentError, 'invalid value for "opts[:"page_limit"]" when calling UsageMeteringAPI.get_hourly_usage, must be greater than or equal to 1.' + end + # resource path + local_var_path = '/api/v2/usage/hourly_usage' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'filter[timestamp][start]'] = filter_timestamp_start + query_params[:'filter[product_families]'] = filter_product_families + query_params[:'filter[timestamp][end]'] = opts[:'filter_timestamp_end'] if !opts[:'filter_timestamp_end'].nil? + query_params[:'filter[include_descendants]'] = opts[:'filter_include_descendants'] if !opts[:'filter_include_descendants'].nil? + query_params[:'filter[versions]'] = opts[:'filter_versions'] if !opts[:'filter_versions'].nil? + query_params[:'page[limit]'] = opts[:'page_limit'] if !opts[:'page_limit'].nil? + query_params[:'page[next_record_id]'] = opts[:'page_next_record_id'] if !opts[:'page_next_record_id'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json;datetime-format=rfc3339']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'HourlyUsageResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :get_hourly_usage, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UsageMeteringAPI#get_hourly_usage\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get hourly usage for Application Security. # # @see #get_usage_application_security_monitoring_with_http_info diff --git a/lib/datadog_api_client/v2/models/hourly_usage.rb b/lib/datadog_api_client/v2/models/hourly_usage.rb new file mode 100644 index 000000000000..99590f508544 --- /dev/null +++ b/lib/datadog_api_client/v2/models/hourly_usage.rb @@ -0,0 +1,133 @@ +=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 + # Hourly usage for a product family for an org. + class HourlyUsage + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # Attributes of hourly usage for a product family for an org for a time period. + attr_accessor :attributes + + # Unique ID of the response. + attr_accessor :id + + # Type of usage data. + attr_accessor :type + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'attributes' => :'attributes', + :'id' => :'id', + :'type' => :'type' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'attributes' => :'HourlyUsageAttributes', + :'id' => :'String', + :'type' => :'UsageTimeSeriesType' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::HourlyUsage` 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::V2::HourlyUsage`. 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?(:'attributes') + self.attributes = attributes[:'attributes'] + end + + if attributes.key?(:'id') + self.id = attributes[:'id'] + end + + if attributes.key?(:'type') + self.type = attributes[:'type'] + else + self.type = 'usage_timeseries' + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + true + 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 + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [attributes, id, type].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/hourly_usage_attributes.rb b/lib/datadog_api_client/v2/models/hourly_usage_attributes.rb new file mode 100644 index 000000000000..50308c54f3af --- /dev/null +++ b/lib/datadog_api_client/v2/models/hourly_usage_attributes.rb @@ -0,0 +1,163 @@ +=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 + # Attributes of hourly usage for a product family for an org for a time period. + class HourlyUsageAttributes + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # List of the measured usage values for the product family for the org for the time period. + attr_accessor :measurements + + # The organization name. + attr_accessor :org_name + + # The product for which usage is being reported. + attr_accessor :product_family + + # The organization public ID. + attr_accessor :public_id + + # The region of the Datadog instance that the organization belongs to. + attr_accessor :region + + # Datetime in ISO-8601 format, UTC. The hour for the usage. + attr_accessor :timestamp + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'measurements' => :'measurements', + :'org_name' => :'org_name', + :'product_family' => :'product_family', + :'public_id' => :'public_id', + :'region' => :'region', + :'timestamp' => :'timestamp' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'measurements' => :'Array', + :'org_name' => :'String', + :'product_family' => :'String', + :'public_id' => :'String', + :'region' => :'String', + :'timestamp' => :'Time' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::HourlyUsageAttributes` 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::V2::HourlyUsageAttributes`. 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?(:'measurements') + if (value = attributes[:'measurements']).is_a?(Array) + self.measurements = value + end + end + + if attributes.key?(:'org_name') + self.org_name = attributes[:'org_name'] + end + + if attributes.key?(:'product_family') + self.product_family = attributes[:'product_family'] + end + + if attributes.key?(:'public_id') + self.public_id = attributes[:'public_id'] + end + + if attributes.key?(:'region') + self.region = attributes[:'region'] + end + + if attributes.key?(:'timestamp') + self.timestamp = attributes[:'timestamp'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + true + 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 && + measurements == o.measurements && + org_name == o.org_name && + product_family == o.product_family && + public_id == o.public_id && + region == o.region && + timestamp == o.timestamp + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [measurements, org_name, product_family, public_id, region, timestamp].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/hourly_usage_measurement.rb b/lib/datadog_api_client/v2/models/hourly_usage_measurement.rb new file mode 100644 index 000000000000..4510e3d4fa1c --- /dev/null +++ b/lib/datadog_api_client/v2/models/hourly_usage_measurement.rb @@ -0,0 +1,122 @@ +=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 + # Usage amount for a given usage type. + class HourlyUsageMeasurement + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # Type of usage. + attr_accessor :usage_type + + # Contains the number measured for the given usage_type during the hour. + attr_accessor :value + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'usage_type' => :'usage_type', + :'value' => :'value' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'usage_type' => :'String', + :'value' => :'Integer' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + :'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::HourlyUsageMeasurement` 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::V2::HourlyUsageMeasurement`. 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?(:'usage_type') + self.usage_type = attributes[:'usage_type'] + end + + if attributes.key?(:'value') + self.value = attributes[:'value'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + true + 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 && + usage_type == o.usage_type && + value == o.value + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [usage_type, value].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/hourly_usage_metadata.rb b/lib/datadog_api_client/v2/models/hourly_usage_metadata.rb new file mode 100644 index 000000000000..02209a757a27 --- /dev/null +++ b/lib/datadog_api_client/v2/models/hourly_usage_metadata.rb @@ -0,0 +1,111 @@ +=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 + # The object containing document metadata. + class HourlyUsageMetadata + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # The metadata for the current pagination. + attr_accessor :pagination + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'pagination' => :'pagination' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'pagination' => :'HourlyUsagePagination' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::HourlyUsageMetadata` 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::V2::HourlyUsageMetadata`. 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?(:'pagination') + self.pagination = attributes[:'pagination'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + true + 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 + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [pagination].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/hourly_usage_pagination.rb b/lib/datadog_api_client/v2/models/hourly_usage_pagination.rb new file mode 100644 index 000000000000..fcafc79cab08 --- /dev/null +++ b/lib/datadog_api_client/v2/models/hourly_usage_pagination.rb @@ -0,0 +1,112 @@ +=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 + # The metadata for the current pagination. + class HourlyUsagePagination + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # The cursor to get the next results (if any). To make the next request, use the same parameters and add `next_record_id`. + attr_accessor :next_record_id + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'next_record_id' => :'next_record_id' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + 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::HourlyUsagePagination` 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::V2::HourlyUsagePagination`. 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?(:'next_record_id') + self.next_record_id = attributes[:'next_record_id'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + true + 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 + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [next_record_id].hash + end + end +end diff --git a/lib/datadog_api_client/v2/models/hourly_usage_response.rb b/lib/datadog_api_client/v2/models/hourly_usage_response.rb new file mode 100644 index 000000000000..5ce798078c28 --- /dev/null +++ b/lib/datadog_api_client/v2/models/hourly_usage_response.rb @@ -0,0 +1,123 @@ +=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 + # Hourly usage response. + class HourlyUsageResponse + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # Response containing hourly usage. + attr_accessor :data + + # The object containing document metadata. + attr_accessor :meta + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data', + :'meta' => :'meta' + } + end + + # Returns all the JSON keys this model knows about + # @!visibility private + def self.acceptable_attributes + attribute_map.values + end + + # Attribute type mapping. + # @!visibility private + def self.openapi_types + { + :'data' => :'Array', + :'meta' => :'HourlyUsageMetadata' + } + end + + # List of attributes with nullable: true + # @!visibility private + def self.openapi_nullable + Set.new([ + ]) + 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::HourlyUsageResponse` 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::V2::HourlyUsageResponse`. 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?(:'data') + if (value = attributes[:'data']).is_a?(Array) + self.data = value + end + end + + if attributes.key?(:'meta') + self.meta = attributes[:'meta'] + end + end + + # Check to see if the all the properties in the model are valid + # @return true if the model is valid + # @!visibility private + def valid? + true + 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 + end + + # @see the `==` method + # @param o [Object] Object to be compared + # @!visibility private + def eql?(o) + self == o + end + + # Calculates hash code according to all attributes. + # @return [Integer] Hash code + # @!visibility private + def hash + [data, meta].hash + end + end +end