diff --git a/.apigentools-info b/.apigentools-info index eac2f6cf80a3..9f2905c86aa1 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.2", - "regenerated": "2022-05-09 16:43:07.537568", - "spec_repo_commit": "a3819bf3" + "regenerated": "2022-05-10 15:39:28.303775", + "spec_repo_commit": "f1e731d3" }, "v2": { "apigentools_version": "1.6.2", - "regenerated": "2022-05-09 16:43:07.557285", - "spec_repo_commit": "a3819bf3" + "regenerated": "2022-05-10 15:39:28.323191", + "spec_repo_commit": "f1e731d3" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index e77fc6fdabb3..b037e5ddaacf 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -1668,11 +1668,13 @@ components: enum: - app_sec_host_count - observability_pipelines_bytes_processed + - lambda_traced_invocations_count example: observability_pipelines_bytes_processed type: string x-enum-varnames: - APP_SEC_HOST_COUNT - OBSERVABILITY_PIPELINES_BYTES_PROCESSSED + - LAMBDA_TRACED_INVOCATIONS_COUNT IdPMetadataFormData: description: The form data submitted to upload IdP metadata properties: @@ -6585,6 +6587,15 @@ components: type: $ref: '#/components/schemas/UsageTimeSeriesType' type: object + UsageLambdaTracedInvocationsResponse: + description: Lambda Traced Invocations usage response. + properties: + data: + description: Response containing Lambda Traced Invocations usage. + items: + $ref: '#/components/schemas/UsageDataObject' + type: array + type: object UsageObservabilityPipelinesResponse: description: Observability Pipelines usage response. properties: @@ -12209,6 +12220,65 @@ paths: x-menu-order: 39 x-undo: type: safe + /api/v2/usage/lambda_traced_invocations: + get: + description: Get hourly usage for Lambda Traced Invocations. + operationId: GetUsageLambdaTracedInvocations + parameters: + - description: 'Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` + for usage beginning at this hour.' + in: query + name: start_hr + 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: end_hr + required: false + schema: + format: date-time + type: string + responses: + '200': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/UsageLambdaTracedInvocationsResponse' + 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 for Lambda Traced Invocations + tags: + - Usage Metering + x-menu-order: 38 + x-undo: + type: safe /api/v2/usage/observability_pipelines: get: description: Get hourly usage for Observability Pipelines. diff --git a/cassettes/features/v2/usage_metering/Get-hourly-usage-for-Lambda-Traced-Invocations-returns-Bad-Request-response.frozen b/cassettes/features/v2/usage_metering/Get-hourly-usage-for-Lambda-Traced-Invocations-returns-Bad-Request-response.frozen new file mode 100644 index 000000000000..229352402a93 --- /dev/null +++ b/cassettes/features/v2/usage_metering/Get-hourly-usage-for-Lambda-Traced-Invocations-returns-Bad-Request-response.frozen @@ -0,0 +1 @@ +2022-05-06T18:07:36.174Z \ No newline at end of file diff --git a/cassettes/features/v2/usage_metering/Get-hourly-usage-for-Lambda-Traced-Invocations-returns-Bad-Request-response.yml b/cassettes/features/v2/usage_metering/Get-hourly-usage-for-Lambda-Traced-Invocations-returns-Bad-Request-response.yml new file mode 100644 index 000000000000..07e7a6087d1d --- /dev/null +++ b/cassettes/features/v2/usage_metering/Get-hourly-usage-for-Lambda-Traced-Invocations-returns-Bad-Request-response.yml @@ -0,0 +1,19 @@ +http_interactions: +- recorded_at: Fri, 06 May 2022 18:07:36 GMT + request: + body: null + headers: + Content-Type: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/usage/lambda_traced_invocations?start_hr=2022-05-03T18%3A07%3A36.174Z&end_hr=2022-05-01T18%3A07%3A36.174Z + response: + body: + encoding: UTF-8 + string: '{"errors":["start_hr [YYYY-MM-DDThh] must be before end_hr [YYYY-MM-DDThh]"]} + + ' + status: + code: 400 + message: Bad Request +recorded_with: VCR 6.0.0 diff --git a/cassettes/features/v2/usage_metering/Get-hourly-usage-for-Lambda-Traced-Invocations-returns-OK-response.frozen b/cassettes/features/v2/usage_metering/Get-hourly-usage-for-Lambda-Traced-Invocations-returns-OK-response.frozen new file mode 100644 index 000000000000..eb372837a734 --- /dev/null +++ b/cassettes/features/v2/usage_metering/Get-hourly-usage-for-Lambda-Traced-Invocations-returns-OK-response.frozen @@ -0,0 +1 @@ +2022-05-06T18:07:36.459Z \ No newline at end of file diff --git a/cassettes/features/v2/usage_metering/Get-hourly-usage-for-Lambda-Traced-Invocations-returns-OK-response.yml b/cassettes/features/v2/usage_metering/Get-hourly-usage-for-Lambda-Traced-Invocations-returns-OK-response.yml new file mode 100644 index 000000000000..820e647293eb --- /dev/null +++ b/cassettes/features/v2/usage_metering/Get-hourly-usage-for-Lambda-Traced-Invocations-returns-OK-response.yml @@ -0,0 +1,19 @@ +http_interactions: +- recorded_at: Fri, 06 May 2022 18:07:36 GMT + request: + body: null + headers: + Content-Type: + - application/json + method: GET + uri: https://api.datadoghq.com/api/v2/usage/lambda_traced_invocations?start_hr=2022-05-01T18%3A07%3A36.459Z&end_hr=2022-05-03T18%3A07%3A36.459Z + response: + body: + encoding: UTF-8 + string: '{"data":[{"attributes":{"org_name":"DD Integration Tests (321813)","usage_type":"lambda_traced_invocations_count","public_id":"fasjyydbcgwwc2uc","timeseries":[{"timestamp":"2022-05-01T18:00:00+00:00","value":null},{"timestamp":"2022-05-01T19:00:00+00:00","value":null},{"timestamp":"2022-05-01T20:00:00+00:00","value":null},{"timestamp":"2022-05-01T21:00:00+00:00","value":null},{"timestamp":"2022-05-01T22:00:00+00:00","value":null},{"timestamp":"2022-05-01T23:00:00+00:00","value":null},{"timestamp":"2022-05-02T00:00:00+00:00","value":null},{"timestamp":"2022-05-02T01:00:00+00:00","value":null},{"timestamp":"2022-05-02T02:00:00+00:00","value":null},{"timestamp":"2022-05-02T03:00:00+00:00","value":null},{"timestamp":"2022-05-02T04:00:00+00:00","value":null},{"timestamp":"2022-05-02T05:00:00+00:00","value":null},{"timestamp":"2022-05-02T06:00:00+00:00","value":null},{"timestamp":"2022-05-02T07:00:00+00:00","value":null},{"timestamp":"2022-05-02T08:00:00+00:00","value":null},{"timestamp":"2022-05-02T09:00:00+00:00","value":null},{"timestamp":"2022-05-02T10:00:00+00:00","value":null},{"timestamp":"2022-05-02T11:00:00+00:00","value":null},{"timestamp":"2022-05-02T12:00:00+00:00","value":null},{"timestamp":"2022-05-02T13:00:00+00:00","value":null},{"timestamp":"2022-05-02T14:00:00+00:00","value":null},{"timestamp":"2022-05-02T15:00:00+00:00","value":null},{"timestamp":"2022-05-02T16:00:00+00:00","value":null},{"timestamp":"2022-05-02T17:00:00+00:00","value":null},{"timestamp":"2022-05-02T18:00:00+00:00","value":null},{"timestamp":"2022-05-02T19:00:00+00:00","value":null},{"timestamp":"2022-05-02T20:00:00+00:00","value":null},{"timestamp":"2022-05-02T21:00:00+00:00","value":null},{"timestamp":"2022-05-02T22:00:00+00:00","value":null},{"timestamp":"2022-05-02T23:00:00+00:00","value":null},{"timestamp":"2022-05-03T00:00:00+00:00","value":null},{"timestamp":"2022-05-03T01:00:00+00:00","value":null},{"timestamp":"2022-05-03T02:00:00+00:00","value":null},{"timestamp":"2022-05-03T03:00:00+00:00","value":null},{"timestamp":"2022-05-03T04:00:00+00:00","value":null},{"timestamp":"2022-05-03T05:00:00+00:00","value":null},{"timestamp":"2022-05-03T06:00:00+00:00","value":null},{"timestamp":"2022-05-03T07:00:00+00:00","value":null},{"timestamp":"2022-05-03T08:00:00+00:00","value":null},{"timestamp":"2022-05-03T09:00:00+00:00","value":null},{"timestamp":"2022-05-03T10:00:00+00:00","value":null},{"timestamp":"2022-05-03T11:00:00+00:00","value":null},{"timestamp":"2022-05-03T12:00:00+00:00","value":null},{"timestamp":"2022-05-03T13:00:00+00:00","value":null},{"timestamp":"2022-05-03T14:00:00+00:00","value":null},{"timestamp":"2022-05-03T15:00:00+00:00","value":null},{"timestamp":"2022-05-03T16:00:00+00:00","value":null},{"timestamp":"2022-05-03T17:00:00+00:00","value":null}],"product_family":"lambda-traced-invocations"},"type":"usage_timeseries","id":"ee1c7b786f4ce991edc30c3f8ef47fd33e26f844679e27a51b458abe6b42e7c5"}]} + + ' + status: + code: 200 + message: OK +recorded_with: VCR 6.0.0 diff --git a/examples/v2/usage-metering/GetUsageLambdaTracedInvocations.rb b/examples/v2/usage-metering/GetUsageLambdaTracedInvocations.rb new file mode 100644 index 000000000000..9e3b189e0a71 --- /dev/null +++ b/examples/v2/usage-metering/GetUsageLambdaTracedInvocations.rb @@ -0,0 +1,8 @@ +# Get hourly usage for Lambda Traced Invocations returns "OK" response + +require "datadog_api_client" +api_instance = DatadogAPIClient::V2::UsageMeteringAPI.new +opts = { + end_hr: (Time.now + -3 * 86400), +} +p api_instance.get_usage_lambda_traced_invocations((Time.now + -5 * 86400), opts) diff --git a/features/v2/undo.json b/features/v2/undo.json index 517ac397d07e..3a6c72737257 100644 --- a/features/v2/undo.json +++ b/features/v2/undo.json @@ -794,6 +794,12 @@ "type": "safe" } }, + "GetUsageLambdaTracedInvocations": { + "tag": "Usage Metering", + "undo": { + "type": "safe" + } + }, "GetUsageObservabilityPipelines": { "tag": "Usage Metering", "undo": { diff --git a/features/v2/usage_metering.feature b/features/v2/usage_metering.feature index 88d46806ce9b..aef06a47ab89 100644 --- a/features/v2/usage_metering.feature +++ b/features/v2/usage_metering.feature @@ -44,6 +44,22 @@ 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 for Lambda Traced Invocations returns "Bad Request" response + Given new "GetUsageLambdaTracedInvocations" request + And request contains "start_hr" parameter with value "{{ timeISO('now - 3d') }}" + And request contains "end_hr" 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 for Lambda Traced Invocations returns "OK" response + Given new "GetUsageLambdaTracedInvocations" request + And request contains "start_hr" parameter with value "{{ timeISO('now - 5d') }}" + And request contains "end_hr" parameter with value "{{ timeISO('now - 3d') }}" + When the request is sent + Then the response status is 200 OK + @team:DataDog/red-zone-revenue-query Scenario: Get hourly usage for Observability Pipelines returns "Bad Request" response Given new "GetUsageObservabilityPipelines" request diff --git a/lib/datadog_api_client/v2.rb b/lib/datadog_api_client/v2.rb index 8117cdc139e8..23e43df73856 100644 --- a/lib/datadog_api_client/v2.rb +++ b/lib/datadog_api_client/v2.rb @@ -435,6 +435,7 @@ require 'datadog_api_client/v2/models/usage_application_security_monitoring_response' require 'datadog_api_client/v2/models/usage_attributes_object' require 'datadog_api_client/v2/models/usage_data_object' +require 'datadog_api_client/v2/models/usage_lambda_traced_invocations_response' require 'datadog_api_client/v2/models/usage_observability_pipelines_response' require 'datadog_api_client/v2/models/usage_time_series_object' require 'datadog_api_client/v2/models/usage_time_series_type' 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 db93344daf3f..1ee220b5010f 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,82 @@ def get_usage_application_security_monitoring_with_http_info(start_hr, opts = {} return data, status_code, headers end + # Get hourly usage for Lambda Traced Invocations. + # + # @see #get_usage_lambda_traced_invocations_with_http_info + def get_usage_lambda_traced_invocations(start_hr, opts = {}) + data, _status_code, _headers = get_usage_lambda_traced_invocations_with_http_info(start_hr, opts) + data + end + + # Get hourly usage for Lambda Traced Invocations. + # + # Get hourly usage for Lambda Traced Invocations. + # + # @param start_hr [Time] Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage beginning at this hour. + # @param opts [Hash] the optional parameters + # @option opts [Time] :end_hr Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage ending **before** this hour. + # @return [Array<(UsageLambdaTracedInvocationsResponse, Integer, Hash)>] UsageLambdaTracedInvocationsResponse data, response status code and response headers + def get_usage_lambda_traced_invocations_with_http_info(start_hr, opts = {}) + + if @api_client.config.unstable_operations.has_key?(:get_usage_lambda_traced_invocations) + unstable_enabled = @api_client.config.unstable_operations[:get_usage_lambda_traced_invocations] + if unstable_enabled + @api_client.config.logger.warn format("Using unstable operation '%s'", "get_usage_lambda_traced_invocations") + else + raise APIError.new(message: format("Unstable operation '%s' is disabled", "get_usage_lambda_traced_invocations")) + end + end + + if @api_client.config.debugging + @api_client.config.logger.debug 'Calling API: UsageMeteringAPI.get_usage_lambda_traced_invocations ...' + end + # verify the required parameter 'start_hr' is set + if @api_client.config.client_side_validation && start_hr.nil? + fail ArgumentError, "Missing the required parameter 'start_hr' when calling UsageMeteringAPI.get_usage_lambda_traced_invocations" + end + # resource path + local_var_path = '/api/v2/usage/lambda_traced_invocations' + + # query parameters + query_params = opts[:query_params] || {} + query_params[:'start_hr'] = start_hr + query_params[:'end_hr'] = opts[:'end_hr'] if !opts[:'end_hr'].nil? + + # header parameters + header_params = opts[:header_params] || {} + # HTTP header 'Accept' (if needed) + header_params['Accept'] = @api_client.select_header_accept(['application/json;datetime-format=rfc3339']) + + # form parameters + form_params = opts[:form_params] || {} + + # http body (model) + post_body = opts[:debug_body] + + # return_type + return_type = opts[:debug_return_type] || 'UsageLambdaTracedInvocationsResponse' + + # auth_names + auth_names = opts[:debug_auth_names] || [:apiKeyAuth, :appKeyAuth, :AuthZ] + + new_options = opts.merge( + :operation => :get_usage_lambda_traced_invocations, + :header_params => header_params, + :query_params => query_params, + :form_params => form_params, + :body => post_body, + :auth_names => auth_names, + :return_type => return_type + ) + + data, status_code, headers = @api_client.call_api(Net::HTTP::Get, local_var_path, new_options) + if @api_client.config.debugging + @api_client.config.logger.debug "API called: UsageMeteringAPI#get_usage_lambda_traced_invocations\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}" + end + return data, status_code, headers + end + # Get hourly usage for Observability Pipelines. # # @see #get_usage_observability_pipelines_with_http_info diff --git a/lib/datadog_api_client/v2/models/hourly_usage_type.rb b/lib/datadog_api_client/v2/models/hourly_usage_type.rb index 6bf7b95f3f14..3acb313129fd 100644 --- a/lib/datadog_api_client/v2/models/hourly_usage_type.rb +++ b/lib/datadog_api_client/v2/models/hourly_usage_type.rb @@ -23,5 +23,6 @@ class HourlyUsageType APP_SEC_HOST_COUNT = "app_sec_host_count".freeze OBSERVABILITY_PIPELINES_BYTES_PROCESSSED = "observability_pipelines_bytes_processed".freeze + LAMBDA_TRACED_INVOCATIONS_COUNT = "lambda_traced_invocations_count".freeze end end diff --git a/lib/datadog_api_client/v2/models/usage_lambda_traced_invocations_response.rb b/lib/datadog_api_client/v2/models/usage_lambda_traced_invocations_response.rb new file mode 100644 index 000000000000..18a55c5e0028 --- /dev/null +++ b/lib/datadog_api_client/v2/models/usage_lambda_traced_invocations_response.rb @@ -0,0 +1,113 @@ +=begin +#Datadog API V2 Collection + +#Collection of all Datadog Public endpoints. + +The version of the OpenAPI document: 1.0 +Contact: support@datadoghq.com +Generated by: https://github.com/DataDog/datadog-api-client-ruby/tree/master/.generator + + Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. + This product includes software developed at Datadog (https://www.datadoghq.com/). + Copyright 2020-Present Datadog, Inc. + +=end + +require 'date' +require 'time' + +module DatadogAPIClient::V2 + # Lambda Traced Invocations usage response. + class UsageLambdaTracedInvocationsResponse + include BaseGenericModel + + # Whether the object has unparsed attributes + # @!visibility private + attr_accessor :_unparsed + + # Response containing Lambda Traced Invocations usage. + attr_accessor :data + + # Attribute mapping from ruby-style variable name to JSON key. + # @!visibility private + def self.attribute_map + { + :'data' => :'data' + } + 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' + } + 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::UsageLambdaTracedInvocationsResponse` 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::UsageLambdaTracedInvocationsResponse`. 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 + 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 + 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].hash + end + end +end