From 86b0104b583547be738a002b5e600c7603cfa20f Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 21 Dec 2022 13:01:48 +0000 Subject: [PATCH] Regenerate client from commit d643f399 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 660 +++++++++++++++++- api/datadog/configuration.go | 2 + api/datadogV2/api_metrics.go | 222 ++++++ api/datadogV2/doc.go | 2 + api/datadogV2/model_events_aggregation.go | 127 ++++ api/datadogV2/model_events_compute.go | 183 +++++ .../model_events_data_source_enum.go | 107 +++ api/datadogV2/model_events_group_by.go | 180 +++++ api/datadogV2/model_events_scalar_query.go | 300 ++++++++ api/datadogV2/model_events_search.go | 98 +++ api/datadogV2/model_events_sort_field.go | 238 +++++++ api/datadogV2/model_events_sort_type_enum.go | 109 +++ .../model_events_timeseries_query.go | 300 ++++++++ api/datadogV2/model_formula_limit.go | 145 ++++ .../model_metrics_aggregator_enum.go | 115 +++ api/datadogV2/model_metrics_data_source.go | 107 +++ api/datadogV2/model_metrics_scalar_query.go | 224 ++++++ .../model_metrics_timeseries_query.go | 181 +++++ api/datadogV2/model_query_formula.go | 145 ++++ api/datadogV2/model_scalar_column.go | 133 ++++ .../model_scalar_formula_query_request.go | 110 +++ .../model_scalar_formula_query_response.go | 140 ++++ api/datadogV2/model_scalar_formula_request.go | 153 ++++ ...model_scalar_formula_request_attributes.go | 204 ++++++ .../model_scalar_formula_request_type.go | 107 +++ ...odel_scalar_formula_response_atrributes.go | 133 ++++ .../model_scalar_formula_response_type.go | 107 +++ api/datadogV2/model_scalar_query.go | 155 ++++ api/datadogV2/model_scalar_response.go | 152 ++++ .../model_timeseries_formula_query_request.go | 110 +++ ...model_timeseries_formula_query_response.go | 140 ++++ .../model_timeseries_formula_request.go | 153 ++++ ...l_timeseries_formula_request_attributes.go | 242 +++++++ .../model_timeseries_formula_request_type.go | 107 +++ .../model_timeseries_formula_response_type.go | 107 +++ api/datadogV2/model_timeseries_query.go | 155 ++++ api/datadogV2/model_timeseries_response.go | 152 ++++ .../model_timeseries_response_attributes.go | 168 +++++ .../model_timeseries_response_series.go | 168 +++++ api/datadogV2/model_unit.go | 288 ++++++++ examples/v2/metrics/QueryScalarData.go | 57 ++ examples/v2/metrics/QueryTimeseriesData.go | 57 ++ ..._query_returns_Bad_Request_response.freeze | 1 + ...ct_query_returns_Bad_Request_response.yaml | 21 + ...s_product_query_returns_OK_response.freeze | 1 + ...oss_product_query_returns_OK_response.yaml | 21 + ..._query_returns_Bad_Request_response.freeze | 1 + ...ct_query_returns_Bad_Request_response.yaml | 21 + ...s_product_query_returns_OK_response.freeze | 1 + ...oss_product_query_returns_OK_response.yaml | 21 + tests/scenarios/features/v2/metrics.feature | 50 +- tests/scenarios/features/v2/undo.json | 12 + 53 files changed, 6884 insertions(+), 17 deletions(-) create mode 100644 api/datadogV2/model_events_aggregation.go create mode 100644 api/datadogV2/model_events_compute.go create mode 100644 api/datadogV2/model_events_data_source_enum.go create mode 100644 api/datadogV2/model_events_group_by.go create mode 100644 api/datadogV2/model_events_scalar_query.go create mode 100644 api/datadogV2/model_events_search.go create mode 100644 api/datadogV2/model_events_sort_field.go create mode 100644 api/datadogV2/model_events_sort_type_enum.go create mode 100644 api/datadogV2/model_events_timeseries_query.go create mode 100644 api/datadogV2/model_formula_limit.go create mode 100644 api/datadogV2/model_metrics_aggregator_enum.go create mode 100644 api/datadogV2/model_metrics_data_source.go create mode 100644 api/datadogV2/model_metrics_scalar_query.go create mode 100644 api/datadogV2/model_metrics_timeseries_query.go create mode 100644 api/datadogV2/model_query_formula.go create mode 100644 api/datadogV2/model_scalar_column.go create mode 100644 api/datadogV2/model_scalar_formula_query_request.go create mode 100644 api/datadogV2/model_scalar_formula_query_response.go create mode 100644 api/datadogV2/model_scalar_formula_request.go create mode 100644 api/datadogV2/model_scalar_formula_request_attributes.go create mode 100644 api/datadogV2/model_scalar_formula_request_type.go create mode 100644 api/datadogV2/model_scalar_formula_response_atrributes.go create mode 100644 api/datadogV2/model_scalar_formula_response_type.go create mode 100644 api/datadogV2/model_scalar_query.go create mode 100644 api/datadogV2/model_scalar_response.go create mode 100644 api/datadogV2/model_timeseries_formula_query_request.go create mode 100644 api/datadogV2/model_timeseries_formula_query_response.go create mode 100644 api/datadogV2/model_timeseries_formula_request.go create mode 100644 api/datadogV2/model_timeseries_formula_request_attributes.go create mode 100644 api/datadogV2/model_timeseries_formula_request_type.go create mode 100644 api/datadogV2/model_timeseries_formula_response_type.go create mode 100644 api/datadogV2/model_timeseries_query.go create mode 100644 api/datadogV2/model_timeseries_response.go create mode 100644 api/datadogV2/model_timeseries_response_attributes.go create mode 100644 api/datadogV2/model_timeseries_response_series.go create mode 100644 api/datadogV2/model_unit.go create mode 100644 examples/v2/metrics/QueryScalarData.go create mode 100644 examples/v2/metrics/QueryTimeseriesData.go create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_OK_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_Bad_Request_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_Bad_Request_response.yaml create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_OK_response.yaml diff --git a/.apigentools-info b/.apigentools-info index 3023740da0f..877664499b8 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2022-12-20 16:44:27.418644", - "spec_repo_commit": "ec3c91a9" + "regenerated": "2022-12-21 13:00:39.668793", + "spec_repo_commit": "d643f399" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2022-12-20 16:44:27.430114", - "spec_repo_commit": "ec3c91a9" + "regenerated": "2022-12-21 13:00:39.680595", + "spec_repo_commit": "d643f399" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index fb4e260e6fe..e54115e77fb 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -2825,6 +2825,78 @@ components: type: string x-enum-varnames: - EVENT + EventsAggregation: + default: count + description: The type of aggregation that can be performed on events-based queries. + enum: + - count + - cardinality + - pc75 + - pc90 + - pc95 + - pc98 + - pc99 + - sum + - min + - max + - avg + example: count + type: string + x-enum-varnames: + - COUNT + - CARDINALITY + - PC75 + - PC90 + - PC95 + - PC98 + - PC99 + - SUM + - MIN + - MAX + - AVG + EventsCompute: + description: The instructions for what to compute for this query. + properties: + aggregation: + $ref: '#/components/schemas/EventsAggregation' + interval: + description: Interval for compute in milliseconds. + example: 60000 + format: int64 + type: integer + metric: + description: The "measure" attribute on which to perform the computation. + type: string + required: + - aggregation + type: object + EventsDataSourceEnum: + default: logs + description: A data source that is powered by the Events Platform. + enum: + - logs + example: logs + type: string + x-enum-varnames: + - LOGS + EventsGroupBy: + description: A dimension on which to split a query's results. + properties: + facet: + description: The facet by which to split groups. + example: '@error.type' + type: string + limit: + description: The maximum number of groups to return. + example: 10 + format: int32 + maximum: 2147483647 + type: integer + sort: + $ref: '#/components/schemas/EventsSortField' + required: + - facet + type: object EventsListRequest: description: The object sent with the request to retrieve a list of events from your organization. @@ -2884,6 +2956,11 @@ components: example: now type: string type: object + EventsQueryGroupBys: + description: The list of facets on which to split results. + items: + $ref: '#/components/schemas/EventsGroupBy' + type: array EventsQueryOptions: description: 'The global query options that are used. Either provide a timezone or a time offset but not both, @@ -2950,6 +3027,39 @@ components: example: eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ== type: string type: object + EventsScalarQuery: + description: An individual scalar events query. + properties: + compute: + $ref: '#/components/schemas/EventsCompute' + data_source: + $ref: '#/components/schemas/EventsDataSourceEnum' + group_by: + $ref: '#/components/schemas/EventsQueryGroupBys' + indexes: + description: The indexes in which to search. + items: + description: The unique index name. + example: main + type: string + type: array + name: + description: The variable name for use in formulas. + type: string + search: + $ref: '#/components/schemas/EventsSearch' + required: + - data_source + - compute + type: object + EventsSearch: + description: Configuration of the search/filter for an events query. + properties: + query: + description: The search/filter string for an events query. + example: status:warn service:foo + type: string + type: object EventsSort: description: The sort parameters when querying events. enum: @@ -2959,6 +3069,57 @@ components: x-enum-varnames: - TIMESTAMP_ASCENDING - TIMESTAMP_DESCENDING + EventsSortField: + description: The dimension by which to sort a query's results. + properties: + aggregation: + $ref: '#/components/schemas/EventsAggregation' + metric: + description: Metric whose calculated value should be used to define the + sort order of a query's results. + example: '@duration' + type: string + order: + $ref: '#/components/schemas/QuerySortOrder' + type: + $ref: '#/components/schemas/EventsSortTypeEnum' + required: + - aggregation + type: object + EventsSortTypeEnum: + description: The type of sort to use on the calculated value. + enum: + - alphabetical + - measure + type: string + x-enum-varnames: + - ALPHABETICAL + - MEASURE + EventsTimeseriesQuery: + description: An individual timeseries events query. + properties: + compute: + $ref: '#/components/schemas/EventsCompute' + data_source: + $ref: '#/components/schemas/EventsDataSourceEnum' + group_by: + $ref: '#/components/schemas/EventsQueryGroupBys' + indexes: + description: The indexes in which to search. + items: + description: The unique index name. + example: main + type: string + type: array + name: + description: The variable name for use in formulas. + type: string + search: + $ref: '#/components/schemas/EventsSearch' + required: + - data_source + - compute + type: object EventsWarning: description: A warning message indicating something is wrong with the query. properties: @@ -2976,6 +3137,19 @@ components: from the other indexes. type: string type: object + FormulaLimit: + description: Message for specifying limits to the number of values returned + by a query. + properties: + count: + description: The number of results to which to limit. + example: 10 + format: int32 + maximum: 2147483647 + type: integer + order: + $ref: '#/components/schemas/QuerySortOrder' + type: object FullAPIKey: description: Datadog API key. properties: @@ -3068,6 +3242,12 @@ components: nullable: true type: array type: object + GroupTags: + description: List of tags that apply to a single response value. + items: + description: A single tag that applies to a single response value. + type: string + type: array HTTPLog: description: Structured log message. items: @@ -6353,6 +6533,23 @@ components: $ref: '#/components/schemas/MetricVolumes' readOnly: true type: object + MetricsAggregatorEnum: + default: avg + description: The type of aggregation that can be performed on metrics queries. + enum: + - avg + - min + - max + - sum + - last + example: avg + type: string + x-enum-varnames: + - AVG + - MIN + - MAX + - SUM + - LAST MetricsAndMetricTagConfigurations: description: Object for a metrics and metric tag configurations. oneOf: @@ -6369,6 +6566,50 @@ components: type: array readOnly: true type: object + MetricsDataSource: + default: metrics + description: A data source that is powered by the Metrics backend. + enum: + - metrics + example: metrics + type: string + x-enum-varnames: + - METRICS + MetricsScalarQuery: + description: An individual scalar metrics query. + properties: + aggregator: + $ref: '#/components/schemas/MetricsAggregatorEnum' + data_source: + $ref: '#/components/schemas/MetricsDataSource' + name: + description: The variable name for use in formulas. + type: string + query: + description: A classic metrics query string. + example: avg:system.cpu.user{*} + type: string + required: + - data_source + - query + - aggregator + type: object + MetricsTimeseriesQuery: + description: An individual timeseries metrics query. + properties: + data_source: + $ref: '#/components/schemas/MetricsDataSource' + name: + description: The variable name for use in formulas. + type: string + query: + description: A classic metrics query string. + example: avg:system.cpu.user{*} + type: string + required: + - data_source + - query + type: object MonitorType: description: Attributes from the monitor that triggered the event. nullable: true @@ -6915,6 +7156,19 @@ components: type: string x-enum-varnames: - PROCESS + QueryFormula: + description: A formula for calculation based on one or more queries. + properties: + formula: + description: Formula string, referencing one or more queries with their + name property. + example: a+b + type: string + limit: + $ref: '#/components/schemas/FormulaLimit' + required: + - formula + type: object QuerySortOrder: default: desc description: Direction of sort. @@ -8207,6 +8461,134 @@ components: type: string x-enum-varnames: - SAML_ASSERTION_ATTRIBUTES + ScalarColumn: + description: A single column in a scalar query response. + properties: + unit: + description: List of units. + items: + $ref: '#/components/schemas/Unit' + type: array + values: + description: Array of values for each group-by combination that results + from one formula or query. + items: + description: An individual value for a given column and group-by. + format: double + type: number + type: array + type: object + ScalarFormulaQueryRequest: + description: A wrapper request around one scalar query to be executed. + properties: + data: + $ref: '#/components/schemas/ScalarFormulaRequest' + required: + - data + type: object + ScalarFormulaQueryResponse: + description: A message containing one or more responses to scalar queries. + properties: + data: + $ref: '#/components/schemas/ScalarResponse' + errors: + description: An error generated when processing a request. + type: string + type: object + ScalarFormulaRequest: + description: A single scalar query to be executed. + properties: + attributes: + $ref: '#/components/schemas/ScalarFormulaRequestAttributes' + type: + $ref: '#/components/schemas/ScalarFormulaRequestType' + required: + - type + - attributes + type: object + ScalarFormulaRequestAttributes: + description: The object describing a scalar formula request. + properties: + formulas: + description: List of formulas to be calculated and returned as responses. + items: + $ref: '#/components/schemas/QueryFormula' + type: array + from: + description: Start date (inclusive) of the query in milliseconds since the + Unix epoch. + example: 1568899800000 + format: int64 + type: integer + queries: + $ref: '#/components/schemas/ScalarFormulaRequestQueries' + to: + description: End date (exclusive) of the query in milliseconds since the + Unix epoch. + example: 1568923200000 + format: int64 + type: integer + required: + - to + - from + - queries + type: object + ScalarFormulaRequestQueries: + description: List of queries to be run and used as inputs to the formulas. + items: + $ref: '#/components/schemas/ScalarQuery' + type: array + ScalarFormulaRequestType: + default: scalar_request + description: The type of the resource. The value should always be scalar_request. + enum: + - scalar_request + example: scalar_request + type: string + x-enum-varnames: + - SCALAR_REQUEST + ScalarFormulaResponseAtrributes: + description: The object describing a scalar response. + properties: + columns: + description: List of response columns, each corresponding to an individual + formula or query in the request and with values in parallel arrays matching + the series list. + items: + $ref: '#/components/schemas/ScalarColumn' + type: array + series: + $ref: '#/components/schemas/ScalarResponseSeriesList' + type: object + ScalarFormulaResponseType: + default: scalar_response + description: The type of the resource. The value should always be scalar_response. + enum: + - scalar_response + example: scalar_response + type: string + x-enum-varnames: + - SCALAR_RESPONSE + ScalarQuery: + description: An individual scalar query to one of the basic Datadog data sources. + oneOf: + - $ref: '#/components/schemas/MetricsScalarQuery' + - $ref: '#/components/schemas/EventsScalarQuery' + type: object + ScalarResponse: + description: A message containing the response to a scalar query. + properties: + attributes: + $ref: '#/components/schemas/ScalarFormulaResponseAtrributes' + type: + $ref: '#/components/schemas/ScalarFormulaResponseType' + type: object + ScalarResponseSeriesList: + description: List of group-by tags for the response. Parallel array to the values + in each scalar column. + items: + $ref: '#/components/schemas/GroupTags' + type: array SecurityFilter: description: The security filter's properties. properties: @@ -10674,11 +11056,200 @@ components: description: Tag associated with your event. type: string type: array + TimeseriesFormulaQueryRequest: + description: A request wrapper around a single timeseries query to be executed. + properties: + data: + $ref: '#/components/schemas/TimeseriesFormulaRequest' + required: + - data + type: object + TimeseriesFormulaQueryResponse: + description: A message containing one response to a timeseries query made with + timeseries formula query request. + properties: + data: + $ref: '#/components/schemas/TimeseriesResponse' + errors: + description: The error generated by the request. + type: string + type: object + TimeseriesFormulaRequest: + description: A single timeseries query to be executed. + properties: + attributes: + $ref: '#/components/schemas/TimeseriesFormulaRequestAttributes' + type: + $ref: '#/components/schemas/TimeseriesFormulaRequestType' + required: + - type + - attributes + type: object + TimeseriesFormulaRequestAttributes: + description: The object describing a timeseries formula request. + properties: + formulas: + description: List of formulas to be calculated and returned as responses. + items: + $ref: '#/components/schemas/QueryFormula' + type: array + from: + description: Start date (inclusive) of the query in milliseconds since the + Unix epoch. + example: 1568899800000 + format: int64 + type: integer + interval: + description: 'A time interval in milliseconds. + + May be overridden by a larger interval if the query would result in + + too many points for the specified timeframe. + + Defaults to a reasonable interval for the given timeframe.' + example: 5000 + format: int64 + type: integer + queries: + $ref: '#/components/schemas/TimeseriesFormulaRequestQueries' + to: + description: End date (exclusive) of the query in milliseconds since the + Unix epoch. + example: 1568923200000 + format: int64 + type: integer + required: + - to + - from + - queries + type: object + TimeseriesFormulaRequestQueries: + description: List of queries to be run and used as inputs to the formulas. + items: + $ref: '#/components/schemas/TimeseriesQuery' + type: array + TimeseriesFormulaRequestType: + default: timeseries_request + description: The type of the resource. The value should always be timeseries_request. + enum: + - timeseries_request + example: timeseries_request + type: string + x-enum-varnames: + - TIMESERIES_REQUEST + TimeseriesFormulaResponseType: + default: timeseries_response + description: The type of the resource. The value should always be timeseries_response. + enum: + - timeseries_response + example: timeseries_response + type: string + x-enum-varnames: + - TIMESERIES_RESPONSE + TimeseriesQuery: + description: An individual timeseries query to one of the basic Datadog data + sources. + oneOf: + - $ref: '#/components/schemas/MetricsTimeseriesQuery' + - $ref: '#/components/schemas/EventsTimeseriesQuery' + type: object + TimeseriesResponse: + description: A message containing the response to a timeseries query. + properties: + attributes: + $ref: '#/components/schemas/TimeseriesResponseAttributes' + type: + $ref: '#/components/schemas/TimeseriesFormulaResponseType' + type: object + TimeseriesResponseAttributes: + description: The object describing a timeseries response. + properties: + series: + $ref: '#/components/schemas/TimeseriesResponseSeriesList' + times: + $ref: '#/components/schemas/TimeseriesResponseTimes' + values: + $ref: '#/components/schemas/TimeseriesResponseValuesList' + type: object + TimeseriesResponseSeries: + description: '' + properties: + group_tags: + $ref: '#/components/schemas/GroupTags' + query_index: + description: The index of the query in the "formulas" array (or "queries" + array if no "formulas" was specified). + example: 0 + format: int32 + maximum: 2147483647 + type: integer + unit: + description: List of units. + items: + $ref: '#/components/schemas/Unit' + type: array + type: object + TimeseriesResponseSeriesList: + description: Array of response series. The index here corresponds to the index + in the `formulas` or `queries` array from the request. + items: + $ref: '#/components/schemas/TimeseriesResponseSeries' + type: array + TimeseriesResponseTimes: + description: Array of times, 1-1 match with individual values arrays. + items: + description: Start date (inclusive) of the query in seconds since the Unix + epoch. + example: 1568899800000 + format: int64 + type: integer + type: array + TimeseriesResponseValues: + description: Array of values for an individual formula or query. + items: + description: An individual value for a given time. + format: double + type: number + type: array + TimeseriesResponseValuesList: + description: Array of value-arrays. The index here corresponds to the index + in the `formulas` or `queries` array from the request. + items: + $ref: '#/components/schemas/TimeseriesResponseValues' + type: array TimestampEventAttribute: description: Timestamp of your event. example: '2019-01-02T09:42:36.320Z' format: date-time type: string + Unit: + description: Object containing the metric unit family, scale factor, name, and + short name. + nullable: true + properties: + family: + description: Unit family, allows for conversion between units of the same + family, for scaling. + example: time + type: string + name: + description: Unit name + example: minute + type: string + plural: + description: Plural form of the unit name. + example: minutes + type: string + scale_factor: + description: Factor for scaling between units of the same family. + example: 60.0 + format: double + type: number + short_name: + description: Abbreviation of the unit. + example: min + type: string + type: object UsageApplicationSecurityMonitoringResponse: description: Application Security Monitoring usage response. properties: @@ -14871,6 +15442,82 @@ paths: cursorPath: meta.page.after limitParam: page[limit] resultsPath: data + /api/v2/query/scalar: + post: + description: 'The internal endpoint to query scalar/table data for multiple + data sources and + + process the data using formulas and functions.' + operationId: QueryScalarData + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/ScalarFormulaQueryRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/ScalarFormulaQueryResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Scalar cross product query + tags: + - Metrics + x-codegen-request-body-name: body + x-unstable: '**Note**: This endpoint is GA for the metrics data source. Logs + is in beta. + + We are gradually onboarding support for more sources. If you have any feedback, + + contact [Datadog support](https://docs.datadoghq.com/help/).' + /api/v2/query/timeseries: + post: + description: 'The internal endpoint to query timeseries data for multiple data + sources and + + process the data by applying formulas and functions.' + operationId: QueryTimeseriesData + requestBody: + content: + application/json: + schema: + $ref: '#/components/schemas/TimeseriesFormulaQueryRequest' + required: true + responses: + '200': + content: + application/json: + schema: + $ref: '#/components/schemas/TimeseriesFormulaQueryResponse' + description: OK + '400': + $ref: '#/components/responses/BadRequestResponse' + '401': + $ref: '#/components/responses/UnauthorizedResponse' + '403': + $ref: '#/components/responses/ForbiddenResponse' + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + summary: Timeseries cross product query + tags: + - Metrics + x-codegen-request-body-name: body + x-unstable: '**Note**: This endpoint is GA for the metrics data source. Logs + is in beta. + + We are gradually onboarding support for more sources. If you have any feedback, + + contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v2/roles: get: description: Returns all roles, including their names and their unique identifiers. @@ -18562,12 +19209,13 @@ tags: url: https://docs.datadoghq.com/logs/logs_to_metrics/ name: Logs Metrics - description: "The metrics endpoint allows you to:\n\n- Post metrics data so it can - be graphed on Datadog\u2019s dashboards\n- Query metrics from any time period\n- - Modify tag configurations for metrics\n- View tags and volumes for metrics\n\n**Note**: - A graph can only contain a set number of points\nand as the timeframe over which - a metric is viewed increases,\naggregation between points occurs to stay below - that set number.\n\nThe Post, Patch, and Delete `manage_tags` API methods can - only be performed by\na user who has the `Manage Tags for Metrics` permission." + be graphed on Datadog\u2019s dashboards\n- Query metrics from any time period + (timeseries and scalar)\n- Modify tag configurations for metrics\n- View tags + and volumes for metrics\n\n**Note**: A graph can only contain a set number of + points\nand as the timeframe over which a metric is viewed increases,\naggregation + between points occurs to stay below that set number.\n\nThe Post, Patch, and Delete + `manage_tags` API methods can only be performed by\na user who has the `Manage + Tags for Metrics` permission." name: Metrics - description: 'Configure your [Datadog Opsgenie integration](https://docs.datadoghq.com/integrations/opsgenie/) diff --git a/api/datadog/configuration.go b/api/datadog/configuration.go index 55f857ecdc0..94d1287e8be 100644 --- a/api/datadog/configuration.go +++ b/api/datadog/configuration.go @@ -369,6 +369,8 @@ func NewConfiguration() *Configuration { "v2.ListIncidents": false, "v2.UpdateIncident": false, "v2.UpdateIncidentAttachments": false, + "v2.QueryScalarData": false, + "v2.QueryTimeseriesData": false, "v2.CreateIncidentService": false, "v2.DeleteIncidentService": false, "v2.GetIncidentService": false, diff --git a/api/datadogV2/api_metrics.go b/api/datadogV2/api_metrics.go index c92be5bc571..e05fe4750f1 100644 --- a/api/datadogV2/api_metrics.go +++ b/api/datadogV2/api_metrics.go @@ -7,7 +7,9 @@ package datadogV2 import ( "bytes" _context "context" + _fmt "fmt" _io "io" + _log "log" _nethttp "net/http" _neturl "net/url" "strings" @@ -1213,6 +1215,226 @@ func (a *MetricsApi) listVolumesByMetricNameExecute(r apiListVolumesByMetricName return localVarReturnValue, localVarHTTPResponse, nil } +type apiQueryScalarDataRequest struct { + ctx _context.Context + body *ScalarFormulaQueryRequest +} + +func (a *MetricsApi) buildQueryScalarDataRequest(ctx _context.Context, body ScalarFormulaQueryRequest) (apiQueryScalarDataRequest, error) { + req := apiQueryScalarDataRequest{ + ctx: ctx, + body: &body, + } + return req, nil +} + +// QueryScalarData Scalar cross product query. +// The internal endpoint to query scalar/table data for multiple data sources and +// process the data using formulas and functions. +func (a *MetricsApi) QueryScalarData(ctx _context.Context, body ScalarFormulaQueryRequest) (ScalarFormulaQueryResponse, *_nethttp.Response, error) { + req, err := a.buildQueryScalarDataRequest(ctx, body) + if err != nil { + var localVarReturnValue ScalarFormulaQueryResponse + return localVarReturnValue, nil, err + } + + return a.queryScalarDataExecute(req) +} + +// queryScalarDataExecute executes the request. +func (a *MetricsApi) queryScalarDataExecute(r apiQueryScalarDataRequest) (ScalarFormulaQueryResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue ScalarFormulaQueryResponse + ) + + operationId := "v2.QueryScalarData" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.MetricsApi.QueryScalarData") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/query/scalar" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.body == nil { + return localVarReturnValue, nil, datadog.ReportError("body is required and must be specified") + } + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = r.body + datadog.SetAuthKeys( + r.ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := _io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + +type apiQueryTimeseriesDataRequest struct { + ctx _context.Context + body *TimeseriesFormulaQueryRequest +} + +func (a *MetricsApi) buildQueryTimeseriesDataRequest(ctx _context.Context, body TimeseriesFormulaQueryRequest) (apiQueryTimeseriesDataRequest, error) { + req := apiQueryTimeseriesDataRequest{ + ctx: ctx, + body: &body, + } + return req, nil +} + +// QueryTimeseriesData Timeseries cross product query. +// The internal endpoint to query timeseries data for multiple data sources and +// process the data by applying formulas and functions. +func (a *MetricsApi) QueryTimeseriesData(ctx _context.Context, body TimeseriesFormulaQueryRequest) (TimeseriesFormulaQueryResponse, *_nethttp.Response, error) { + req, err := a.buildQueryTimeseriesDataRequest(ctx, body) + if err != nil { + var localVarReturnValue TimeseriesFormulaQueryResponse + return localVarReturnValue, nil, err + } + + return a.queryTimeseriesDataExecute(req) +} + +// queryTimeseriesDataExecute executes the request. +func (a *MetricsApi) queryTimeseriesDataExecute(r apiQueryTimeseriesDataRequest) (TimeseriesFormulaQueryResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodPost + localVarPostBody interface{} + localVarReturnValue TimeseriesFormulaQueryResponse + ) + + operationId := "v2.QueryTimeseriesData" + if a.Client.Cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.Client.Cfg.ServerURLWithContext(r.ctx, "v2.MetricsApi.QueryTimeseriesData") + if err != nil { + return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()} + } + + localVarPath := localBasePath + "/api/v2/query/timeseries" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.body == nil { + return localVarReturnValue, nil, datadog.ReportError("body is required and must be specified") + } + localVarHeaderParams["Content-Type"] = "application/json" + localVarHeaderParams["Accept"] = "application/json" + + // body params + localVarPostBody = r.body + datadog.SetAuthKeys( + r.ctx, + &localVarHeaderParams, + [2]string{"apiKeyAuth", "DD-API-KEY"}, + [2]string{"appKeyAuth", "DD-APPLICATION-KEY"}, + ) + req, err := a.Client.PrepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.Client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := _io.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _io.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.ErrorModel = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := datadog.GenericOpenAPIError{ + ErrorBody: localVarBody, + ErrorMessage: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + type apiSubmitMetricsRequest struct { ctx _context.Context body *MetricPayload diff --git a/api/datadogV2/doc.go b/api/datadogV2/doc.go index c1326ed03bd..41c88988825 100644 --- a/api/datadogV2/doc.go +++ b/api/datadogV2/doc.go @@ -98,6 +98,8 @@ // - [MetricsApi.ListTagConfigurations] // - [MetricsApi.ListTagsByMetricName] // - [MetricsApi.ListVolumesByMetricName] +// - [MetricsApi.QueryScalarData] +// - [MetricsApi.QueryTimeseriesData] // - [MetricsApi.SubmitMetrics] // - [MetricsApi.UpdateTagConfiguration] // - [OpsgenieIntegrationApi.CreateOpsgenieService] diff --git a/api/datadogV2/model_events_aggregation.go b/api/datadogV2/model_events_aggregation.go new file mode 100644 index 00000000000..fff73ddd843 --- /dev/null +++ b/api/datadogV2/model_events_aggregation.go @@ -0,0 +1,127 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// EventsAggregation The type of aggregation that can be performed on events-based queries. +type EventsAggregation string + +// List of EventsAggregation. +const ( + EVENTSAGGREGATION_COUNT EventsAggregation = "count" + EVENTSAGGREGATION_CARDINALITY EventsAggregation = "cardinality" + EVENTSAGGREGATION_PC75 EventsAggregation = "pc75" + EVENTSAGGREGATION_PC90 EventsAggregation = "pc90" + EVENTSAGGREGATION_PC95 EventsAggregation = "pc95" + EVENTSAGGREGATION_PC98 EventsAggregation = "pc98" + EVENTSAGGREGATION_PC99 EventsAggregation = "pc99" + EVENTSAGGREGATION_SUM EventsAggregation = "sum" + EVENTSAGGREGATION_MIN EventsAggregation = "min" + EVENTSAGGREGATION_MAX EventsAggregation = "max" + EVENTSAGGREGATION_AVG EventsAggregation = "avg" +) + +var allowedEventsAggregationEnumValues = []EventsAggregation{ + EVENTSAGGREGATION_COUNT, + EVENTSAGGREGATION_CARDINALITY, + EVENTSAGGREGATION_PC75, + EVENTSAGGREGATION_PC90, + EVENTSAGGREGATION_PC95, + EVENTSAGGREGATION_PC98, + EVENTSAGGREGATION_PC99, + EVENTSAGGREGATION_SUM, + EVENTSAGGREGATION_MIN, + EVENTSAGGREGATION_MAX, + EVENTSAGGREGATION_AVG, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *EventsAggregation) GetAllowedValues() []EventsAggregation { + return allowedEventsAggregationEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *EventsAggregation) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = EventsAggregation(value) + return nil +} + +// NewEventsAggregationFromValue returns a pointer to a valid EventsAggregation +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewEventsAggregationFromValue(v string) (*EventsAggregation, error) { + ev := EventsAggregation(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for EventsAggregation: valid values are %v", v, allowedEventsAggregationEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v EventsAggregation) IsValid() bool { + for _, existing := range allowedEventsAggregationEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to EventsAggregation value. +func (v EventsAggregation) Ptr() *EventsAggregation { + return &v +} + +// NullableEventsAggregation handles when a null is used for EventsAggregation. +type NullableEventsAggregation struct { + value *EventsAggregation + isSet bool +} + +// Get returns the associated value. +func (v NullableEventsAggregation) Get() *EventsAggregation { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableEventsAggregation) Set(val *EventsAggregation) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableEventsAggregation) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag. +func (v *NullableEventsAggregation) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableEventsAggregation initializes the struct as if Set has been called. +func NewNullableEventsAggregation(val *EventsAggregation) *NullableEventsAggregation { + return &NullableEventsAggregation{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableEventsAggregation) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableEventsAggregation) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_events_compute.go b/api/datadogV2/model_events_compute.go new file mode 100644 index 00000000000..769f2722815 --- /dev/null +++ b/api/datadogV2/model_events_compute.go @@ -0,0 +1,183 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// EventsCompute The instructions for what to compute for this query. +type EventsCompute struct { + // The type of aggregation that can be performed on events-based queries. + Aggregation EventsAggregation `json:"aggregation"` + // Interval for compute in milliseconds. + Interval *int64 `json:"interval,omitempty"` + // The "measure" attribute on which to perform the computation. + Metric *string `json:"metric,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewEventsCompute instantiates a new EventsCompute object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewEventsCompute(aggregation EventsAggregation) *EventsCompute { + this := EventsCompute{} + this.Aggregation = aggregation + return &this +} + +// NewEventsComputeWithDefaults instantiates a new EventsCompute object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewEventsComputeWithDefaults() *EventsCompute { + this := EventsCompute{} + var aggregation EventsAggregation = EVENTSAGGREGATION_COUNT + this.Aggregation = aggregation + return &this +} + +// GetAggregation returns the Aggregation field value. +func (o *EventsCompute) GetAggregation() EventsAggregation { + if o == nil { + var ret EventsAggregation + return ret + } + return o.Aggregation +} + +// GetAggregationOk returns a tuple with the Aggregation field value +// and a boolean to check if the value has been set. +func (o *EventsCompute) GetAggregationOk() (*EventsAggregation, bool) { + if o == nil { + return nil, false + } + return &o.Aggregation, true +} + +// SetAggregation sets field value. +func (o *EventsCompute) SetAggregation(v EventsAggregation) { + o.Aggregation = v +} + +// GetInterval returns the Interval field value if set, zero value otherwise. +func (o *EventsCompute) GetInterval() int64 { + if o == nil || o.Interval == nil { + var ret int64 + return ret + } + return *o.Interval +} + +// GetIntervalOk returns a tuple with the Interval field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsCompute) GetIntervalOk() (*int64, bool) { + if o == nil || o.Interval == nil { + return nil, false + } + return o.Interval, true +} + +// HasInterval returns a boolean if a field has been set. +func (o *EventsCompute) HasInterval() bool { + return o != nil && o.Interval != nil +} + +// SetInterval gets a reference to the given int64 and assigns it to the Interval field. +func (o *EventsCompute) SetInterval(v int64) { + o.Interval = &v +} + +// GetMetric returns the Metric field value if set, zero value otherwise. +func (o *EventsCompute) GetMetric() string { + if o == nil || o.Metric == nil { + var ret string + return ret + } + return *o.Metric +} + +// GetMetricOk returns a tuple with the Metric field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsCompute) GetMetricOk() (*string, bool) { + if o == nil || o.Metric == nil { + return nil, false + } + return o.Metric, true +} + +// HasMetric returns a boolean if a field has been set. +func (o *EventsCompute) HasMetric() bool { + return o != nil && o.Metric != nil +} + +// SetMetric gets a reference to the given string and assigns it to the Metric field. +func (o *EventsCompute) SetMetric(v string) { + o.Metric = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventsCompute) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["aggregation"] = o.Aggregation + if o.Interval != nil { + toSerialize["interval"] = o.Interval + } + if o.Metric != nil { + toSerialize["metric"] = o.Metric + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *EventsCompute) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Aggregation *EventsAggregation `json:"aggregation"` + }{} + all := struct { + Aggregation EventsAggregation `json:"aggregation"` + Interval *int64 `json:"interval,omitempty"` + Metric *string `json:"metric,omitempty"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Aggregation == nil { + return fmt.Errorf("required field aggregation missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Aggregation; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Aggregation = all.Aggregation + o.Interval = all.Interval + o.Metric = all.Metric + return nil +} diff --git a/api/datadogV2/model_events_data_source_enum.go b/api/datadogV2/model_events_data_source_enum.go new file mode 100644 index 00000000000..99083a1f744 --- /dev/null +++ b/api/datadogV2/model_events_data_source_enum.go @@ -0,0 +1,107 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// EventsDataSourceEnum A data source that is powered by the Events Platform. +type EventsDataSourceEnum string + +// List of EventsDataSourceEnum. +const ( + EVENTSDATASOURCEENUM_LOGS EventsDataSourceEnum = "logs" +) + +var allowedEventsDataSourceEnumEnumValues = []EventsDataSourceEnum{ + EVENTSDATASOURCEENUM_LOGS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *EventsDataSourceEnum) GetAllowedValues() []EventsDataSourceEnum { + return allowedEventsDataSourceEnumEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *EventsDataSourceEnum) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = EventsDataSourceEnum(value) + return nil +} + +// NewEventsDataSourceEnumFromValue returns a pointer to a valid EventsDataSourceEnum +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewEventsDataSourceEnumFromValue(v string) (*EventsDataSourceEnum, error) { + ev := EventsDataSourceEnum(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for EventsDataSourceEnum: valid values are %v", v, allowedEventsDataSourceEnumEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v EventsDataSourceEnum) IsValid() bool { + for _, existing := range allowedEventsDataSourceEnumEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to EventsDataSourceEnum value. +func (v EventsDataSourceEnum) Ptr() *EventsDataSourceEnum { + return &v +} + +// NullableEventsDataSourceEnum handles when a null is used for EventsDataSourceEnum. +type NullableEventsDataSourceEnum struct { + value *EventsDataSourceEnum + isSet bool +} + +// Get returns the associated value. +func (v NullableEventsDataSourceEnum) Get() *EventsDataSourceEnum { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableEventsDataSourceEnum) Set(val *EventsDataSourceEnum) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableEventsDataSourceEnum) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag. +func (v *NullableEventsDataSourceEnum) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableEventsDataSourceEnum initializes the struct as if Set has been called. +func NewNullableEventsDataSourceEnum(val *EventsDataSourceEnum) *NullableEventsDataSourceEnum { + return &NullableEventsDataSourceEnum{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableEventsDataSourceEnum) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableEventsDataSourceEnum) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_events_group_by.go b/api/datadogV2/model_events_group_by.go new file mode 100644 index 00000000000..336c9e40294 --- /dev/null +++ b/api/datadogV2/model_events_group_by.go @@ -0,0 +1,180 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// EventsGroupBy A dimension on which to split a query's results. +type EventsGroupBy struct { + // The facet by which to split groups. + Facet string `json:"facet"` + // The maximum number of groups to return. + Limit *int32 `json:"limit,omitempty"` + // The dimension by which to sort a query's results. + Sort *EventsSortField `json:"sort,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewEventsGroupBy instantiates a new EventsGroupBy object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewEventsGroupBy(facet string) *EventsGroupBy { + this := EventsGroupBy{} + this.Facet = facet + return &this +} + +// NewEventsGroupByWithDefaults instantiates a new EventsGroupBy object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewEventsGroupByWithDefaults() *EventsGroupBy { + this := EventsGroupBy{} + return &this +} + +// GetFacet returns the Facet field value. +func (o *EventsGroupBy) GetFacet() string { + if o == nil { + var ret string + return ret + } + return o.Facet +} + +// GetFacetOk returns a tuple with the Facet field value +// and a boolean to check if the value has been set. +func (o *EventsGroupBy) GetFacetOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Facet, true +} + +// SetFacet sets field value. +func (o *EventsGroupBy) SetFacet(v string) { + o.Facet = v +} + +// GetLimit returns the Limit field value if set, zero value otherwise. +func (o *EventsGroupBy) GetLimit() int32 { + if o == nil || o.Limit == nil { + var ret int32 + return ret + } + return *o.Limit +} + +// GetLimitOk returns a tuple with the Limit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsGroupBy) GetLimitOk() (*int32, bool) { + if o == nil || o.Limit == nil { + return nil, false + } + return o.Limit, true +} + +// HasLimit returns a boolean if a field has been set. +func (o *EventsGroupBy) HasLimit() bool { + return o != nil && o.Limit != nil +} + +// SetLimit gets a reference to the given int32 and assigns it to the Limit field. +func (o *EventsGroupBy) SetLimit(v int32) { + o.Limit = &v +} + +// GetSort returns the Sort field value if set, zero value otherwise. +func (o *EventsGroupBy) GetSort() EventsSortField { + if o == nil || o.Sort == nil { + var ret EventsSortField + return ret + } + return *o.Sort +} + +// GetSortOk returns a tuple with the Sort field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsGroupBy) GetSortOk() (*EventsSortField, bool) { + if o == nil || o.Sort == nil { + return nil, false + } + return o.Sort, true +} + +// HasSort returns a boolean if a field has been set. +func (o *EventsGroupBy) HasSort() bool { + return o != nil && o.Sort != nil +} + +// SetSort gets a reference to the given EventsSortField and assigns it to the Sort field. +func (o *EventsGroupBy) SetSort(v EventsSortField) { + o.Sort = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventsGroupBy) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["facet"] = o.Facet + if o.Limit != nil { + toSerialize["limit"] = o.Limit + } + if o.Sort != nil { + toSerialize["sort"] = o.Sort + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *EventsGroupBy) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Facet *string `json:"facet"` + }{} + all := struct { + Facet string `json:"facet"` + Limit *int32 `json:"limit,omitempty"` + Sort *EventsSortField `json:"sort,omitempty"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Facet == nil { + return fmt.Errorf("required field facet missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Facet = all.Facet + o.Limit = all.Limit + if all.Sort != nil && all.Sort.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Sort = all.Sort + return nil +} diff --git a/api/datadogV2/model_events_scalar_query.go b/api/datadogV2/model_events_scalar_query.go new file mode 100644 index 00000000000..a60b897f1a8 --- /dev/null +++ b/api/datadogV2/model_events_scalar_query.go @@ -0,0 +1,300 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// EventsScalarQuery An individual scalar events query. +type EventsScalarQuery struct { + // The instructions for what to compute for this query. + Compute EventsCompute `json:"compute"` + // A data source that is powered by the Events Platform. + DataSource EventsDataSourceEnum `json:"data_source"` + // The list of facets on which to split results. + GroupBy []EventsGroupBy `json:"group_by,omitempty"` + // The indexes in which to search. + Indexes []string `json:"indexes,omitempty"` + // The variable name for use in formulas. + Name *string `json:"name,omitempty"` + // Configuration of the search/filter for an events query. + Search *EventsSearch `json:"search,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewEventsScalarQuery instantiates a new EventsScalarQuery object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewEventsScalarQuery(compute EventsCompute, dataSource EventsDataSourceEnum) *EventsScalarQuery { + this := EventsScalarQuery{} + this.Compute = compute + this.DataSource = dataSource + return &this +} + +// NewEventsScalarQueryWithDefaults instantiates a new EventsScalarQuery object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewEventsScalarQueryWithDefaults() *EventsScalarQuery { + this := EventsScalarQuery{} + var dataSource EventsDataSourceEnum = EVENTSDATASOURCEENUM_LOGS + this.DataSource = dataSource + return &this +} + +// GetCompute returns the Compute field value. +func (o *EventsScalarQuery) GetCompute() EventsCompute { + if o == nil { + var ret EventsCompute + return ret + } + return o.Compute +} + +// GetComputeOk returns a tuple with the Compute field value +// and a boolean to check if the value has been set. +func (o *EventsScalarQuery) GetComputeOk() (*EventsCompute, bool) { + if o == nil { + return nil, false + } + return &o.Compute, true +} + +// SetCompute sets field value. +func (o *EventsScalarQuery) SetCompute(v EventsCompute) { + o.Compute = v +} + +// GetDataSource returns the DataSource field value. +func (o *EventsScalarQuery) GetDataSource() EventsDataSourceEnum { + if o == nil { + var ret EventsDataSourceEnum + return ret + } + return o.DataSource +} + +// GetDataSourceOk returns a tuple with the DataSource field value +// and a boolean to check if the value has been set. +func (o *EventsScalarQuery) GetDataSourceOk() (*EventsDataSourceEnum, bool) { + if o == nil { + return nil, false + } + return &o.DataSource, true +} + +// SetDataSource sets field value. +func (o *EventsScalarQuery) SetDataSource(v EventsDataSourceEnum) { + o.DataSource = v +} + +// GetGroupBy returns the GroupBy field value if set, zero value otherwise. +func (o *EventsScalarQuery) GetGroupBy() []EventsGroupBy { + if o == nil || o.GroupBy == nil { + var ret []EventsGroupBy + return ret + } + return o.GroupBy +} + +// GetGroupByOk returns a tuple with the GroupBy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsScalarQuery) GetGroupByOk() (*[]EventsGroupBy, bool) { + if o == nil || o.GroupBy == nil { + return nil, false + } + return &o.GroupBy, true +} + +// HasGroupBy returns a boolean if a field has been set. +func (o *EventsScalarQuery) HasGroupBy() bool { + return o != nil && o.GroupBy != nil +} + +// SetGroupBy gets a reference to the given []EventsGroupBy and assigns it to the GroupBy field. +func (o *EventsScalarQuery) SetGroupBy(v []EventsGroupBy) { + o.GroupBy = v +} + +// GetIndexes returns the Indexes field value if set, zero value otherwise. +func (o *EventsScalarQuery) GetIndexes() []string { + if o == nil || o.Indexes == nil { + var ret []string + return ret + } + return o.Indexes +} + +// GetIndexesOk returns a tuple with the Indexes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsScalarQuery) GetIndexesOk() (*[]string, bool) { + if o == nil || o.Indexes == nil { + return nil, false + } + return &o.Indexes, true +} + +// HasIndexes returns a boolean if a field has been set. +func (o *EventsScalarQuery) HasIndexes() bool { + return o != nil && o.Indexes != nil +} + +// SetIndexes gets a reference to the given []string and assigns it to the Indexes field. +func (o *EventsScalarQuery) SetIndexes(v []string) { + o.Indexes = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *EventsScalarQuery) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsScalarQuery) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *EventsScalarQuery) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *EventsScalarQuery) SetName(v string) { + o.Name = &v +} + +// GetSearch returns the Search field value if set, zero value otherwise. +func (o *EventsScalarQuery) GetSearch() EventsSearch { + if o == nil || o.Search == nil { + var ret EventsSearch + return ret + } + return *o.Search +} + +// GetSearchOk returns a tuple with the Search field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsScalarQuery) GetSearchOk() (*EventsSearch, bool) { + if o == nil || o.Search == nil { + return nil, false + } + return o.Search, true +} + +// HasSearch returns a boolean if a field has been set. +func (o *EventsScalarQuery) HasSearch() bool { + return o != nil && o.Search != nil +} + +// SetSearch gets a reference to the given EventsSearch and assigns it to the Search field. +func (o *EventsScalarQuery) SetSearch(v EventsSearch) { + o.Search = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventsScalarQuery) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["compute"] = o.Compute + toSerialize["data_source"] = o.DataSource + if o.GroupBy != nil { + toSerialize["group_by"] = o.GroupBy + } + if o.Indexes != nil { + toSerialize["indexes"] = o.Indexes + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Search != nil { + toSerialize["search"] = o.Search + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *EventsScalarQuery) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Compute *EventsCompute `json:"compute"` + DataSource *EventsDataSourceEnum `json:"data_source"` + }{} + all := struct { + Compute EventsCompute `json:"compute"` + DataSource EventsDataSourceEnum `json:"data_source"` + GroupBy []EventsGroupBy `json:"group_by,omitempty"` + Indexes []string `json:"indexes,omitempty"` + Name *string `json:"name,omitempty"` + Search *EventsSearch `json:"search,omitempty"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Compute == nil { + return fmt.Errorf("required field compute missing") + } + if required.DataSource == nil { + return fmt.Errorf("required field data_source missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.DataSource; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Compute.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Compute = all.Compute + o.DataSource = all.DataSource + o.GroupBy = all.GroupBy + o.Indexes = all.Indexes + o.Name = all.Name + if all.Search != nil && all.Search.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Search = all.Search + return nil +} diff --git a/api/datadogV2/model_events_search.go b/api/datadogV2/model_events_search.go new file mode 100644 index 00000000000..9720e3d834c --- /dev/null +++ b/api/datadogV2/model_events_search.go @@ -0,0 +1,98 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// EventsSearch Configuration of the search/filter for an events query. +type EventsSearch struct { + // The search/filter string for an events query. + Query *string `json:"query,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewEventsSearch instantiates a new EventsSearch object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewEventsSearch() *EventsSearch { + this := EventsSearch{} + return &this +} + +// NewEventsSearchWithDefaults instantiates a new EventsSearch object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewEventsSearchWithDefaults() *EventsSearch { + this := EventsSearch{} + return &this +} + +// GetQuery returns the Query field value if set, zero value otherwise. +func (o *EventsSearch) GetQuery() string { + if o == nil || o.Query == nil { + var ret string + return ret + } + return *o.Query +} + +// GetQueryOk returns a tuple with the Query field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsSearch) GetQueryOk() (*string, bool) { + if o == nil || o.Query == nil { + return nil, false + } + return o.Query, true +} + +// HasQuery returns a boolean if a field has been set. +func (o *EventsSearch) HasQuery() bool { + return o != nil && o.Query != nil +} + +// SetQuery gets a reference to the given string and assigns it to the Query field. +func (o *EventsSearch) SetQuery(v string) { + o.Query = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventsSearch) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Query != nil { + toSerialize["query"] = o.Query + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *EventsSearch) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Query *string `json:"query,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Query = all.Query + return nil +} diff --git a/api/datadogV2/model_events_sort_field.go b/api/datadogV2/model_events_sort_field.go new file mode 100644 index 00000000000..73087651028 --- /dev/null +++ b/api/datadogV2/model_events_sort_field.go @@ -0,0 +1,238 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// EventsSortField The dimension by which to sort a query's results. +type EventsSortField struct { + // The type of aggregation that can be performed on events-based queries. + Aggregation EventsAggregation `json:"aggregation"` + // Metric whose calculated value should be used to define the sort order of a query's results. + Metric *string `json:"metric,omitempty"` + // Direction of sort. + Order *QuerySortOrder `json:"order,omitempty"` + // The type of sort to use on the calculated value. + Type *EventsSortTypeEnum `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewEventsSortField instantiates a new EventsSortField object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewEventsSortField(aggregation EventsAggregation) *EventsSortField { + this := EventsSortField{} + this.Aggregation = aggregation + var order QuerySortOrder = QUERYSORTORDER_DESC + this.Order = &order + return &this +} + +// NewEventsSortFieldWithDefaults instantiates a new EventsSortField object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewEventsSortFieldWithDefaults() *EventsSortField { + this := EventsSortField{} + var aggregation EventsAggregation = EVENTSAGGREGATION_COUNT + this.Aggregation = aggregation + var order QuerySortOrder = QUERYSORTORDER_DESC + this.Order = &order + return &this +} + +// GetAggregation returns the Aggregation field value. +func (o *EventsSortField) GetAggregation() EventsAggregation { + if o == nil { + var ret EventsAggregation + return ret + } + return o.Aggregation +} + +// GetAggregationOk returns a tuple with the Aggregation field value +// and a boolean to check if the value has been set. +func (o *EventsSortField) GetAggregationOk() (*EventsAggregation, bool) { + if o == nil { + return nil, false + } + return &o.Aggregation, true +} + +// SetAggregation sets field value. +func (o *EventsSortField) SetAggregation(v EventsAggregation) { + o.Aggregation = v +} + +// GetMetric returns the Metric field value if set, zero value otherwise. +func (o *EventsSortField) GetMetric() string { + if o == nil || o.Metric == nil { + var ret string + return ret + } + return *o.Metric +} + +// GetMetricOk returns a tuple with the Metric field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsSortField) GetMetricOk() (*string, bool) { + if o == nil || o.Metric == nil { + return nil, false + } + return o.Metric, true +} + +// HasMetric returns a boolean if a field has been set. +func (o *EventsSortField) HasMetric() bool { + return o != nil && o.Metric != nil +} + +// SetMetric gets a reference to the given string and assigns it to the Metric field. +func (o *EventsSortField) SetMetric(v string) { + o.Metric = &v +} + +// GetOrder returns the Order field value if set, zero value otherwise. +func (o *EventsSortField) GetOrder() QuerySortOrder { + if o == nil || o.Order == nil { + var ret QuerySortOrder + return ret + } + return *o.Order +} + +// GetOrderOk returns a tuple with the Order field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsSortField) GetOrderOk() (*QuerySortOrder, bool) { + if o == nil || o.Order == nil { + return nil, false + } + return o.Order, true +} + +// HasOrder returns a boolean if a field has been set. +func (o *EventsSortField) HasOrder() bool { + return o != nil && o.Order != nil +} + +// SetOrder gets a reference to the given QuerySortOrder and assigns it to the Order field. +func (o *EventsSortField) SetOrder(v QuerySortOrder) { + o.Order = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *EventsSortField) GetType() EventsSortTypeEnum { + if o == nil || o.Type == nil { + var ret EventsSortTypeEnum + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsSortField) GetTypeOk() (*EventsSortTypeEnum, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *EventsSortField) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given EventsSortTypeEnum and assigns it to the Type field. +func (o *EventsSortField) SetType(v EventsSortTypeEnum) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventsSortField) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["aggregation"] = o.Aggregation + if o.Metric != nil { + toSerialize["metric"] = o.Metric + } + if o.Order != nil { + toSerialize["order"] = o.Order + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *EventsSortField) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Aggregation *EventsAggregation `json:"aggregation"` + }{} + all := struct { + Aggregation EventsAggregation `json:"aggregation"` + Metric *string `json:"metric,omitempty"` + Order *QuerySortOrder `json:"order,omitempty"` + Type *EventsSortTypeEnum `json:"type,omitempty"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Aggregation == nil { + return fmt.Errorf("required field aggregation missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Aggregation; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Order; v != nil && !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Type; v != nil && !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Aggregation = all.Aggregation + o.Metric = all.Metric + o.Order = all.Order + o.Type = all.Type + return nil +} diff --git a/api/datadogV2/model_events_sort_type_enum.go b/api/datadogV2/model_events_sort_type_enum.go new file mode 100644 index 00000000000..d9d78f19627 --- /dev/null +++ b/api/datadogV2/model_events_sort_type_enum.go @@ -0,0 +1,109 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// EventsSortTypeEnum The type of sort to use on the calculated value. +type EventsSortTypeEnum string + +// List of EventsSortTypeEnum. +const ( + EVENTSSORTTYPEENUM_ALPHABETICAL EventsSortTypeEnum = "alphabetical" + EVENTSSORTTYPEENUM_MEASURE EventsSortTypeEnum = "measure" +) + +var allowedEventsSortTypeEnumEnumValues = []EventsSortTypeEnum{ + EVENTSSORTTYPEENUM_ALPHABETICAL, + EVENTSSORTTYPEENUM_MEASURE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *EventsSortTypeEnum) GetAllowedValues() []EventsSortTypeEnum { + return allowedEventsSortTypeEnumEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *EventsSortTypeEnum) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = EventsSortTypeEnum(value) + return nil +} + +// NewEventsSortTypeEnumFromValue returns a pointer to a valid EventsSortTypeEnum +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewEventsSortTypeEnumFromValue(v string) (*EventsSortTypeEnum, error) { + ev := EventsSortTypeEnum(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for EventsSortTypeEnum: valid values are %v", v, allowedEventsSortTypeEnumEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v EventsSortTypeEnum) IsValid() bool { + for _, existing := range allowedEventsSortTypeEnumEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to EventsSortTypeEnum value. +func (v EventsSortTypeEnum) Ptr() *EventsSortTypeEnum { + return &v +} + +// NullableEventsSortTypeEnum handles when a null is used for EventsSortTypeEnum. +type NullableEventsSortTypeEnum struct { + value *EventsSortTypeEnum + isSet bool +} + +// Get returns the associated value. +func (v NullableEventsSortTypeEnum) Get() *EventsSortTypeEnum { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableEventsSortTypeEnum) Set(val *EventsSortTypeEnum) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableEventsSortTypeEnum) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag. +func (v *NullableEventsSortTypeEnum) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableEventsSortTypeEnum initializes the struct as if Set has been called. +func NewNullableEventsSortTypeEnum(val *EventsSortTypeEnum) *NullableEventsSortTypeEnum { + return &NullableEventsSortTypeEnum{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableEventsSortTypeEnum) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableEventsSortTypeEnum) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_events_timeseries_query.go b/api/datadogV2/model_events_timeseries_query.go new file mode 100644 index 00000000000..bd1360bc0aa --- /dev/null +++ b/api/datadogV2/model_events_timeseries_query.go @@ -0,0 +1,300 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// EventsTimeseriesQuery An individual timeseries events query. +type EventsTimeseriesQuery struct { + // The instructions for what to compute for this query. + Compute EventsCompute `json:"compute"` + // A data source that is powered by the Events Platform. + DataSource EventsDataSourceEnum `json:"data_source"` + // The list of facets on which to split results. + GroupBy []EventsGroupBy `json:"group_by,omitempty"` + // The indexes in which to search. + Indexes []string `json:"indexes,omitempty"` + // The variable name for use in formulas. + Name *string `json:"name,omitempty"` + // Configuration of the search/filter for an events query. + Search *EventsSearch `json:"search,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewEventsTimeseriesQuery instantiates a new EventsTimeseriesQuery object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewEventsTimeseriesQuery(compute EventsCompute, dataSource EventsDataSourceEnum) *EventsTimeseriesQuery { + this := EventsTimeseriesQuery{} + this.Compute = compute + this.DataSource = dataSource + return &this +} + +// NewEventsTimeseriesQueryWithDefaults instantiates a new EventsTimeseriesQuery object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewEventsTimeseriesQueryWithDefaults() *EventsTimeseriesQuery { + this := EventsTimeseriesQuery{} + var dataSource EventsDataSourceEnum = EVENTSDATASOURCEENUM_LOGS + this.DataSource = dataSource + return &this +} + +// GetCompute returns the Compute field value. +func (o *EventsTimeseriesQuery) GetCompute() EventsCompute { + if o == nil { + var ret EventsCompute + return ret + } + return o.Compute +} + +// GetComputeOk returns a tuple with the Compute field value +// and a boolean to check if the value has been set. +func (o *EventsTimeseriesQuery) GetComputeOk() (*EventsCompute, bool) { + if o == nil { + return nil, false + } + return &o.Compute, true +} + +// SetCompute sets field value. +func (o *EventsTimeseriesQuery) SetCompute(v EventsCompute) { + o.Compute = v +} + +// GetDataSource returns the DataSource field value. +func (o *EventsTimeseriesQuery) GetDataSource() EventsDataSourceEnum { + if o == nil { + var ret EventsDataSourceEnum + return ret + } + return o.DataSource +} + +// GetDataSourceOk returns a tuple with the DataSource field value +// and a boolean to check if the value has been set. +func (o *EventsTimeseriesQuery) GetDataSourceOk() (*EventsDataSourceEnum, bool) { + if o == nil { + return nil, false + } + return &o.DataSource, true +} + +// SetDataSource sets field value. +func (o *EventsTimeseriesQuery) SetDataSource(v EventsDataSourceEnum) { + o.DataSource = v +} + +// GetGroupBy returns the GroupBy field value if set, zero value otherwise. +func (o *EventsTimeseriesQuery) GetGroupBy() []EventsGroupBy { + if o == nil || o.GroupBy == nil { + var ret []EventsGroupBy + return ret + } + return o.GroupBy +} + +// GetGroupByOk returns a tuple with the GroupBy field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsTimeseriesQuery) GetGroupByOk() (*[]EventsGroupBy, bool) { + if o == nil || o.GroupBy == nil { + return nil, false + } + return &o.GroupBy, true +} + +// HasGroupBy returns a boolean if a field has been set. +func (o *EventsTimeseriesQuery) HasGroupBy() bool { + return o != nil && o.GroupBy != nil +} + +// SetGroupBy gets a reference to the given []EventsGroupBy and assigns it to the GroupBy field. +func (o *EventsTimeseriesQuery) SetGroupBy(v []EventsGroupBy) { + o.GroupBy = v +} + +// GetIndexes returns the Indexes field value if set, zero value otherwise. +func (o *EventsTimeseriesQuery) GetIndexes() []string { + if o == nil || o.Indexes == nil { + var ret []string + return ret + } + return o.Indexes +} + +// GetIndexesOk returns a tuple with the Indexes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsTimeseriesQuery) GetIndexesOk() (*[]string, bool) { + if o == nil || o.Indexes == nil { + return nil, false + } + return &o.Indexes, true +} + +// HasIndexes returns a boolean if a field has been set. +func (o *EventsTimeseriesQuery) HasIndexes() bool { + return o != nil && o.Indexes != nil +} + +// SetIndexes gets a reference to the given []string and assigns it to the Indexes field. +func (o *EventsTimeseriesQuery) SetIndexes(v []string) { + o.Indexes = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *EventsTimeseriesQuery) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsTimeseriesQuery) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *EventsTimeseriesQuery) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *EventsTimeseriesQuery) SetName(v string) { + o.Name = &v +} + +// GetSearch returns the Search field value if set, zero value otherwise. +func (o *EventsTimeseriesQuery) GetSearch() EventsSearch { + if o == nil || o.Search == nil { + var ret EventsSearch + return ret + } + return *o.Search +} + +// GetSearchOk returns a tuple with the Search field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *EventsTimeseriesQuery) GetSearchOk() (*EventsSearch, bool) { + if o == nil || o.Search == nil { + return nil, false + } + return o.Search, true +} + +// HasSearch returns a boolean if a field has been set. +func (o *EventsTimeseriesQuery) HasSearch() bool { + return o != nil && o.Search != nil +} + +// SetSearch gets a reference to the given EventsSearch and assigns it to the Search field. +func (o *EventsTimeseriesQuery) SetSearch(v EventsSearch) { + o.Search = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o EventsTimeseriesQuery) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["compute"] = o.Compute + toSerialize["data_source"] = o.DataSource + if o.GroupBy != nil { + toSerialize["group_by"] = o.GroupBy + } + if o.Indexes != nil { + toSerialize["indexes"] = o.Indexes + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Search != nil { + toSerialize["search"] = o.Search + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *EventsTimeseriesQuery) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Compute *EventsCompute `json:"compute"` + DataSource *EventsDataSourceEnum `json:"data_source"` + }{} + all := struct { + Compute EventsCompute `json:"compute"` + DataSource EventsDataSourceEnum `json:"data_source"` + GroupBy []EventsGroupBy `json:"group_by,omitempty"` + Indexes []string `json:"indexes,omitempty"` + Name *string `json:"name,omitempty"` + Search *EventsSearch `json:"search,omitempty"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Compute == nil { + return fmt.Errorf("required field compute missing") + } + if required.DataSource == nil { + return fmt.Errorf("required field data_source missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.DataSource; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Compute.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Compute = all.Compute + o.DataSource = all.DataSource + o.GroupBy = all.GroupBy + o.Indexes = all.Indexes + o.Name = all.Name + if all.Search != nil && all.Search.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Search = all.Search + return nil +} diff --git a/api/datadogV2/model_formula_limit.go b/api/datadogV2/model_formula_limit.go new file mode 100644 index 00000000000..ac2a16a0a61 --- /dev/null +++ b/api/datadogV2/model_formula_limit.go @@ -0,0 +1,145 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// FormulaLimit Message for specifying limits to the number of values returned by a query. +type FormulaLimit struct { + // The number of results to which to limit. + Count *int32 `json:"count,omitempty"` + // Direction of sort. + Order *QuerySortOrder `json:"order,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewFormulaLimit instantiates a new FormulaLimit object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewFormulaLimit() *FormulaLimit { + this := FormulaLimit{} + var order QuerySortOrder = QUERYSORTORDER_DESC + this.Order = &order + return &this +} + +// NewFormulaLimitWithDefaults instantiates a new FormulaLimit object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewFormulaLimitWithDefaults() *FormulaLimit { + this := FormulaLimit{} + var order QuerySortOrder = QUERYSORTORDER_DESC + this.Order = &order + return &this +} + +// GetCount returns the Count field value if set, zero value otherwise. +func (o *FormulaLimit) GetCount() int32 { + if o == nil || o.Count == nil { + var ret int32 + return ret + } + return *o.Count +} + +// GetCountOk returns a tuple with the Count field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FormulaLimit) GetCountOk() (*int32, bool) { + if o == nil || o.Count == nil { + return nil, false + } + return o.Count, true +} + +// HasCount returns a boolean if a field has been set. +func (o *FormulaLimit) HasCount() bool { + return o != nil && o.Count != nil +} + +// SetCount gets a reference to the given int32 and assigns it to the Count field. +func (o *FormulaLimit) SetCount(v int32) { + o.Count = &v +} + +// GetOrder returns the Order field value if set, zero value otherwise. +func (o *FormulaLimit) GetOrder() QuerySortOrder { + if o == nil || o.Order == nil { + var ret QuerySortOrder + return ret + } + return *o.Order +} + +// GetOrderOk returns a tuple with the Order field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *FormulaLimit) GetOrderOk() (*QuerySortOrder, bool) { + if o == nil || o.Order == nil { + return nil, false + } + return o.Order, true +} + +// HasOrder returns a boolean if a field has been set. +func (o *FormulaLimit) HasOrder() bool { + return o != nil && o.Order != nil +} + +// SetOrder gets a reference to the given QuerySortOrder and assigns it to the Order field. +func (o *FormulaLimit) SetOrder(v QuerySortOrder) { + o.Order = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o FormulaLimit) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Count != nil { + toSerialize["count"] = o.Count + } + if o.Order != nil { + toSerialize["order"] = o.Order + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *FormulaLimit) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Count *int32 `json:"count,omitempty"` + Order *QuerySortOrder `json:"order,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Order; v != nil && !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Count = all.Count + o.Order = all.Order + return nil +} diff --git a/api/datadogV2/model_metrics_aggregator_enum.go b/api/datadogV2/model_metrics_aggregator_enum.go new file mode 100644 index 00000000000..758583f6b13 --- /dev/null +++ b/api/datadogV2/model_metrics_aggregator_enum.go @@ -0,0 +1,115 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// MetricsAggregatorEnum The type of aggregation that can be performed on metrics queries. +type MetricsAggregatorEnum string + +// List of MetricsAggregatorEnum. +const ( + METRICSAGGREGATORENUM_AVG MetricsAggregatorEnum = "avg" + METRICSAGGREGATORENUM_MIN MetricsAggregatorEnum = "min" + METRICSAGGREGATORENUM_MAX MetricsAggregatorEnum = "max" + METRICSAGGREGATORENUM_SUM MetricsAggregatorEnum = "sum" + METRICSAGGREGATORENUM_LAST MetricsAggregatorEnum = "last" +) + +var allowedMetricsAggregatorEnumEnumValues = []MetricsAggregatorEnum{ + METRICSAGGREGATORENUM_AVG, + METRICSAGGREGATORENUM_MIN, + METRICSAGGREGATORENUM_MAX, + METRICSAGGREGATORENUM_SUM, + METRICSAGGREGATORENUM_LAST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *MetricsAggregatorEnum) GetAllowedValues() []MetricsAggregatorEnum { + return allowedMetricsAggregatorEnumEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *MetricsAggregatorEnum) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = MetricsAggregatorEnum(value) + return nil +} + +// NewMetricsAggregatorEnumFromValue returns a pointer to a valid MetricsAggregatorEnum +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewMetricsAggregatorEnumFromValue(v string) (*MetricsAggregatorEnum, error) { + ev := MetricsAggregatorEnum(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for MetricsAggregatorEnum: valid values are %v", v, allowedMetricsAggregatorEnumEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v MetricsAggregatorEnum) IsValid() bool { + for _, existing := range allowedMetricsAggregatorEnumEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to MetricsAggregatorEnum value. +func (v MetricsAggregatorEnum) Ptr() *MetricsAggregatorEnum { + return &v +} + +// NullableMetricsAggregatorEnum handles when a null is used for MetricsAggregatorEnum. +type NullableMetricsAggregatorEnum struct { + value *MetricsAggregatorEnum + isSet bool +} + +// Get returns the associated value. +func (v NullableMetricsAggregatorEnum) Get() *MetricsAggregatorEnum { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableMetricsAggregatorEnum) Set(val *MetricsAggregatorEnum) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableMetricsAggregatorEnum) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag. +func (v *NullableMetricsAggregatorEnum) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableMetricsAggregatorEnum initializes the struct as if Set has been called. +func NewNullableMetricsAggregatorEnum(val *MetricsAggregatorEnum) *NullableMetricsAggregatorEnum { + return &NullableMetricsAggregatorEnum{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableMetricsAggregatorEnum) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableMetricsAggregatorEnum) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_metrics_data_source.go b/api/datadogV2/model_metrics_data_source.go new file mode 100644 index 00000000000..959f482e1f4 --- /dev/null +++ b/api/datadogV2/model_metrics_data_source.go @@ -0,0 +1,107 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// MetricsDataSource A data source that is powered by the Metrics backend. +type MetricsDataSource string + +// List of MetricsDataSource. +const ( + METRICSDATASOURCE_METRICS MetricsDataSource = "metrics" +) + +var allowedMetricsDataSourceEnumValues = []MetricsDataSource{ + METRICSDATASOURCE_METRICS, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *MetricsDataSource) GetAllowedValues() []MetricsDataSource { + return allowedMetricsDataSourceEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *MetricsDataSource) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = MetricsDataSource(value) + return nil +} + +// NewMetricsDataSourceFromValue returns a pointer to a valid MetricsDataSource +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewMetricsDataSourceFromValue(v string) (*MetricsDataSource, error) { + ev := MetricsDataSource(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for MetricsDataSource: valid values are %v", v, allowedMetricsDataSourceEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v MetricsDataSource) IsValid() bool { + for _, existing := range allowedMetricsDataSourceEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to MetricsDataSource value. +func (v MetricsDataSource) Ptr() *MetricsDataSource { + return &v +} + +// NullableMetricsDataSource handles when a null is used for MetricsDataSource. +type NullableMetricsDataSource struct { + value *MetricsDataSource + isSet bool +} + +// Get returns the associated value. +func (v NullableMetricsDataSource) Get() *MetricsDataSource { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableMetricsDataSource) Set(val *MetricsDataSource) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableMetricsDataSource) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag. +func (v *NullableMetricsDataSource) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableMetricsDataSource initializes the struct as if Set has been called. +func NewNullableMetricsDataSource(val *MetricsDataSource) *NullableMetricsDataSource { + return &NullableMetricsDataSource{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableMetricsDataSource) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableMetricsDataSource) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_metrics_scalar_query.go b/api/datadogV2/model_metrics_scalar_query.go new file mode 100644 index 00000000000..b6d973e9f4b --- /dev/null +++ b/api/datadogV2/model_metrics_scalar_query.go @@ -0,0 +1,224 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// MetricsScalarQuery An individual scalar metrics query. +type MetricsScalarQuery struct { + // The type of aggregation that can be performed on metrics queries. + Aggregator MetricsAggregatorEnum `json:"aggregator"` + // A data source that is powered by the Metrics backend. + DataSource MetricsDataSource `json:"data_source"` + // The variable name for use in formulas. + Name *string `json:"name,omitempty"` + // A classic metrics query string. + Query string `json:"query"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewMetricsScalarQuery instantiates a new MetricsScalarQuery object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewMetricsScalarQuery(aggregator MetricsAggregatorEnum, dataSource MetricsDataSource, query string) *MetricsScalarQuery { + this := MetricsScalarQuery{} + this.Aggregator = aggregator + this.DataSource = dataSource + this.Query = query + return &this +} + +// NewMetricsScalarQueryWithDefaults instantiates a new MetricsScalarQuery object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewMetricsScalarQueryWithDefaults() *MetricsScalarQuery { + this := MetricsScalarQuery{} + var aggregator MetricsAggregatorEnum = METRICSAGGREGATORENUM_AVG + this.Aggregator = aggregator + var dataSource MetricsDataSource = METRICSDATASOURCE_METRICS + this.DataSource = dataSource + return &this +} + +// GetAggregator returns the Aggregator field value. +func (o *MetricsScalarQuery) GetAggregator() MetricsAggregatorEnum { + if o == nil { + var ret MetricsAggregatorEnum + return ret + } + return o.Aggregator +} + +// GetAggregatorOk returns a tuple with the Aggregator field value +// and a boolean to check if the value has been set. +func (o *MetricsScalarQuery) GetAggregatorOk() (*MetricsAggregatorEnum, bool) { + if o == nil { + return nil, false + } + return &o.Aggregator, true +} + +// SetAggregator sets field value. +func (o *MetricsScalarQuery) SetAggregator(v MetricsAggregatorEnum) { + o.Aggregator = v +} + +// GetDataSource returns the DataSource field value. +func (o *MetricsScalarQuery) GetDataSource() MetricsDataSource { + if o == nil { + var ret MetricsDataSource + return ret + } + return o.DataSource +} + +// GetDataSourceOk returns a tuple with the DataSource field value +// and a boolean to check if the value has been set. +func (o *MetricsScalarQuery) GetDataSourceOk() (*MetricsDataSource, bool) { + if o == nil { + return nil, false + } + return &o.DataSource, true +} + +// SetDataSource sets field value. +func (o *MetricsScalarQuery) SetDataSource(v MetricsDataSource) { + o.DataSource = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *MetricsScalarQuery) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MetricsScalarQuery) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *MetricsScalarQuery) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *MetricsScalarQuery) SetName(v string) { + o.Name = &v +} + +// GetQuery returns the Query field value. +func (o *MetricsScalarQuery) GetQuery() string { + if o == nil { + var ret string + return ret + } + return o.Query +} + +// GetQueryOk returns a tuple with the Query field value +// and a boolean to check if the value has been set. +func (o *MetricsScalarQuery) GetQueryOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Query, true +} + +// SetQuery sets field value. +func (o *MetricsScalarQuery) SetQuery(v string) { + o.Query = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MetricsScalarQuery) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["aggregator"] = o.Aggregator + toSerialize["data_source"] = o.DataSource + if o.Name != nil { + toSerialize["name"] = o.Name + } + toSerialize["query"] = o.Query + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MetricsScalarQuery) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Aggregator *MetricsAggregatorEnum `json:"aggregator"` + DataSource *MetricsDataSource `json:"data_source"` + Query *string `json:"query"` + }{} + all := struct { + Aggregator MetricsAggregatorEnum `json:"aggregator"` + DataSource MetricsDataSource `json:"data_source"` + Name *string `json:"name,omitempty"` + Query string `json:"query"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Aggregator == nil { + return fmt.Errorf("required field aggregator missing") + } + if required.DataSource == nil { + return fmt.Errorf("required field data_source missing") + } + if required.Query == nil { + return fmt.Errorf("required field query missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Aggregator; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.DataSource; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Aggregator = all.Aggregator + o.DataSource = all.DataSource + o.Name = all.Name + o.Query = all.Query + return nil +} diff --git a/api/datadogV2/model_metrics_timeseries_query.go b/api/datadogV2/model_metrics_timeseries_query.go new file mode 100644 index 00000000000..41820792c60 --- /dev/null +++ b/api/datadogV2/model_metrics_timeseries_query.go @@ -0,0 +1,181 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// MetricsTimeseriesQuery An individual timeseries metrics query. +type MetricsTimeseriesQuery struct { + // A data source that is powered by the Metrics backend. + DataSource MetricsDataSource `json:"data_source"` + // The variable name for use in formulas. + Name *string `json:"name,omitempty"` + // A classic metrics query string. + Query string `json:"query"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewMetricsTimeseriesQuery instantiates a new MetricsTimeseriesQuery object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewMetricsTimeseriesQuery(dataSource MetricsDataSource, query string) *MetricsTimeseriesQuery { + this := MetricsTimeseriesQuery{} + this.DataSource = dataSource + this.Query = query + return &this +} + +// NewMetricsTimeseriesQueryWithDefaults instantiates a new MetricsTimeseriesQuery object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewMetricsTimeseriesQueryWithDefaults() *MetricsTimeseriesQuery { + this := MetricsTimeseriesQuery{} + var dataSource MetricsDataSource = METRICSDATASOURCE_METRICS + this.DataSource = dataSource + return &this +} + +// GetDataSource returns the DataSource field value. +func (o *MetricsTimeseriesQuery) GetDataSource() MetricsDataSource { + if o == nil { + var ret MetricsDataSource + return ret + } + return o.DataSource +} + +// GetDataSourceOk returns a tuple with the DataSource field value +// and a boolean to check if the value has been set. +func (o *MetricsTimeseriesQuery) GetDataSourceOk() (*MetricsDataSource, bool) { + if o == nil { + return nil, false + } + return &o.DataSource, true +} + +// SetDataSource sets field value. +func (o *MetricsTimeseriesQuery) SetDataSource(v MetricsDataSource) { + o.DataSource = v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *MetricsTimeseriesQuery) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MetricsTimeseriesQuery) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *MetricsTimeseriesQuery) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *MetricsTimeseriesQuery) SetName(v string) { + o.Name = &v +} + +// GetQuery returns the Query field value. +func (o *MetricsTimeseriesQuery) GetQuery() string { + if o == nil { + var ret string + return ret + } + return o.Query +} + +// GetQueryOk returns a tuple with the Query field value +// and a boolean to check if the value has been set. +func (o *MetricsTimeseriesQuery) GetQueryOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Query, true +} + +// SetQuery sets field value. +func (o *MetricsTimeseriesQuery) SetQuery(v string) { + o.Query = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MetricsTimeseriesQuery) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["data_source"] = o.DataSource + if o.Name != nil { + toSerialize["name"] = o.Name + } + toSerialize["query"] = o.Query + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MetricsTimeseriesQuery) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + DataSource *MetricsDataSource `json:"data_source"` + Query *string `json:"query"` + }{} + all := struct { + DataSource MetricsDataSource `json:"data_source"` + Name *string `json:"name,omitempty"` + Query string `json:"query"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.DataSource == nil { + return fmt.Errorf("required field data_source missing") + } + if required.Query == nil { + return fmt.Errorf("required field query missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.DataSource; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.DataSource = all.DataSource + o.Name = all.Name + o.Query = all.Query + return nil +} diff --git a/api/datadogV2/model_query_formula.go b/api/datadogV2/model_query_formula.go new file mode 100644 index 00000000000..76e53e11055 --- /dev/null +++ b/api/datadogV2/model_query_formula.go @@ -0,0 +1,145 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// QueryFormula A formula for calculation based on one or more queries. +type QueryFormula struct { + // Formula string, referencing one or more queries with their name property. + Formula string `json:"formula"` + // Message for specifying limits to the number of values returned by a query. + Limit *FormulaLimit `json:"limit,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewQueryFormula instantiates a new QueryFormula object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewQueryFormula(formula string) *QueryFormula { + this := QueryFormula{} + this.Formula = formula + return &this +} + +// NewQueryFormulaWithDefaults instantiates a new QueryFormula object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewQueryFormulaWithDefaults() *QueryFormula { + this := QueryFormula{} + return &this +} + +// GetFormula returns the Formula field value. +func (o *QueryFormula) GetFormula() string { + if o == nil { + var ret string + return ret + } + return o.Formula +} + +// GetFormulaOk returns a tuple with the Formula field value +// and a boolean to check if the value has been set. +func (o *QueryFormula) GetFormulaOk() (*string, bool) { + if o == nil { + return nil, false + } + return &o.Formula, true +} + +// SetFormula sets field value. +func (o *QueryFormula) SetFormula(v string) { + o.Formula = v +} + +// GetLimit returns the Limit field value if set, zero value otherwise. +func (o *QueryFormula) GetLimit() FormulaLimit { + if o == nil || o.Limit == nil { + var ret FormulaLimit + return ret + } + return *o.Limit +} + +// GetLimitOk returns a tuple with the Limit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *QueryFormula) GetLimitOk() (*FormulaLimit, bool) { + if o == nil || o.Limit == nil { + return nil, false + } + return o.Limit, true +} + +// HasLimit returns a boolean if a field has been set. +func (o *QueryFormula) HasLimit() bool { + return o != nil && o.Limit != nil +} + +// SetLimit gets a reference to the given FormulaLimit and assigns it to the Limit field. +func (o *QueryFormula) SetLimit(v FormulaLimit) { + o.Limit = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o QueryFormula) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["formula"] = o.Formula + if o.Limit != nil { + toSerialize["limit"] = o.Limit + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *QueryFormula) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Formula *string `json:"formula"` + }{} + all := struct { + Formula string `json:"formula"` + Limit *FormulaLimit `json:"limit,omitempty"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Formula == nil { + return fmt.Errorf("required field formula missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Formula = all.Formula + if all.Limit != nil && all.Limit.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Limit = all.Limit + return nil +} diff --git a/api/datadogV2/model_scalar_column.go b/api/datadogV2/model_scalar_column.go new file mode 100644 index 00000000000..97ab7424c46 --- /dev/null +++ b/api/datadogV2/model_scalar_column.go @@ -0,0 +1,133 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// ScalarColumn A single column in a scalar query response. +type ScalarColumn struct { + // List of units. + Unit []Unit `json:"unit,omitempty"` + // Array of values for each group-by combination that results from one formula or query. + Values []float64 `json:"values,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewScalarColumn instantiates a new ScalarColumn object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewScalarColumn() *ScalarColumn { + this := ScalarColumn{} + return &this +} + +// NewScalarColumnWithDefaults instantiates a new ScalarColumn object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewScalarColumnWithDefaults() *ScalarColumn { + this := ScalarColumn{} + return &this +} + +// GetUnit returns the Unit field value if set, zero value otherwise. +func (o *ScalarColumn) GetUnit() []Unit { + if o == nil || o.Unit == nil { + var ret []Unit + return ret + } + return o.Unit +} + +// GetUnitOk returns a tuple with the Unit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ScalarColumn) GetUnitOk() (*[]Unit, bool) { + if o == nil || o.Unit == nil { + return nil, false + } + return &o.Unit, true +} + +// HasUnit returns a boolean if a field has been set. +func (o *ScalarColumn) HasUnit() bool { + return o != nil && o.Unit != nil +} + +// SetUnit gets a reference to the given []Unit and assigns it to the Unit field. +func (o *ScalarColumn) SetUnit(v []Unit) { + o.Unit = v +} + +// GetValues returns the Values field value if set, zero value otherwise. +func (o *ScalarColumn) GetValues() []float64 { + if o == nil || o.Values == nil { + var ret []float64 + return ret + } + return o.Values +} + +// GetValuesOk returns a tuple with the Values field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ScalarColumn) GetValuesOk() (*[]float64, bool) { + if o == nil || o.Values == nil { + return nil, false + } + return &o.Values, true +} + +// HasValues returns a boolean if a field has been set. +func (o *ScalarColumn) HasValues() bool { + return o != nil && o.Values != nil +} + +// SetValues gets a reference to the given []float64 and assigns it to the Values field. +func (o *ScalarColumn) SetValues(v []float64) { + o.Values = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ScalarColumn) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Unit != nil { + toSerialize["unit"] = o.Unit + } + if o.Values != nil { + toSerialize["values"] = o.Values + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ScalarColumn) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Unit []Unit `json:"unit,omitempty"` + Values []float64 `json:"values,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Unit = all.Unit + o.Values = all.Values + return nil +} diff --git a/api/datadogV2/model_scalar_formula_query_request.go b/api/datadogV2/model_scalar_formula_query_request.go new file mode 100644 index 00000000000..b5c0a52d678 --- /dev/null +++ b/api/datadogV2/model_scalar_formula_query_request.go @@ -0,0 +1,110 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// ScalarFormulaQueryRequest A wrapper request around one scalar query to be executed. +type ScalarFormulaQueryRequest struct { + // A single scalar query to be executed. + Data ScalarFormulaRequest `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewScalarFormulaQueryRequest instantiates a new ScalarFormulaQueryRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewScalarFormulaQueryRequest(data ScalarFormulaRequest) *ScalarFormulaQueryRequest { + this := ScalarFormulaQueryRequest{} + this.Data = data + return &this +} + +// NewScalarFormulaQueryRequestWithDefaults instantiates a new ScalarFormulaQueryRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewScalarFormulaQueryRequestWithDefaults() *ScalarFormulaQueryRequest { + this := ScalarFormulaQueryRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *ScalarFormulaQueryRequest) GetData() ScalarFormulaRequest { + if o == nil { + var ret ScalarFormulaRequest + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *ScalarFormulaQueryRequest) GetDataOk() (*ScalarFormulaRequest, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *ScalarFormulaQueryRequest) SetData(v ScalarFormulaRequest) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ScalarFormulaQueryRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ScalarFormulaQueryRequest) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Data *ScalarFormulaRequest `json:"data"` + }{} + all := struct { + Data ScalarFormulaRequest `json:"data"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Data == nil { + return fmt.Errorf("required field data missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + return nil +} diff --git a/api/datadogV2/model_scalar_formula_query_response.go b/api/datadogV2/model_scalar_formula_query_response.go new file mode 100644 index 00000000000..0e94492c309 --- /dev/null +++ b/api/datadogV2/model_scalar_formula_query_response.go @@ -0,0 +1,140 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// ScalarFormulaQueryResponse A message containing one or more responses to scalar queries. +type ScalarFormulaQueryResponse struct { + // A message containing the response to a scalar query. + Data *ScalarResponse `json:"data,omitempty"` + // An error generated when processing a request. + Errors *string `json:"errors,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewScalarFormulaQueryResponse instantiates a new ScalarFormulaQueryResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewScalarFormulaQueryResponse() *ScalarFormulaQueryResponse { + this := ScalarFormulaQueryResponse{} + return &this +} + +// NewScalarFormulaQueryResponseWithDefaults instantiates a new ScalarFormulaQueryResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewScalarFormulaQueryResponseWithDefaults() *ScalarFormulaQueryResponse { + this := ScalarFormulaQueryResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *ScalarFormulaQueryResponse) GetData() ScalarResponse { + if o == nil || o.Data == nil { + var ret ScalarResponse + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ScalarFormulaQueryResponse) GetDataOk() (*ScalarResponse, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *ScalarFormulaQueryResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given ScalarResponse and assigns it to the Data field. +func (o *ScalarFormulaQueryResponse) SetData(v ScalarResponse) { + o.Data = &v +} + +// GetErrors returns the Errors field value if set, zero value otherwise. +func (o *ScalarFormulaQueryResponse) GetErrors() string { + if o == nil || o.Errors == nil { + var ret string + return ret + } + return *o.Errors +} + +// GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ScalarFormulaQueryResponse) GetErrorsOk() (*string, bool) { + if o == nil || o.Errors == nil { + return nil, false + } + return o.Errors, true +} + +// HasErrors returns a boolean if a field has been set. +func (o *ScalarFormulaQueryResponse) HasErrors() bool { + return o != nil && o.Errors != nil +} + +// SetErrors gets a reference to the given string and assigns it to the Errors field. +func (o *ScalarFormulaQueryResponse) SetErrors(v string) { + o.Errors = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ScalarFormulaQueryResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + if o.Errors != nil { + toSerialize["errors"] = o.Errors + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ScalarFormulaQueryResponse) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Data *ScalarResponse `json:"data,omitempty"` + Errors *string `json:"errors,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + o.Errors = all.Errors + return nil +} diff --git a/api/datadogV2/model_scalar_formula_request.go b/api/datadogV2/model_scalar_formula_request.go new file mode 100644 index 00000000000..23cc98b4bc0 --- /dev/null +++ b/api/datadogV2/model_scalar_formula_request.go @@ -0,0 +1,153 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// ScalarFormulaRequest A single scalar query to be executed. +type ScalarFormulaRequest struct { + // The object describing a scalar formula request. + Attributes ScalarFormulaRequestAttributes `json:"attributes"` + // The type of the resource. The value should always be scalar_request. + Type ScalarFormulaRequestType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewScalarFormulaRequest instantiates a new ScalarFormulaRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewScalarFormulaRequest(attributes ScalarFormulaRequestAttributes, typeVar ScalarFormulaRequestType) *ScalarFormulaRequest { + this := ScalarFormulaRequest{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewScalarFormulaRequestWithDefaults instantiates a new ScalarFormulaRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewScalarFormulaRequestWithDefaults() *ScalarFormulaRequest { + this := ScalarFormulaRequest{} + var typeVar ScalarFormulaRequestType = SCALARFORMULAREQUESTTYPE_SCALAR_REQUEST + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *ScalarFormulaRequest) GetAttributes() ScalarFormulaRequestAttributes { + if o == nil { + var ret ScalarFormulaRequestAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *ScalarFormulaRequest) GetAttributesOk() (*ScalarFormulaRequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *ScalarFormulaRequest) SetAttributes(v ScalarFormulaRequestAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *ScalarFormulaRequest) GetType() ScalarFormulaRequestType { + if o == nil { + var ret ScalarFormulaRequestType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *ScalarFormulaRequest) GetTypeOk() (*ScalarFormulaRequestType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *ScalarFormulaRequest) SetType(v ScalarFormulaRequestType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ScalarFormulaRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ScalarFormulaRequest) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Attributes *ScalarFormulaRequestAttributes `json:"attributes"` + Type *ScalarFormulaRequestType `json:"type"` + }{} + all := struct { + Attributes ScalarFormulaRequestAttributes `json:"attributes"` + Type ScalarFormulaRequestType `json:"type"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if required.Type == nil { + return fmt.Errorf("required field type missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Type; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Type = all.Type + return nil +} diff --git a/api/datadogV2/model_scalar_formula_request_attributes.go b/api/datadogV2/model_scalar_formula_request_attributes.go new file mode 100644 index 00000000000..420e32d1ad6 --- /dev/null +++ b/api/datadogV2/model_scalar_formula_request_attributes.go @@ -0,0 +1,204 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// ScalarFormulaRequestAttributes The object describing a scalar formula request. +type ScalarFormulaRequestAttributes struct { + // List of formulas to be calculated and returned as responses. + Formulas []QueryFormula `json:"formulas,omitempty"` + // Start date (inclusive) of the query in milliseconds since the Unix epoch. + From int64 `json:"from"` + // List of queries to be run and used as inputs to the formulas. + Queries []ScalarQuery `json:"queries"` + // End date (exclusive) of the query in milliseconds since the Unix epoch. + To int64 `json:"to"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewScalarFormulaRequestAttributes instantiates a new ScalarFormulaRequestAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewScalarFormulaRequestAttributes(from int64, queries []ScalarQuery, to int64) *ScalarFormulaRequestAttributes { + this := ScalarFormulaRequestAttributes{} + this.From = from + this.Queries = queries + this.To = to + return &this +} + +// NewScalarFormulaRequestAttributesWithDefaults instantiates a new ScalarFormulaRequestAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewScalarFormulaRequestAttributesWithDefaults() *ScalarFormulaRequestAttributes { + this := ScalarFormulaRequestAttributes{} + return &this +} + +// GetFormulas returns the Formulas field value if set, zero value otherwise. +func (o *ScalarFormulaRequestAttributes) GetFormulas() []QueryFormula { + if o == nil || o.Formulas == nil { + var ret []QueryFormula + return ret + } + return o.Formulas +} + +// GetFormulasOk returns a tuple with the Formulas field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ScalarFormulaRequestAttributes) GetFormulasOk() (*[]QueryFormula, bool) { + if o == nil || o.Formulas == nil { + return nil, false + } + return &o.Formulas, true +} + +// HasFormulas returns a boolean if a field has been set. +func (o *ScalarFormulaRequestAttributes) HasFormulas() bool { + return o != nil && o.Formulas != nil +} + +// SetFormulas gets a reference to the given []QueryFormula and assigns it to the Formulas field. +func (o *ScalarFormulaRequestAttributes) SetFormulas(v []QueryFormula) { + o.Formulas = v +} + +// GetFrom returns the From field value. +func (o *ScalarFormulaRequestAttributes) GetFrom() int64 { + if o == nil { + var ret int64 + return ret + } + return o.From +} + +// GetFromOk returns a tuple with the From field value +// and a boolean to check if the value has been set. +func (o *ScalarFormulaRequestAttributes) GetFromOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.From, true +} + +// SetFrom sets field value. +func (o *ScalarFormulaRequestAttributes) SetFrom(v int64) { + o.From = v +} + +// GetQueries returns the Queries field value. +func (o *ScalarFormulaRequestAttributes) GetQueries() []ScalarQuery { + if o == nil { + var ret []ScalarQuery + return ret + } + return o.Queries +} + +// GetQueriesOk returns a tuple with the Queries field value +// and a boolean to check if the value has been set. +func (o *ScalarFormulaRequestAttributes) GetQueriesOk() (*[]ScalarQuery, bool) { + if o == nil { + return nil, false + } + return &o.Queries, true +} + +// SetQueries sets field value. +func (o *ScalarFormulaRequestAttributes) SetQueries(v []ScalarQuery) { + o.Queries = v +} + +// GetTo returns the To field value. +func (o *ScalarFormulaRequestAttributes) GetTo() int64 { + if o == nil { + var ret int64 + return ret + } + return o.To +} + +// GetToOk returns a tuple with the To field value +// and a boolean to check if the value has been set. +func (o *ScalarFormulaRequestAttributes) GetToOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.To, true +} + +// SetTo sets field value. +func (o *ScalarFormulaRequestAttributes) SetTo(v int64) { + o.To = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ScalarFormulaRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Formulas != nil { + toSerialize["formulas"] = o.Formulas + } + toSerialize["from"] = o.From + toSerialize["queries"] = o.Queries + toSerialize["to"] = o.To + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ScalarFormulaRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + From *int64 `json:"from"` + Queries *[]ScalarQuery `json:"queries"` + To *int64 `json:"to"` + }{} + all := struct { + Formulas []QueryFormula `json:"formulas,omitempty"` + From int64 `json:"from"` + Queries []ScalarQuery `json:"queries"` + To int64 `json:"to"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.From == nil { + return fmt.Errorf("required field from missing") + } + if required.Queries == nil { + return fmt.Errorf("required field queries missing") + } + if required.To == nil { + return fmt.Errorf("required field to missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Formulas = all.Formulas + o.From = all.From + o.Queries = all.Queries + o.To = all.To + return nil +} diff --git a/api/datadogV2/model_scalar_formula_request_type.go b/api/datadogV2/model_scalar_formula_request_type.go new file mode 100644 index 00000000000..21233c6fe2b --- /dev/null +++ b/api/datadogV2/model_scalar_formula_request_type.go @@ -0,0 +1,107 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// ScalarFormulaRequestType The type of the resource. The value should always be scalar_request. +type ScalarFormulaRequestType string + +// List of ScalarFormulaRequestType. +const ( + SCALARFORMULAREQUESTTYPE_SCALAR_REQUEST ScalarFormulaRequestType = "scalar_request" +) + +var allowedScalarFormulaRequestTypeEnumValues = []ScalarFormulaRequestType{ + SCALARFORMULAREQUESTTYPE_SCALAR_REQUEST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ScalarFormulaRequestType) GetAllowedValues() []ScalarFormulaRequestType { + return allowedScalarFormulaRequestTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ScalarFormulaRequestType) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ScalarFormulaRequestType(value) + return nil +} + +// NewScalarFormulaRequestTypeFromValue returns a pointer to a valid ScalarFormulaRequestType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewScalarFormulaRequestTypeFromValue(v string) (*ScalarFormulaRequestType, error) { + ev := ScalarFormulaRequestType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ScalarFormulaRequestType: valid values are %v", v, allowedScalarFormulaRequestTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ScalarFormulaRequestType) IsValid() bool { + for _, existing := range allowedScalarFormulaRequestTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ScalarFormulaRequestType value. +func (v ScalarFormulaRequestType) Ptr() *ScalarFormulaRequestType { + return &v +} + +// NullableScalarFormulaRequestType handles when a null is used for ScalarFormulaRequestType. +type NullableScalarFormulaRequestType struct { + value *ScalarFormulaRequestType + isSet bool +} + +// Get returns the associated value. +func (v NullableScalarFormulaRequestType) Get() *ScalarFormulaRequestType { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableScalarFormulaRequestType) Set(val *ScalarFormulaRequestType) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableScalarFormulaRequestType) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag. +func (v *NullableScalarFormulaRequestType) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableScalarFormulaRequestType initializes the struct as if Set has been called. +func NewNullableScalarFormulaRequestType(val *ScalarFormulaRequestType) *NullableScalarFormulaRequestType { + return &NullableScalarFormulaRequestType{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableScalarFormulaRequestType) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableScalarFormulaRequestType) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_scalar_formula_response_atrributes.go b/api/datadogV2/model_scalar_formula_response_atrributes.go new file mode 100644 index 00000000000..6c0555c8b2c --- /dev/null +++ b/api/datadogV2/model_scalar_formula_response_atrributes.go @@ -0,0 +1,133 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// ScalarFormulaResponseAtrributes The object describing a scalar response. +type ScalarFormulaResponseAtrributes struct { + // List of response columns, each corresponding to an individual formula or query in the request and with values in parallel arrays matching the series list. + Columns []ScalarColumn `json:"columns,omitempty"` + // List of group-by tags for the response. Parallel array to the values in each scalar column. + Series [][]string `json:"series,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewScalarFormulaResponseAtrributes instantiates a new ScalarFormulaResponseAtrributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewScalarFormulaResponseAtrributes() *ScalarFormulaResponseAtrributes { + this := ScalarFormulaResponseAtrributes{} + return &this +} + +// NewScalarFormulaResponseAtrributesWithDefaults instantiates a new ScalarFormulaResponseAtrributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewScalarFormulaResponseAtrributesWithDefaults() *ScalarFormulaResponseAtrributes { + this := ScalarFormulaResponseAtrributes{} + return &this +} + +// GetColumns returns the Columns field value if set, zero value otherwise. +func (o *ScalarFormulaResponseAtrributes) GetColumns() []ScalarColumn { + if o == nil || o.Columns == nil { + var ret []ScalarColumn + return ret + } + return o.Columns +} + +// GetColumnsOk returns a tuple with the Columns field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ScalarFormulaResponseAtrributes) GetColumnsOk() (*[]ScalarColumn, bool) { + if o == nil || o.Columns == nil { + return nil, false + } + return &o.Columns, true +} + +// HasColumns returns a boolean if a field has been set. +func (o *ScalarFormulaResponseAtrributes) HasColumns() bool { + return o != nil && o.Columns != nil +} + +// SetColumns gets a reference to the given []ScalarColumn and assigns it to the Columns field. +func (o *ScalarFormulaResponseAtrributes) SetColumns(v []ScalarColumn) { + o.Columns = v +} + +// GetSeries returns the Series field value if set, zero value otherwise. +func (o *ScalarFormulaResponseAtrributes) GetSeries() [][]string { + if o == nil || o.Series == nil { + var ret [][]string + return ret + } + return o.Series +} + +// GetSeriesOk returns a tuple with the Series field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ScalarFormulaResponseAtrributes) GetSeriesOk() (*[][]string, bool) { + if o == nil || o.Series == nil { + return nil, false + } + return &o.Series, true +} + +// HasSeries returns a boolean if a field has been set. +func (o *ScalarFormulaResponseAtrributes) HasSeries() bool { + return o != nil && o.Series != nil +} + +// SetSeries gets a reference to the given [][]string and assigns it to the Series field. +func (o *ScalarFormulaResponseAtrributes) SetSeries(v [][]string) { + o.Series = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ScalarFormulaResponseAtrributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Columns != nil { + toSerialize["columns"] = o.Columns + } + if o.Series != nil { + toSerialize["series"] = o.Series + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ScalarFormulaResponseAtrributes) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Columns []ScalarColumn `json:"columns,omitempty"` + Series [][]string `json:"series,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Columns = all.Columns + o.Series = all.Series + return nil +} diff --git a/api/datadogV2/model_scalar_formula_response_type.go b/api/datadogV2/model_scalar_formula_response_type.go new file mode 100644 index 00000000000..60731c2acb6 --- /dev/null +++ b/api/datadogV2/model_scalar_formula_response_type.go @@ -0,0 +1,107 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// ScalarFormulaResponseType The type of the resource. The value should always be scalar_response. +type ScalarFormulaResponseType string + +// List of ScalarFormulaResponseType. +const ( + SCALARFORMULARESPONSETYPE_SCALAR_RESPONSE ScalarFormulaResponseType = "scalar_response" +) + +var allowedScalarFormulaResponseTypeEnumValues = []ScalarFormulaResponseType{ + SCALARFORMULARESPONSETYPE_SCALAR_RESPONSE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *ScalarFormulaResponseType) GetAllowedValues() []ScalarFormulaResponseType { + return allowedScalarFormulaResponseTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *ScalarFormulaResponseType) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = ScalarFormulaResponseType(value) + return nil +} + +// NewScalarFormulaResponseTypeFromValue returns a pointer to a valid ScalarFormulaResponseType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewScalarFormulaResponseTypeFromValue(v string) (*ScalarFormulaResponseType, error) { + ev := ScalarFormulaResponseType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for ScalarFormulaResponseType: valid values are %v", v, allowedScalarFormulaResponseTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v ScalarFormulaResponseType) IsValid() bool { + for _, existing := range allowedScalarFormulaResponseTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to ScalarFormulaResponseType value. +func (v ScalarFormulaResponseType) Ptr() *ScalarFormulaResponseType { + return &v +} + +// NullableScalarFormulaResponseType handles when a null is used for ScalarFormulaResponseType. +type NullableScalarFormulaResponseType struct { + value *ScalarFormulaResponseType + isSet bool +} + +// Get returns the associated value. +func (v NullableScalarFormulaResponseType) Get() *ScalarFormulaResponseType { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableScalarFormulaResponseType) Set(val *ScalarFormulaResponseType) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableScalarFormulaResponseType) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag. +func (v *NullableScalarFormulaResponseType) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableScalarFormulaResponseType initializes the struct as if Set has been called. +func NewNullableScalarFormulaResponseType(val *ScalarFormulaResponseType) *NullableScalarFormulaResponseType { + return &NullableScalarFormulaResponseType{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableScalarFormulaResponseType) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableScalarFormulaResponseType) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_scalar_query.go b/api/datadogV2/model_scalar_query.go new file mode 100644 index 00000000000..cace600c1ea --- /dev/null +++ b/api/datadogV2/model_scalar_query.go @@ -0,0 +1,155 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// ScalarQuery - An individual scalar query to one of the basic Datadog data sources. +type ScalarQuery struct { + MetricsScalarQuery *MetricsScalarQuery + EventsScalarQuery *EventsScalarQuery + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// MetricsScalarQueryAsScalarQuery is a convenience function that returns MetricsScalarQuery wrapped in ScalarQuery. +func MetricsScalarQueryAsScalarQuery(v *MetricsScalarQuery) ScalarQuery { + return ScalarQuery{MetricsScalarQuery: v} +} + +// EventsScalarQueryAsScalarQuery is a convenience function that returns EventsScalarQuery wrapped in ScalarQuery. +func EventsScalarQueryAsScalarQuery(v *EventsScalarQuery) ScalarQuery { + return ScalarQuery{EventsScalarQuery: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *ScalarQuery) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into MetricsScalarQuery + err = json.Unmarshal(data, &obj.MetricsScalarQuery) + if err == nil { + if obj.MetricsScalarQuery != nil && obj.MetricsScalarQuery.UnparsedObject == nil { + jsonMetricsScalarQuery, _ := json.Marshal(obj.MetricsScalarQuery) + if string(jsonMetricsScalarQuery) == "{}" { // empty struct + obj.MetricsScalarQuery = nil + } else { + match++ + } + } else { + obj.MetricsScalarQuery = nil + } + } else { + obj.MetricsScalarQuery = nil + } + + // try to unmarshal data into EventsScalarQuery + err = json.Unmarshal(data, &obj.EventsScalarQuery) + if err == nil { + if obj.EventsScalarQuery != nil && obj.EventsScalarQuery.UnparsedObject == nil { + jsonEventsScalarQuery, _ := json.Marshal(obj.EventsScalarQuery) + if string(jsonEventsScalarQuery) == "{}" { // empty struct + obj.EventsScalarQuery = nil + } else { + match++ + } + } else { + obj.EventsScalarQuery = nil + } + } else { + obj.EventsScalarQuery = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.MetricsScalarQuery = nil + obj.EventsScalarQuery = nil + return json.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj ScalarQuery) MarshalJSON() ([]byte, error) { + if obj.MetricsScalarQuery != nil { + return json.Marshal(&obj.MetricsScalarQuery) + } + + if obj.EventsScalarQuery != nil { + return json.Marshal(&obj.EventsScalarQuery) + } + + if obj.UnparsedObject != nil { + return json.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *ScalarQuery) GetActualInstance() interface{} { + if obj.MetricsScalarQuery != nil { + return obj.MetricsScalarQuery + } + + if obj.EventsScalarQuery != nil { + return obj.EventsScalarQuery + } + + // all schemas are nil + return nil +} + +// NullableScalarQuery handles when a null is used for ScalarQuery. +type NullableScalarQuery struct { + value *ScalarQuery + isSet bool +} + +// Get returns the associated value. +func (v NullableScalarQuery) Get() *ScalarQuery { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableScalarQuery) Set(val *ScalarQuery) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableScalarQuery) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag/ +func (v *NullableScalarQuery) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableScalarQuery initializes the struct as if Set has been called. +func NewNullableScalarQuery(val *ScalarQuery) *NullableScalarQuery { + return &NullableScalarQuery{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableScalarQuery) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableScalarQuery) UnmarshalJSON(src []byte) error { + v.isSet = true + + // this object is nullable so check if the payload is null or empty string + if string(src) == "" || string(src) == "{}" { + return nil + } + + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_scalar_response.go b/api/datadogV2/model_scalar_response.go new file mode 100644 index 00000000000..0451d685175 --- /dev/null +++ b/api/datadogV2/model_scalar_response.go @@ -0,0 +1,152 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// ScalarResponse A message containing the response to a scalar query. +type ScalarResponse struct { + // The object describing a scalar response. + Attributes *ScalarFormulaResponseAtrributes `json:"attributes,omitempty"` + // The type of the resource. The value should always be scalar_response. + Type *ScalarFormulaResponseType `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewScalarResponse instantiates a new ScalarResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewScalarResponse() *ScalarResponse { + this := ScalarResponse{} + var typeVar ScalarFormulaResponseType = SCALARFORMULARESPONSETYPE_SCALAR_RESPONSE + this.Type = &typeVar + return &this +} + +// NewScalarResponseWithDefaults instantiates a new ScalarResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewScalarResponseWithDefaults() *ScalarResponse { + this := ScalarResponse{} + var typeVar ScalarFormulaResponseType = SCALARFORMULARESPONSETYPE_SCALAR_RESPONSE + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *ScalarResponse) GetAttributes() ScalarFormulaResponseAtrributes { + if o == nil || o.Attributes == nil { + var ret ScalarFormulaResponseAtrributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ScalarResponse) GetAttributesOk() (*ScalarFormulaResponseAtrributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *ScalarResponse) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given ScalarFormulaResponseAtrributes and assigns it to the Attributes field. +func (o *ScalarResponse) SetAttributes(v ScalarFormulaResponseAtrributes) { + o.Attributes = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *ScalarResponse) GetType() ScalarFormulaResponseType { + if o == nil || o.Type == nil { + var ret ScalarFormulaResponseType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *ScalarResponse) GetTypeOk() (*ScalarFormulaResponseType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *ScalarResponse) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given ScalarFormulaResponseType and assigns it to the Type field. +func (o *ScalarResponse) SetType(v ScalarFormulaResponseType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o ScalarResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *ScalarResponse) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Attributes *ScalarFormulaResponseAtrributes `json:"attributes,omitempty"` + Type *ScalarFormulaResponseType `json:"type,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Type; v != nil && !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Type = all.Type + return nil +} diff --git a/api/datadogV2/model_timeseries_formula_query_request.go b/api/datadogV2/model_timeseries_formula_query_request.go new file mode 100644 index 00000000000..df6a5d1aa87 --- /dev/null +++ b/api/datadogV2/model_timeseries_formula_query_request.go @@ -0,0 +1,110 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// TimeseriesFormulaQueryRequest A request wrapper around a single timeseries query to be executed. +type TimeseriesFormulaQueryRequest struct { + // A single timeseries query to be executed. + Data TimeseriesFormulaRequest `json:"data"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewTimeseriesFormulaQueryRequest instantiates a new TimeseriesFormulaQueryRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTimeseriesFormulaQueryRequest(data TimeseriesFormulaRequest) *TimeseriesFormulaQueryRequest { + this := TimeseriesFormulaQueryRequest{} + this.Data = data + return &this +} + +// NewTimeseriesFormulaQueryRequestWithDefaults instantiates a new TimeseriesFormulaQueryRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTimeseriesFormulaQueryRequestWithDefaults() *TimeseriesFormulaQueryRequest { + this := TimeseriesFormulaQueryRequest{} + return &this +} + +// GetData returns the Data field value. +func (o *TimeseriesFormulaQueryRequest) GetData() TimeseriesFormulaRequest { + if o == nil { + var ret TimeseriesFormulaRequest + return ret + } + return o.Data +} + +// GetDataOk returns a tuple with the Data field value +// and a boolean to check if the value has been set. +func (o *TimeseriesFormulaQueryRequest) GetDataOk() (*TimeseriesFormulaRequest, bool) { + if o == nil { + return nil, false + } + return &o.Data, true +} + +// SetData sets field value. +func (o *TimeseriesFormulaQueryRequest) SetData(v TimeseriesFormulaRequest) { + o.Data = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TimeseriesFormulaQueryRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["data"] = o.Data + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TimeseriesFormulaQueryRequest) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Data *TimeseriesFormulaRequest `json:"data"` + }{} + all := struct { + Data TimeseriesFormulaRequest `json:"data"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Data == nil { + return fmt.Errorf("required field data missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + return nil +} diff --git a/api/datadogV2/model_timeseries_formula_query_response.go b/api/datadogV2/model_timeseries_formula_query_response.go new file mode 100644 index 00000000000..b04e2e6c3ce --- /dev/null +++ b/api/datadogV2/model_timeseries_formula_query_response.go @@ -0,0 +1,140 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// TimeseriesFormulaQueryResponse A message containing one response to a timeseries query made with timeseries formula query request. +type TimeseriesFormulaQueryResponse struct { + // A message containing the response to a timeseries query. + Data *TimeseriesResponse `json:"data,omitempty"` + // The error generated by the request. + Errors *string `json:"errors,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewTimeseriesFormulaQueryResponse instantiates a new TimeseriesFormulaQueryResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTimeseriesFormulaQueryResponse() *TimeseriesFormulaQueryResponse { + this := TimeseriesFormulaQueryResponse{} + return &this +} + +// NewTimeseriesFormulaQueryResponseWithDefaults instantiates a new TimeseriesFormulaQueryResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTimeseriesFormulaQueryResponseWithDefaults() *TimeseriesFormulaQueryResponse { + this := TimeseriesFormulaQueryResponse{} + return &this +} + +// GetData returns the Data field value if set, zero value otherwise. +func (o *TimeseriesFormulaQueryResponse) GetData() TimeseriesResponse { + if o == nil || o.Data == nil { + var ret TimeseriesResponse + return ret + } + return *o.Data +} + +// GetDataOk returns a tuple with the Data field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TimeseriesFormulaQueryResponse) GetDataOk() (*TimeseriesResponse, bool) { + if o == nil || o.Data == nil { + return nil, false + } + return o.Data, true +} + +// HasData returns a boolean if a field has been set. +func (o *TimeseriesFormulaQueryResponse) HasData() bool { + return o != nil && o.Data != nil +} + +// SetData gets a reference to the given TimeseriesResponse and assigns it to the Data field. +func (o *TimeseriesFormulaQueryResponse) SetData(v TimeseriesResponse) { + o.Data = &v +} + +// GetErrors returns the Errors field value if set, zero value otherwise. +func (o *TimeseriesFormulaQueryResponse) GetErrors() string { + if o == nil || o.Errors == nil { + var ret string + return ret + } + return *o.Errors +} + +// GetErrorsOk returns a tuple with the Errors field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TimeseriesFormulaQueryResponse) GetErrorsOk() (*string, bool) { + if o == nil || o.Errors == nil { + return nil, false + } + return o.Errors, true +} + +// HasErrors returns a boolean if a field has been set. +func (o *TimeseriesFormulaQueryResponse) HasErrors() bool { + return o != nil && o.Errors != nil +} + +// SetErrors gets a reference to the given string and assigns it to the Errors field. +func (o *TimeseriesFormulaQueryResponse) SetErrors(v string) { + o.Errors = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TimeseriesFormulaQueryResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Data != nil { + toSerialize["data"] = o.Data + } + if o.Errors != nil { + toSerialize["errors"] = o.Errors + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TimeseriesFormulaQueryResponse) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Data *TimeseriesResponse `json:"data,omitempty"` + Errors *string `json:"errors,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Data != nil && all.Data.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Data = all.Data + o.Errors = all.Errors + return nil +} diff --git a/api/datadogV2/model_timeseries_formula_request.go b/api/datadogV2/model_timeseries_formula_request.go new file mode 100644 index 00000000000..7b087435349 --- /dev/null +++ b/api/datadogV2/model_timeseries_formula_request.go @@ -0,0 +1,153 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// TimeseriesFormulaRequest A single timeseries query to be executed. +type TimeseriesFormulaRequest struct { + // The object describing a timeseries formula request. + Attributes TimeseriesFormulaRequestAttributes `json:"attributes"` + // The type of the resource. The value should always be timeseries_request. + Type TimeseriesFormulaRequestType `json:"type"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewTimeseriesFormulaRequest instantiates a new TimeseriesFormulaRequest object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTimeseriesFormulaRequest(attributes TimeseriesFormulaRequestAttributes, typeVar TimeseriesFormulaRequestType) *TimeseriesFormulaRequest { + this := TimeseriesFormulaRequest{} + this.Attributes = attributes + this.Type = typeVar + return &this +} + +// NewTimeseriesFormulaRequestWithDefaults instantiates a new TimeseriesFormulaRequest object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTimeseriesFormulaRequestWithDefaults() *TimeseriesFormulaRequest { + this := TimeseriesFormulaRequest{} + var typeVar TimeseriesFormulaRequestType = TIMESERIESFORMULAREQUESTTYPE_TIMESERIES_REQUEST + this.Type = typeVar + return &this +} + +// GetAttributes returns the Attributes field value. +func (o *TimeseriesFormulaRequest) GetAttributes() TimeseriesFormulaRequestAttributes { + if o == nil { + var ret TimeseriesFormulaRequestAttributes + return ret + } + return o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value +// and a boolean to check if the value has been set. +func (o *TimeseriesFormulaRequest) GetAttributesOk() (*TimeseriesFormulaRequestAttributes, bool) { + if o == nil { + return nil, false + } + return &o.Attributes, true +} + +// SetAttributes sets field value. +func (o *TimeseriesFormulaRequest) SetAttributes(v TimeseriesFormulaRequestAttributes) { + o.Attributes = v +} + +// GetType returns the Type field value. +func (o *TimeseriesFormulaRequest) GetType() TimeseriesFormulaRequestType { + if o == nil { + var ret TimeseriesFormulaRequestType + return ret + } + return o.Type +} + +// GetTypeOk returns a tuple with the Type field value +// and a boolean to check if the value has been set. +func (o *TimeseriesFormulaRequest) GetTypeOk() (*TimeseriesFormulaRequestType, bool) { + if o == nil { + return nil, false + } + return &o.Type, true +} + +// SetType sets field value. +func (o *TimeseriesFormulaRequest) SetType(v TimeseriesFormulaRequestType) { + o.Type = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TimeseriesFormulaRequest) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + toSerialize["attributes"] = o.Attributes + toSerialize["type"] = o.Type + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TimeseriesFormulaRequest) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + Attributes *TimeseriesFormulaRequestAttributes `json:"attributes"` + Type *TimeseriesFormulaRequestType `json:"type"` + }{} + all := struct { + Attributes TimeseriesFormulaRequestAttributes `json:"attributes"` + Type TimeseriesFormulaRequestType `json:"type"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.Attributes == nil { + return fmt.Errorf("required field attributes missing") + } + if required.Type == nil { + return fmt.Errorf("required field type missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Type; !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Type = all.Type + return nil +} diff --git a/api/datadogV2/model_timeseries_formula_request_attributes.go b/api/datadogV2/model_timeseries_formula_request_attributes.go new file mode 100644 index 00000000000..c6a0c62f264 --- /dev/null +++ b/api/datadogV2/model_timeseries_formula_request_attributes.go @@ -0,0 +1,242 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// TimeseriesFormulaRequestAttributes The object describing a timeseries formula request. +type TimeseriesFormulaRequestAttributes struct { + // List of formulas to be calculated and returned as responses. + Formulas []QueryFormula `json:"formulas,omitempty"` + // Start date (inclusive) of the query in milliseconds since the Unix epoch. + From int64 `json:"from"` + // A time interval in milliseconds. + // May be overridden by a larger interval if the query would result in + // too many points for the specified timeframe. + // Defaults to a reasonable interval for the given timeframe. + Interval *int64 `json:"interval,omitempty"` + // List of queries to be run and used as inputs to the formulas. + Queries []TimeseriesQuery `json:"queries"` + // End date (exclusive) of the query in milliseconds since the Unix epoch. + To int64 `json:"to"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewTimeseriesFormulaRequestAttributes instantiates a new TimeseriesFormulaRequestAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTimeseriesFormulaRequestAttributes(from int64, queries []TimeseriesQuery, to int64) *TimeseriesFormulaRequestAttributes { + this := TimeseriesFormulaRequestAttributes{} + this.From = from + this.Queries = queries + this.To = to + return &this +} + +// NewTimeseriesFormulaRequestAttributesWithDefaults instantiates a new TimeseriesFormulaRequestAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTimeseriesFormulaRequestAttributesWithDefaults() *TimeseriesFormulaRequestAttributes { + this := TimeseriesFormulaRequestAttributes{} + return &this +} + +// GetFormulas returns the Formulas field value if set, zero value otherwise. +func (o *TimeseriesFormulaRequestAttributes) GetFormulas() []QueryFormula { + if o == nil || o.Formulas == nil { + var ret []QueryFormula + return ret + } + return o.Formulas +} + +// GetFormulasOk returns a tuple with the Formulas field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TimeseriesFormulaRequestAttributes) GetFormulasOk() (*[]QueryFormula, bool) { + if o == nil || o.Formulas == nil { + return nil, false + } + return &o.Formulas, true +} + +// HasFormulas returns a boolean if a field has been set. +func (o *TimeseriesFormulaRequestAttributes) HasFormulas() bool { + return o != nil && o.Formulas != nil +} + +// SetFormulas gets a reference to the given []QueryFormula and assigns it to the Formulas field. +func (o *TimeseriesFormulaRequestAttributes) SetFormulas(v []QueryFormula) { + o.Formulas = v +} + +// GetFrom returns the From field value. +func (o *TimeseriesFormulaRequestAttributes) GetFrom() int64 { + if o == nil { + var ret int64 + return ret + } + return o.From +} + +// GetFromOk returns a tuple with the From field value +// and a boolean to check if the value has been set. +func (o *TimeseriesFormulaRequestAttributes) GetFromOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.From, true +} + +// SetFrom sets field value. +func (o *TimeseriesFormulaRequestAttributes) SetFrom(v int64) { + o.From = v +} + +// GetInterval returns the Interval field value if set, zero value otherwise. +func (o *TimeseriesFormulaRequestAttributes) GetInterval() int64 { + if o == nil || o.Interval == nil { + var ret int64 + return ret + } + return *o.Interval +} + +// GetIntervalOk returns a tuple with the Interval field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TimeseriesFormulaRequestAttributes) GetIntervalOk() (*int64, bool) { + if o == nil || o.Interval == nil { + return nil, false + } + return o.Interval, true +} + +// HasInterval returns a boolean if a field has been set. +func (o *TimeseriesFormulaRequestAttributes) HasInterval() bool { + return o != nil && o.Interval != nil +} + +// SetInterval gets a reference to the given int64 and assigns it to the Interval field. +func (o *TimeseriesFormulaRequestAttributes) SetInterval(v int64) { + o.Interval = &v +} + +// GetQueries returns the Queries field value. +func (o *TimeseriesFormulaRequestAttributes) GetQueries() []TimeseriesQuery { + if o == nil { + var ret []TimeseriesQuery + return ret + } + return o.Queries +} + +// GetQueriesOk returns a tuple with the Queries field value +// and a boolean to check if the value has been set. +func (o *TimeseriesFormulaRequestAttributes) GetQueriesOk() (*[]TimeseriesQuery, bool) { + if o == nil { + return nil, false + } + return &o.Queries, true +} + +// SetQueries sets field value. +func (o *TimeseriesFormulaRequestAttributes) SetQueries(v []TimeseriesQuery) { + o.Queries = v +} + +// GetTo returns the To field value. +func (o *TimeseriesFormulaRequestAttributes) GetTo() int64 { + if o == nil { + var ret int64 + return ret + } + return o.To +} + +// GetToOk returns a tuple with the To field value +// and a boolean to check if the value has been set. +func (o *TimeseriesFormulaRequestAttributes) GetToOk() (*int64, bool) { + if o == nil { + return nil, false + } + return &o.To, true +} + +// SetTo sets field value. +func (o *TimeseriesFormulaRequestAttributes) SetTo(v int64) { + o.To = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TimeseriesFormulaRequestAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Formulas != nil { + toSerialize["formulas"] = o.Formulas + } + toSerialize["from"] = o.From + if o.Interval != nil { + toSerialize["interval"] = o.Interval + } + toSerialize["queries"] = o.Queries + toSerialize["to"] = o.To + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TimeseriesFormulaRequestAttributes) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + required := struct { + From *int64 `json:"from"` + Queries *[]TimeseriesQuery `json:"queries"` + To *int64 `json:"to"` + }{} + all := struct { + Formulas []QueryFormula `json:"formulas,omitempty"` + From int64 `json:"from"` + Interval *int64 `json:"interval,omitempty"` + Queries []TimeseriesQuery `json:"queries"` + To int64 `json:"to"` + }{} + err = json.Unmarshal(bytes, &required) + if err != nil { + return err + } + if required.From == nil { + return fmt.Errorf("required field from missing") + } + if required.Queries == nil { + return fmt.Errorf("required field queries missing") + } + if required.To == nil { + return fmt.Errorf("required field to missing") + } + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Formulas = all.Formulas + o.From = all.From + o.Interval = all.Interval + o.Queries = all.Queries + o.To = all.To + return nil +} diff --git a/api/datadogV2/model_timeseries_formula_request_type.go b/api/datadogV2/model_timeseries_formula_request_type.go new file mode 100644 index 00000000000..239172cdfdc --- /dev/null +++ b/api/datadogV2/model_timeseries_formula_request_type.go @@ -0,0 +1,107 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// TimeseriesFormulaRequestType The type of the resource. The value should always be timeseries_request. +type TimeseriesFormulaRequestType string + +// List of TimeseriesFormulaRequestType. +const ( + TIMESERIESFORMULAREQUESTTYPE_TIMESERIES_REQUEST TimeseriesFormulaRequestType = "timeseries_request" +) + +var allowedTimeseriesFormulaRequestTypeEnumValues = []TimeseriesFormulaRequestType{ + TIMESERIESFORMULAREQUESTTYPE_TIMESERIES_REQUEST, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *TimeseriesFormulaRequestType) GetAllowedValues() []TimeseriesFormulaRequestType { + return allowedTimeseriesFormulaRequestTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *TimeseriesFormulaRequestType) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = TimeseriesFormulaRequestType(value) + return nil +} + +// NewTimeseriesFormulaRequestTypeFromValue returns a pointer to a valid TimeseriesFormulaRequestType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewTimeseriesFormulaRequestTypeFromValue(v string) (*TimeseriesFormulaRequestType, error) { + ev := TimeseriesFormulaRequestType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for TimeseriesFormulaRequestType: valid values are %v", v, allowedTimeseriesFormulaRequestTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v TimeseriesFormulaRequestType) IsValid() bool { + for _, existing := range allowedTimeseriesFormulaRequestTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to TimeseriesFormulaRequestType value. +func (v TimeseriesFormulaRequestType) Ptr() *TimeseriesFormulaRequestType { + return &v +} + +// NullableTimeseriesFormulaRequestType handles when a null is used for TimeseriesFormulaRequestType. +type NullableTimeseriesFormulaRequestType struct { + value *TimeseriesFormulaRequestType + isSet bool +} + +// Get returns the associated value. +func (v NullableTimeseriesFormulaRequestType) Get() *TimeseriesFormulaRequestType { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableTimeseriesFormulaRequestType) Set(val *TimeseriesFormulaRequestType) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableTimeseriesFormulaRequestType) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag. +func (v *NullableTimeseriesFormulaRequestType) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableTimeseriesFormulaRequestType initializes the struct as if Set has been called. +func NewNullableTimeseriesFormulaRequestType(val *TimeseriesFormulaRequestType) *NullableTimeseriesFormulaRequestType { + return &NullableTimeseriesFormulaRequestType{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableTimeseriesFormulaRequestType) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableTimeseriesFormulaRequestType) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_timeseries_formula_response_type.go b/api/datadogV2/model_timeseries_formula_response_type.go new file mode 100644 index 00000000000..10cd0fb6f5a --- /dev/null +++ b/api/datadogV2/model_timeseries_formula_response_type.go @@ -0,0 +1,107 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// TimeseriesFormulaResponseType The type of the resource. The value should always be timeseries_response. +type TimeseriesFormulaResponseType string + +// List of TimeseriesFormulaResponseType. +const ( + TIMESERIESFORMULARESPONSETYPE_TIMESERIES_RESPONSE TimeseriesFormulaResponseType = "timeseries_response" +) + +var allowedTimeseriesFormulaResponseTypeEnumValues = []TimeseriesFormulaResponseType{ + TIMESERIESFORMULARESPONSETYPE_TIMESERIES_RESPONSE, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *TimeseriesFormulaResponseType) GetAllowedValues() []TimeseriesFormulaResponseType { + return allowedTimeseriesFormulaResponseTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *TimeseriesFormulaResponseType) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = TimeseriesFormulaResponseType(value) + return nil +} + +// NewTimeseriesFormulaResponseTypeFromValue returns a pointer to a valid TimeseriesFormulaResponseType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewTimeseriesFormulaResponseTypeFromValue(v string) (*TimeseriesFormulaResponseType, error) { + ev := TimeseriesFormulaResponseType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for TimeseriesFormulaResponseType: valid values are %v", v, allowedTimeseriesFormulaResponseTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v TimeseriesFormulaResponseType) IsValid() bool { + for _, existing := range allowedTimeseriesFormulaResponseTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to TimeseriesFormulaResponseType value. +func (v TimeseriesFormulaResponseType) Ptr() *TimeseriesFormulaResponseType { + return &v +} + +// NullableTimeseriesFormulaResponseType handles when a null is used for TimeseriesFormulaResponseType. +type NullableTimeseriesFormulaResponseType struct { + value *TimeseriesFormulaResponseType + isSet bool +} + +// Get returns the associated value. +func (v NullableTimeseriesFormulaResponseType) Get() *TimeseriesFormulaResponseType { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableTimeseriesFormulaResponseType) Set(val *TimeseriesFormulaResponseType) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableTimeseriesFormulaResponseType) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag. +func (v *NullableTimeseriesFormulaResponseType) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableTimeseriesFormulaResponseType initializes the struct as if Set has been called. +func NewNullableTimeseriesFormulaResponseType(val *TimeseriesFormulaResponseType) *NullableTimeseriesFormulaResponseType { + return &NullableTimeseriesFormulaResponseType{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableTimeseriesFormulaResponseType) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableTimeseriesFormulaResponseType) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_timeseries_query.go b/api/datadogV2/model_timeseries_query.go new file mode 100644 index 00000000000..98ea9a995dd --- /dev/null +++ b/api/datadogV2/model_timeseries_query.go @@ -0,0 +1,155 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// TimeseriesQuery - An individual timeseries query to one of the basic Datadog data sources. +type TimeseriesQuery struct { + MetricsTimeseriesQuery *MetricsTimeseriesQuery + EventsTimeseriesQuery *EventsTimeseriesQuery + + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject interface{} +} + +// MetricsTimeseriesQueryAsTimeseriesQuery is a convenience function that returns MetricsTimeseriesQuery wrapped in TimeseriesQuery. +func MetricsTimeseriesQueryAsTimeseriesQuery(v *MetricsTimeseriesQuery) TimeseriesQuery { + return TimeseriesQuery{MetricsTimeseriesQuery: v} +} + +// EventsTimeseriesQueryAsTimeseriesQuery is a convenience function that returns EventsTimeseriesQuery wrapped in TimeseriesQuery. +func EventsTimeseriesQueryAsTimeseriesQuery(v *EventsTimeseriesQuery) TimeseriesQuery { + return TimeseriesQuery{EventsTimeseriesQuery: v} +} + +// UnmarshalJSON turns data into one of the pointers in the struct. +func (obj *TimeseriesQuery) UnmarshalJSON(data []byte) error { + var err error + match := 0 + // try to unmarshal data into MetricsTimeseriesQuery + err = json.Unmarshal(data, &obj.MetricsTimeseriesQuery) + if err == nil { + if obj.MetricsTimeseriesQuery != nil && obj.MetricsTimeseriesQuery.UnparsedObject == nil { + jsonMetricsTimeseriesQuery, _ := json.Marshal(obj.MetricsTimeseriesQuery) + if string(jsonMetricsTimeseriesQuery) == "{}" { // empty struct + obj.MetricsTimeseriesQuery = nil + } else { + match++ + } + } else { + obj.MetricsTimeseriesQuery = nil + } + } else { + obj.MetricsTimeseriesQuery = nil + } + + // try to unmarshal data into EventsTimeseriesQuery + err = json.Unmarshal(data, &obj.EventsTimeseriesQuery) + if err == nil { + if obj.EventsTimeseriesQuery != nil && obj.EventsTimeseriesQuery.UnparsedObject == nil { + jsonEventsTimeseriesQuery, _ := json.Marshal(obj.EventsTimeseriesQuery) + if string(jsonEventsTimeseriesQuery) == "{}" { // empty struct + obj.EventsTimeseriesQuery = nil + } else { + match++ + } + } else { + obj.EventsTimeseriesQuery = nil + } + } else { + obj.EventsTimeseriesQuery = nil + } + + if match != 1 { // more than 1 match + // reset to nil + obj.MetricsTimeseriesQuery = nil + obj.EventsTimeseriesQuery = nil + return json.Unmarshal(data, &obj.UnparsedObject) + } + return nil // exactly one match +} + +// MarshalJSON turns data from the first non-nil pointers in the struct to JSON. +func (obj TimeseriesQuery) MarshalJSON() ([]byte, error) { + if obj.MetricsTimeseriesQuery != nil { + return json.Marshal(&obj.MetricsTimeseriesQuery) + } + + if obj.EventsTimeseriesQuery != nil { + return json.Marshal(&obj.EventsTimeseriesQuery) + } + + if obj.UnparsedObject != nil { + return json.Marshal(obj.UnparsedObject) + } + return nil, nil // no data in oneOf schemas +} + +// GetActualInstance returns the actual instance. +func (obj *TimeseriesQuery) GetActualInstance() interface{} { + if obj.MetricsTimeseriesQuery != nil { + return obj.MetricsTimeseriesQuery + } + + if obj.EventsTimeseriesQuery != nil { + return obj.EventsTimeseriesQuery + } + + // all schemas are nil + return nil +} + +// NullableTimeseriesQuery handles when a null is used for TimeseriesQuery. +type NullableTimeseriesQuery struct { + value *TimeseriesQuery + isSet bool +} + +// Get returns the associated value. +func (v NullableTimeseriesQuery) Get() *TimeseriesQuery { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableTimeseriesQuery) Set(val *TimeseriesQuery) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableTimeseriesQuery) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag/ +func (v *NullableTimeseriesQuery) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableTimeseriesQuery initializes the struct as if Set has been called. +func NewNullableTimeseriesQuery(val *TimeseriesQuery) *NullableTimeseriesQuery { + return &NullableTimeseriesQuery{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableTimeseriesQuery) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableTimeseriesQuery) UnmarshalJSON(src []byte) error { + v.isSet = true + + // this object is nullable so check if the payload is null or empty string + if string(src) == "" || string(src) == "{}" { + return nil + } + + return json.Unmarshal(src, &v.value) +} diff --git a/api/datadogV2/model_timeseries_response.go b/api/datadogV2/model_timeseries_response.go new file mode 100644 index 00000000000..2859ce11ead --- /dev/null +++ b/api/datadogV2/model_timeseries_response.go @@ -0,0 +1,152 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// TimeseriesResponse A message containing the response to a timeseries query. +type TimeseriesResponse struct { + // The object describing a timeseries response. + Attributes *TimeseriesResponseAttributes `json:"attributes,omitempty"` + // The type of the resource. The value should always be timeseries_response. + Type *TimeseriesFormulaResponseType `json:"type,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewTimeseriesResponse instantiates a new TimeseriesResponse object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTimeseriesResponse() *TimeseriesResponse { + this := TimeseriesResponse{} + var typeVar TimeseriesFormulaResponseType = TIMESERIESFORMULARESPONSETYPE_TIMESERIES_RESPONSE + this.Type = &typeVar + return &this +} + +// NewTimeseriesResponseWithDefaults instantiates a new TimeseriesResponse object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTimeseriesResponseWithDefaults() *TimeseriesResponse { + this := TimeseriesResponse{} + var typeVar TimeseriesFormulaResponseType = TIMESERIESFORMULARESPONSETYPE_TIMESERIES_RESPONSE + this.Type = &typeVar + return &this +} + +// GetAttributes returns the Attributes field value if set, zero value otherwise. +func (o *TimeseriesResponse) GetAttributes() TimeseriesResponseAttributes { + if o == nil || o.Attributes == nil { + var ret TimeseriesResponseAttributes + return ret + } + return *o.Attributes +} + +// GetAttributesOk returns a tuple with the Attributes field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TimeseriesResponse) GetAttributesOk() (*TimeseriesResponseAttributes, bool) { + if o == nil || o.Attributes == nil { + return nil, false + } + return o.Attributes, true +} + +// HasAttributes returns a boolean if a field has been set. +func (o *TimeseriesResponse) HasAttributes() bool { + return o != nil && o.Attributes != nil +} + +// SetAttributes gets a reference to the given TimeseriesResponseAttributes and assigns it to the Attributes field. +func (o *TimeseriesResponse) SetAttributes(v TimeseriesResponseAttributes) { + o.Attributes = &v +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *TimeseriesResponse) GetType() TimeseriesFormulaResponseType { + if o == nil || o.Type == nil { + var ret TimeseriesFormulaResponseType + return ret + } + return *o.Type +} + +// GetTypeOk returns a tuple with the Type field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TimeseriesResponse) GetTypeOk() (*TimeseriesFormulaResponseType, bool) { + if o == nil || o.Type == nil { + return nil, false + } + return o.Type, true +} + +// HasType returns a boolean if a field has been set. +func (o *TimeseriesResponse) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given TimeseriesFormulaResponseType and assigns it to the Type field. +func (o *TimeseriesResponse) SetType(v TimeseriesFormulaResponseType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TimeseriesResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Attributes != nil { + toSerialize["attributes"] = o.Attributes + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TimeseriesResponse) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Attributes *TimeseriesResponseAttributes `json:"attributes,omitempty"` + Type *TimeseriesFormulaResponseType `json:"type,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if v := all.Type; v != nil && !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + if all.Attributes != nil && all.Attributes.UnparsedObject != nil && o.UnparsedObject == nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + } + o.Attributes = all.Attributes + o.Type = all.Type + return nil +} diff --git a/api/datadogV2/model_timeseries_response_attributes.go b/api/datadogV2/model_timeseries_response_attributes.go new file mode 100644 index 00000000000..2a37d2085ed --- /dev/null +++ b/api/datadogV2/model_timeseries_response_attributes.go @@ -0,0 +1,168 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// TimeseriesResponseAttributes The object describing a timeseries response. +type TimeseriesResponseAttributes struct { + // Array of response series. The index here corresponds to the index in the `formulas` or `queries` array from the request. + Series []TimeseriesResponseSeries `json:"series,omitempty"` + // Array of times, 1-1 match with individual values arrays. + Times []int64 `json:"times,omitempty"` + // Array of value-arrays. The index here corresponds to the index in the `formulas` or `queries` array from the request. + Values [][]float64 `json:"values,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewTimeseriesResponseAttributes instantiates a new TimeseriesResponseAttributes object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTimeseriesResponseAttributes() *TimeseriesResponseAttributes { + this := TimeseriesResponseAttributes{} + return &this +} + +// NewTimeseriesResponseAttributesWithDefaults instantiates a new TimeseriesResponseAttributes object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTimeseriesResponseAttributesWithDefaults() *TimeseriesResponseAttributes { + this := TimeseriesResponseAttributes{} + return &this +} + +// GetSeries returns the Series field value if set, zero value otherwise. +func (o *TimeseriesResponseAttributes) GetSeries() []TimeseriesResponseSeries { + if o == nil || o.Series == nil { + var ret []TimeseriesResponseSeries + return ret + } + return o.Series +} + +// GetSeriesOk returns a tuple with the Series field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TimeseriesResponseAttributes) GetSeriesOk() (*[]TimeseriesResponseSeries, bool) { + if o == nil || o.Series == nil { + return nil, false + } + return &o.Series, true +} + +// HasSeries returns a boolean if a field has been set. +func (o *TimeseriesResponseAttributes) HasSeries() bool { + return o != nil && o.Series != nil +} + +// SetSeries gets a reference to the given []TimeseriesResponseSeries and assigns it to the Series field. +func (o *TimeseriesResponseAttributes) SetSeries(v []TimeseriesResponseSeries) { + o.Series = v +} + +// GetTimes returns the Times field value if set, zero value otherwise. +func (o *TimeseriesResponseAttributes) GetTimes() []int64 { + if o == nil || o.Times == nil { + var ret []int64 + return ret + } + return o.Times +} + +// GetTimesOk returns a tuple with the Times field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TimeseriesResponseAttributes) GetTimesOk() (*[]int64, bool) { + if o == nil || o.Times == nil { + return nil, false + } + return &o.Times, true +} + +// HasTimes returns a boolean if a field has been set. +func (o *TimeseriesResponseAttributes) HasTimes() bool { + return o != nil && o.Times != nil +} + +// SetTimes gets a reference to the given []int64 and assigns it to the Times field. +func (o *TimeseriesResponseAttributes) SetTimes(v []int64) { + o.Times = v +} + +// GetValues returns the Values field value if set, zero value otherwise. +func (o *TimeseriesResponseAttributes) GetValues() [][]float64 { + if o == nil || o.Values == nil { + var ret [][]float64 + return ret + } + return o.Values +} + +// GetValuesOk returns a tuple with the Values field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TimeseriesResponseAttributes) GetValuesOk() (*[][]float64, bool) { + if o == nil || o.Values == nil { + return nil, false + } + return &o.Values, true +} + +// HasValues returns a boolean if a field has been set. +func (o *TimeseriesResponseAttributes) HasValues() bool { + return o != nil && o.Values != nil +} + +// SetValues gets a reference to the given [][]float64 and assigns it to the Values field. +func (o *TimeseriesResponseAttributes) SetValues(v [][]float64) { + o.Values = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TimeseriesResponseAttributes) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Series != nil { + toSerialize["series"] = o.Series + } + if o.Times != nil { + toSerialize["times"] = o.Times + } + if o.Values != nil { + toSerialize["values"] = o.Values + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TimeseriesResponseAttributes) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Series []TimeseriesResponseSeries `json:"series,omitempty"` + Times []int64 `json:"times,omitempty"` + Values [][]float64 `json:"values,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Series = all.Series + o.Times = all.Times + o.Values = all.Values + return nil +} diff --git a/api/datadogV2/model_timeseries_response_series.go b/api/datadogV2/model_timeseries_response_series.go new file mode 100644 index 00000000000..b198fb548ee --- /dev/null +++ b/api/datadogV2/model_timeseries_response_series.go @@ -0,0 +1,168 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// TimeseriesResponseSeries +type TimeseriesResponseSeries struct { + // List of tags that apply to a single response value. + GroupTags []string `json:"group_tags,omitempty"` + // The index of the query in the "formulas" array (or "queries" array if no "formulas" was specified). + QueryIndex *int32 `json:"query_index,omitempty"` + // List of units. + Unit []Unit `json:"unit,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewTimeseriesResponseSeries instantiates a new TimeseriesResponseSeries object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewTimeseriesResponseSeries() *TimeseriesResponseSeries { + this := TimeseriesResponseSeries{} + return &this +} + +// NewTimeseriesResponseSeriesWithDefaults instantiates a new TimeseriesResponseSeries object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewTimeseriesResponseSeriesWithDefaults() *TimeseriesResponseSeries { + this := TimeseriesResponseSeries{} + return &this +} + +// GetGroupTags returns the GroupTags field value if set, zero value otherwise. +func (o *TimeseriesResponseSeries) GetGroupTags() []string { + if o == nil || o.GroupTags == nil { + var ret []string + return ret + } + return o.GroupTags +} + +// GetGroupTagsOk returns a tuple with the GroupTags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TimeseriesResponseSeries) GetGroupTagsOk() (*[]string, bool) { + if o == nil || o.GroupTags == nil { + return nil, false + } + return &o.GroupTags, true +} + +// HasGroupTags returns a boolean if a field has been set. +func (o *TimeseriesResponseSeries) HasGroupTags() bool { + return o != nil && o.GroupTags != nil +} + +// SetGroupTags gets a reference to the given []string and assigns it to the GroupTags field. +func (o *TimeseriesResponseSeries) SetGroupTags(v []string) { + o.GroupTags = v +} + +// GetQueryIndex returns the QueryIndex field value if set, zero value otherwise. +func (o *TimeseriesResponseSeries) GetQueryIndex() int32 { + if o == nil || o.QueryIndex == nil { + var ret int32 + return ret + } + return *o.QueryIndex +} + +// GetQueryIndexOk returns a tuple with the QueryIndex field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TimeseriesResponseSeries) GetQueryIndexOk() (*int32, bool) { + if o == nil || o.QueryIndex == nil { + return nil, false + } + return o.QueryIndex, true +} + +// HasQueryIndex returns a boolean if a field has been set. +func (o *TimeseriesResponseSeries) HasQueryIndex() bool { + return o != nil && o.QueryIndex != nil +} + +// SetQueryIndex gets a reference to the given int32 and assigns it to the QueryIndex field. +func (o *TimeseriesResponseSeries) SetQueryIndex(v int32) { + o.QueryIndex = &v +} + +// GetUnit returns the Unit field value if set, zero value otherwise. +func (o *TimeseriesResponseSeries) GetUnit() []Unit { + if o == nil || o.Unit == nil { + var ret []Unit + return ret + } + return o.Unit +} + +// GetUnitOk returns a tuple with the Unit field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *TimeseriesResponseSeries) GetUnitOk() (*[]Unit, bool) { + if o == nil || o.Unit == nil { + return nil, false + } + return &o.Unit, true +} + +// HasUnit returns a boolean if a field has been set. +func (o *TimeseriesResponseSeries) HasUnit() bool { + return o != nil && o.Unit != nil +} + +// SetUnit gets a reference to the given []Unit and assigns it to the Unit field. +func (o *TimeseriesResponseSeries) SetUnit(v []Unit) { + o.Unit = v +} + +// MarshalJSON serializes the struct using spec logic. +func (o TimeseriesResponseSeries) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.GroupTags != nil { + toSerialize["group_tags"] = o.GroupTags + } + if o.QueryIndex != nil { + toSerialize["query_index"] = o.QueryIndex + } + if o.Unit != nil { + toSerialize["unit"] = o.Unit + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *TimeseriesResponseSeries) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + GroupTags []string `json:"group_tags,omitempty"` + QueryIndex *int32 `json:"query_index,omitempty"` + Unit []Unit `json:"unit,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.GroupTags = all.GroupTags + o.QueryIndex = all.QueryIndex + o.Unit = all.Unit + return nil +} diff --git a/api/datadogV2/model_unit.go b/api/datadogV2/model_unit.go new file mode 100644 index 00000000000..a8ad11a4ca9 --- /dev/null +++ b/api/datadogV2/model_unit.go @@ -0,0 +1,288 @@ +// 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 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" +) + +// Unit Object containing the metric unit family, scale factor, name, and short name. +type Unit struct { + // Unit family, allows for conversion between units of the same family, for scaling. + Family *string `json:"family,omitempty"` + // Unit name + Name *string `json:"name,omitempty"` + // Plural form of the unit name. + Plural *string `json:"plural,omitempty"` + // Factor for scaling between units of the same family. + ScaleFactor *float64 `json:"scale_factor,omitempty"` + // Abbreviation of the unit. + ShortName *string `json:"short_name,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:"-"` + AdditionalProperties map[string]interface{} +} + +// NewUnit instantiates a new Unit object. +// This constructor will assign default values to properties that have it defined, +// and makes sure properties required by API are set, but the set of arguments +// will change when the set of required properties is changed. +func NewUnit() *Unit { + this := Unit{} + return &this +} + +// NewUnitWithDefaults instantiates a new Unit object. +// This constructor will only assign default values to properties that have it defined, +// but it doesn't guarantee that properties required by API are set. +func NewUnitWithDefaults() *Unit { + this := Unit{} + return &this +} + +// GetFamily returns the Family field value if set, zero value otherwise. +func (o *Unit) GetFamily() string { + if o == nil || o.Family == nil { + var ret string + return ret + } + return *o.Family +} + +// GetFamilyOk returns a tuple with the Family field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Unit) GetFamilyOk() (*string, bool) { + if o == nil || o.Family == nil { + return nil, false + } + return o.Family, true +} + +// HasFamily returns a boolean if a field has been set. +func (o *Unit) HasFamily() bool { + return o != nil && o.Family != nil +} + +// SetFamily gets a reference to the given string and assigns it to the Family field. +func (o *Unit) SetFamily(v string) { + o.Family = &v +} + +// GetName returns the Name field value if set, zero value otherwise. +func (o *Unit) GetName() string { + if o == nil || o.Name == nil { + var ret string + return ret + } + return *o.Name +} + +// GetNameOk returns a tuple with the Name field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Unit) GetNameOk() (*string, bool) { + if o == nil || o.Name == nil { + return nil, false + } + return o.Name, true +} + +// HasName returns a boolean if a field has been set. +func (o *Unit) HasName() bool { + return o != nil && o.Name != nil +} + +// SetName gets a reference to the given string and assigns it to the Name field. +func (o *Unit) SetName(v string) { + o.Name = &v +} + +// GetPlural returns the Plural field value if set, zero value otherwise. +func (o *Unit) GetPlural() string { + if o == nil || o.Plural == nil { + var ret string + return ret + } + return *o.Plural +} + +// GetPluralOk returns a tuple with the Plural field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Unit) GetPluralOk() (*string, bool) { + if o == nil || o.Plural == nil { + return nil, false + } + return o.Plural, true +} + +// HasPlural returns a boolean if a field has been set. +func (o *Unit) HasPlural() bool { + return o != nil && o.Plural != nil +} + +// SetPlural gets a reference to the given string and assigns it to the Plural field. +func (o *Unit) SetPlural(v string) { + o.Plural = &v +} + +// GetScaleFactor returns the ScaleFactor field value if set, zero value otherwise. +func (o *Unit) GetScaleFactor() float64 { + if o == nil || o.ScaleFactor == nil { + var ret float64 + return ret + } + return *o.ScaleFactor +} + +// GetScaleFactorOk returns a tuple with the ScaleFactor field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Unit) GetScaleFactorOk() (*float64, bool) { + if o == nil || o.ScaleFactor == nil { + return nil, false + } + return o.ScaleFactor, true +} + +// HasScaleFactor returns a boolean if a field has been set. +func (o *Unit) HasScaleFactor() bool { + return o != nil && o.ScaleFactor != nil +} + +// SetScaleFactor gets a reference to the given float64 and assigns it to the ScaleFactor field. +func (o *Unit) SetScaleFactor(v float64) { + o.ScaleFactor = &v +} + +// GetShortName returns the ShortName field value if set, zero value otherwise. +func (o *Unit) GetShortName() string { + if o == nil || o.ShortName == nil { + var ret string + return ret + } + return *o.ShortName +} + +// GetShortNameOk returns a tuple with the ShortName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *Unit) GetShortNameOk() (*string, bool) { + if o == nil || o.ShortName == nil { + return nil, false + } + return o.ShortName, true +} + +// HasShortName returns a boolean if a field has been set. +func (o *Unit) HasShortName() bool { + return o != nil && o.ShortName != nil +} + +// SetShortName gets a reference to the given string and assigns it to the ShortName field. +func (o *Unit) SetShortName(v string) { + o.ShortName = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o Unit) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Family != nil { + toSerialize["family"] = o.Family + } + if o.Name != nil { + toSerialize["name"] = o.Name + } + if o.Plural != nil { + toSerialize["plural"] = o.Plural + } + if o.ScaleFactor != nil { + toSerialize["scale_factor"] = o.ScaleFactor + } + if o.ShortName != nil { + toSerialize["short_name"] = o.ShortName + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return json.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *Unit) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Family *string `json:"family,omitempty"` + Name *string `json:"name,omitempty"` + Plural *string `json:"plural,omitempty"` + ScaleFactor *float64 `json:"scale_factor,omitempty"` + ShortName *string `json:"short_name,omitempty"` + }{} + err = json.Unmarshal(bytes, &all) + if err != nil { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Family = all.Family + o.Name = all.Name + o.Plural = all.Plural + o.ScaleFactor = all.ScaleFactor + o.ShortName = all.ShortName + return nil +} + +// NullableUnit handles when a null is used for Unit. +type NullableUnit struct { + value *Unit + isSet bool +} + +// Get returns the associated value. +func (v NullableUnit) Get() *Unit { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableUnit) Set(val *Unit) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableUnit) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag/ +func (v *NullableUnit) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableUnit initializes the struct as if Set has been called. +func NewNullableUnit(val *Unit) *NullableUnit { + return &NullableUnit{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableUnit) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableUnit) UnmarshalJSON(src []byte) error { + v.isSet = true + + // this object is nullable so check if the payload is null or empty string + if string(src) == "" || string(src) == "{}" { + return nil + } + + return json.Unmarshal(src, &v.value) +} diff --git a/examples/v2/metrics/QueryScalarData.go b/examples/v2/metrics/QueryScalarData.go new file mode 100644 index 00000000000..7d7f2d9b7c6 --- /dev/null +++ b/examples/v2/metrics/QueryScalarData.go @@ -0,0 +1,57 @@ +// Scalar cross product query returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.ScalarFormulaQueryRequest{ + Data: datadogV2.ScalarFormulaRequest{ + Attributes: datadogV2.ScalarFormulaRequestAttributes{ + Formulas: []datadogV2.QueryFormula{ + { + Formula: "a", + Limit: &datadogV2.FormulaLimit{ + Count: datadog.PtrInt32(10), + Order: datadogV2.QUERYSORTORDER_DESC.Ptr(), + }, + }, + }, + From: 1671612804000, + Queries: []datadogV2.ScalarQuery{ + datadogV2.ScalarQuery{ + MetricsScalarQuery: &datadogV2.MetricsScalarQuery{ + Aggregator: datadogV2.METRICSAGGREGATORENUM_AVG, + DataSource: datadogV2.METRICSDATASOURCE_METRICS, + Query: "avg:system.cpu.user{*}", + Name: datadog.PtrString("a"), + }}, + }, + To: 1671620004000, + }, + Type: datadogV2.SCALARFORMULAREQUESTTYPE_SCALAR_REQUEST, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.QueryScalarData", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewMetricsApi(apiClient) + resp, r, err := api.QueryScalarData(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.QueryScalarData`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `MetricsApi.QueryScalarData`:\n%s\n", responseContent) +} diff --git a/examples/v2/metrics/QueryTimeseriesData.go b/examples/v2/metrics/QueryTimeseriesData.go new file mode 100644 index 00000000000..c4e7c10ad6a --- /dev/null +++ b/examples/v2/metrics/QueryTimeseriesData.go @@ -0,0 +1,57 @@ +// Timeseries cross product query returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" + "github.com/DataDog/datadog-api-client-go/v2/api/datadogV2" +) + +func main() { + body := datadogV2.TimeseriesFormulaQueryRequest{ + Data: datadogV2.TimeseriesFormulaRequest{ + Attributes: datadogV2.TimeseriesFormulaRequestAttributes{ + Formulas: []datadogV2.QueryFormula{ + { + Formula: "a", + Limit: &datadogV2.FormulaLimit{ + Count: datadog.PtrInt32(10), + Order: datadogV2.QUERYSORTORDER_DESC.Ptr(), + }, + }, + }, + From: 1671612804000, + Interval: datadog.PtrInt64(5000), + Queries: []datadogV2.TimeseriesQuery{ + datadogV2.TimeseriesQuery{ + MetricsTimeseriesQuery: &datadogV2.MetricsTimeseriesQuery{ + DataSource: datadogV2.METRICSDATASOURCE_METRICS, + Query: "avg:system.cpu.user{*}", + Name: datadog.PtrString("a"), + }}, + }, + To: 1671620004000, + }, + Type: datadogV2.TIMESERIESFORMULAREQUESTTYPE_TIMESERIES_REQUEST, + }, + } + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("v2.QueryTimeseriesData", true) + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewMetricsApi(apiClient) + resp, r, err := api.QueryTimeseriesData(ctx, body) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.QueryTimeseriesData`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `MetricsApi.QueryTimeseriesData`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..36050d7ebfe --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2022-12-21T11:14:00.535Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..017fb75045f --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_Bad_Request_response.yaml @@ -0,0 +1,21 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"formulas":[{"formula":"a+b","limit":{"count":10,"order":"desc"}}],"from":1568899800000,"queries":[{"aggregator":"avg","data_source":"metrics","name":"a","query":"avg:system.cpu.user{*}"}],"to":1568923200000},"type":"scalar_request"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/query/scalar + response: + body: '{"errors":["Queries ending outside the retention date are invalid"]}' + code: 400 + duration: '' + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_OK_response.freeze new file mode 100644 index 00000000000..224b8d84abf --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_OK_response.freeze @@ -0,0 +1 @@ +2022-12-21T11:14:01.142Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_OK_response.yaml new file mode 100644 index 00000000000..10a66fc996b --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Scalar_cross_product_query_returns_OK_response.yaml @@ -0,0 +1,21 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"formulas":[{"formula":"a","limit":{"count":10,"order":"desc"}}],"from":1671612804000,"queries":[{"aggregator":"avg","data_source":"metrics","name":"a","query":"avg:system.cpu.user{*}"}],"to":1671620004000},"type":"scalar_request"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/query/scalar + response: + body: '{"data":{"type":"scalar_response","attributes":{"columns":[{"name":"a","values":[5.173633659114822],"type":"number","meta":{"unit":[{"scale_factor":1.0,"id":17,"name":"percent","plural":"percent","family":"percentage","short_name":"%"},null]}}]}}}' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_Bad_Request_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_Bad_Request_response.freeze new file mode 100644 index 00000000000..ae90f3a3508 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_Bad_Request_response.freeze @@ -0,0 +1 @@ +2022-12-21T11:14:01.584Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_Bad_Request_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_Bad_Request_response.yaml new file mode 100644 index 00000000000..3b8faeb040d --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_Bad_Request_response.yaml @@ -0,0 +1,21 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"formulas":[{"formula":"a+b","limit":{"count":10,"order":"desc"}}],"from":1671617641,"interval":5000,"queries":[{"data_source":"metrics","query":"avg:system.cpu.user{*}"}],"to":1671621241},"type":"timeseries_rquest"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/query/timeseries + response: + body: '{"errors":["API input validation failed: Invalid type. Expected \"timeseries_request\"."]}' + code: 400 + duration: '' + headers: + Content-Type: + - application/json + status: 400 Bad Request +version: 1 diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_OK_response.freeze new file mode 100644 index 00000000000..5bdb3c10fff --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_OK_response.freeze @@ -0,0 +1 @@ +2022-12-21T11:14:01.814Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_OK_response.yaml new file mode 100644 index 00000000000..fbdefa13855 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v2/Feature_Metrics/Scenario_Timeseries_cross_product_query_returns_OK_response.yaml @@ -0,0 +1,21 @@ +interactions: +- request: + body: | + {"data":{"attributes":{"formulas":[{"formula":"a","limit":{"count":10,"order":"desc"}}],"from":1671612804000,"interval":5000,"queries":[{"data_source":"metrics","name":"a","query":"avg:system.cpu.user{*}"}],"to":1671620004000},"type":"timeseries_request"}} + form: {} + headers: + Accept: + - application/json + Content-Type: + - application/json + method: POST + url: https://api.datadoghq.com/api/v2/query/timeseries + response: + body: '{"data":{"type":"timeseries_response","attributes":{"values":[[4.511036,4.452697,4.412659,4.518245,4.687136,4.97308,5.192443,5.394637,5.340696,4.967064,4.986722,5.222986,5.654652,5.309001,5.166451,5.10007,5.363234,5.198181,4.985549,4.732672,4.596457,4.438161,4.440617,4.417017,4.460995,4.388007,4.407114,4.396247,4.463179,4.556415,4.706282,4.841254,4.834313,4.969147,5.022375,5.204864,4.885128,5.136058,5.385709,5.960689,5.565356,5.246903,4.899752,4.89686,4.872231,4.843359,5.013687,4.84587,4.641045,4.316564,4.259839,4.286675,4.351473,4.486833,4.577294,4.745868,4.705028,4.661034,4.471036,4.442686,4.648083,5.242174,5.852524,6.096846,5.89139,5.560238,5.280996,4.862933,4.709248,4.623006,4.860077,4.935585,5.022714,5.029523,4.788869,4.585691,4.341339,4.392719,4.404215,4.68485,4.762513,4.861116,4.615962,4.537305,4.396546,4.354968,4.328285,4.607015,5.543913,6.324773,6.792496,7.220547,6.606063,5.876218,5.871163,5.78849,5.905384,5.90785,6.120763,6.309492,6.454408,6.166451,5.863357,5.795657,5.884391,5.989054,5.812381,5.704644,5.556254,5.478115,5.505722,5.60674,6.059316,6.338839,6.711452,6.735411,6.865414,6.90191,6.756111,6.526661,6.100718,5.87628,5.748863,5.757181,5.722193,5.932041,6.204195,6.685102,6.549346,6.337531,5.916065,5.809077,5.712645,5.624461,5.609235,5.663688,5.853015,5.902995,5.914612,6.256064,6.687142,7.191397,6.847396,6.486767,6.206287,6.328331,6.46251,6.206348,5.929493,5.680556,5.661752,5.797259,6.048074,6.290369,6.501473,6.405154,6.309052,5.99345,5.866646,5.775236,5.92197,5.930556,5.906912,5.884151,6.011508,6.121853,6.39136,6.543824,6.756647,6.35429,6.0619,6.013092,6.279459,6.557457,6.311731,6.210523,5.947832,5.862253,5.738994,5.956962,6.252644,6.373787,6.300842,6.234464,6.376188,6.240802,6.092113,5.74307,5.68881,5.591538,6.218279,6.730657,7.310558,6.723645,6.249439,5.753847,5.758291,5.734797,5.933901,6.279562,6.520173,6.370642,6.201029,6.106782,6.112661,5.918345,5.965812,6.068902,6.358401,5.119474,5.134993,5.013521,4.778848,4.535078,4.507003,4.597434,4.656196,4.967201,5.331067,5.783775,5.319137,4.889232,4.395338,4.502716,4.490939,4.684735,4.821445,5.037191,5.007238,4.953504,4.945898,4.866694,4.819154,4.764052,4.819065,4.745362,4.831931,4.931988,5.21707,4.966855,4.702029,4.854507,5.347428,5.893627,5.386981,4.955269,4.470617,4.596507,4.521039,4.462105,4.346769,4.390456,4.519676,4.678632,4.852548,5.094638,5.299293,5.37353,5.054819,4.66616,4.420079,4.38882,4.519663,4.774763,5.069079,5.221413,4.927594,4.634475,4.909238,5.491882,6.046457,5.631336,5.062027,4.481505,4.341841,4.332686,4.364885,4.448851,4.572952,4.751025,4.902067,4.904094,5.054718,5.090399,5.254011,4.913755,4.751565,4.463131,4.463551,4.378909,4.649447,4.923694,5.6018,5.903531,6.186827,5.836629,5.377205,4.888724,4.536856,4.40555,4.363478,4.431734,4.545142,4.598567,4.695658,4.685236,4.679584,4.532542,4.445523,4.632351,4.974624,5.250778,5.07555,4.798842,4.620069,4.536116,4.457244,4.604563,4.840088,5.766038,6.303143,6.802655,6.091143,5.328086,4.642865,4.450604,4.476219,4.449314,4.629411,4.735648,4.865296,4.685488,4.51912,4.315168,4.350158,4.360299,4.571845,4.709814,4.902212,5.001238,5.028215,5.084393,4.820687,5.052605,5.28559,5.715299,5.603917,5.55135,5.576788,5.450727,5.078365,4.679194,4.674274,4.750762,4.798283,4.627874,4.535463,4.437021,4.466878,4.454509,4.491398,4.488202,4.494882,4.55218,4.543842,4.570604,4.697906,4.977783,5.215616,5.077405,5.413667,5.827774,6.409674,5.830352,5.430387,5.057747,5.445663,5.304086,5.155742,4.682481,4.497533,4.296956,4.310508,4.31634,4.375265,4.413491,4.458567,4.471268,4.39949,4.354437,4.342085,4.469582,4.563571,4.77724,5.132156,5.460429,5.638983,5.607113,5.687771,5.619198,5.360052,5.266902,5.285339,5.48854,5.203703,4.971474,4.666843,4.555747,4.40484,4.354661,4.353139,4.397763,4.369454,4.398596,4.43654,4.548555,4.556558,4.459109,4.368599,4.31658,4.492293,5.099936,5.773344,6.509406,6.340683,6.058546,5.237316,4.795722,4.701339,4.939245,5.249865,5.095241,4.927081,4.730854,4.643312,4.5614,4.439782,4.407931,4.405545,4.507572,4.545492,4.477086,4.380839,4.299001,4.341577,5.604058,5.766157,5.924093,6.431079,6.771484,7.294038,7.10321,7.014538,6.532796,6.284576,6.21839,6.226662,6.353135,6.177565,6.098286,5.951891,5.796254,5.661725,5.637161,5.689067,5.648374,5.564126,5.559261,5.662602,5.660762,5.650876,5.651624,6.41184,7.040154,7.567294,6.793774,6.159532,5.770742,6.113773,6.399101,6.543671,6.549843,6.707259,6.57199,6.418717,6.139889,6.142233,6.228013,6.106845,5.859366,5.618063,5.611779,5.729061,5.712502,5.660427,5.623323,5.807494,5.906427,5.905664,6.240026,6.689505,7.181008,6.755872,6.284999,5.894045,5.932816,5.963972,6.125965,6.264631,6.555714,6.41868,6.400609,6.342607,6.363507,6.368072,6.020383,6.116022,6.075169,6.304079,5.997817,5.926331,5.835736,5.891495,6.224173,6.571082,6.98461,6.704984,6.448813,6.206686,6.137743,5.95096,5.734213,5.579123,5.550976,5.84681,6.207702,6.46903,6.184917,5.960549,6.08436,6.368466,6.486024,6.146055,5.958414,5.985733,6.072375,6.015133,5.767673,5.64189,5.590981,6.234506,6.886698,7.54875,7.055817,6.521776,5.957623,5.813814,5.677685,5.602713,5.673723,5.745898,5.842411,5.957794,6.047446,6.123755,6.040006,6.257737,6.292998,6.548829,6.36445,6.243616,5.961898,5.768549,5.632522,5.800672,6.087605,6.397678,6.604807,6.72822,6.816733,6.330082,5.933997,5.614503,5.733362,5.767461,5.642726,5.566482,5.53098,5.69419,5.690981,5.74126,5.95255,6.364493,6.861884,6.769757,6.550781,6.22468,6.218283,6.221438,5.983002,5.777493,6.236155,6.917476,7.551833,6.874846,5.03724,4.431195,4.541074,4.577274,4.479928,4.413132,4.38909,4.489487,4.408067,4.381461,4.394746,4.636141,4.749196,5.006414,5.137766,5.463718,5.387333,5.3072,5.29074,5.3804,5.764801,5.838204,5.966061,5.967326,5.911563,5.945886,5.458721,5.137591,4.634298,4.542561,4.4042,4.421751,4.301151,4.328716,4.37357,4.63648,4.76866,4.788025,4.641315,4.548089,4.700453,4.909737,5.083664,5.063394,5.06239,5.222026,5.203851,5.766587,6.339293,7.148687,6.738301,6.094441,5.289414,5.141527,4.828282,4.65933,4.355831,4.35543,4.379142,4.59293,4.713009,4.713887,4.576071,4.482119,4.433541,4.413563,4.399436,4.526244,4.706011,4.884732,5.069787,5.325227,5.544574,5.43909,5.56328,5.789192,6.097385,5.646025,5.325857,5.145808,5.289327,5.302399,5.347059,5.557595,5.401509,5.109009,4.749572,4.642069,4.622322,4.570128,4.56531,4.554197,4.600152,4.614564,4.633111,4.669017,4.759874,5.144207,5.960851,6.683971,6.757185,5.874296,5.065982,4.596848,4.488963,4.410002,4.403799,4.641694,5.060071,5.335161,5.423871,5.331915,5.316386,5.358,5.093657,4.843664,4.62796,4.608533,4.525216,4.362327,4.319978,4.423956,4.692335,4.820373,4.980927,5.518366,6.163841,6.607748,5.936241,5.27836,4.616486,4.686,4.729623,4.818991,4.730467,4.586487,4.427772,4.325053,4.554597,4.875824,5.256654,5.209429,5.079156,4.835285,4.635874,4.535398,4.639349,4.813136,4.811499,5.057662,5.295994,5.837526,5.554467,5.34481,5.038404,5.181465,5.283583,5.033609,4.727632,4.436047,4.40415,4.400332,4.350948,4.314592,4.347252,4.535038,4.695051,4.738912,4.818852,4.961932,5.281096,5.172995,4.916344,4.518263,4.376344,4.374166,4.828422,5.339736,5.945168,5.679431,5.352809,5.038977,5.182376,5.350026,5.070155,4.736487,4.416676,4.416178,4.480411,4.515826,4.52491,4.474684,4.523715,4.643881,4.808741,5.119445,5.259779,5.527601,5.241716,5.084799,4.971889,5.232194,5.531652,6.685176,6.594271,6.378665,6.036106,5.749025,5.808157,6.080423,6.412563,6.294321,6.215258,6.025452,5.89444,5.693119,5.571756,5.603598,5.68151,5.692337,5.562277,5.55869,5.857507,6.29602,6.405064,6.114436,5.839327,6.396238,7.000285,7.477303,6.723237,6.070666,5.49394,5.519553,5.573955,5.82986,6.112589,6.354534,6.31873,6.196888,6.104198,5.999645,5.950351,5.829921,5.686605,5.681302,5.699959,5.846128,5.645393,5.755449,5.91268,6.662886,6.95588,7.11596,6.802511,6.591513,6.438332,6.099304,5.820275,5.568072,5.630495,5.694073,5.845307,5.912643,5.98479,6.082166,6.25045,6.398362,6.104982,5.823612,5.552764,5.622212,5.577602,5.622981,5.698252,5.900581,6.182465,6.322807,6.879799,7.188691,7.575777,6.944885,6.332597,5.738734,5.726838,5.731537,5.696529,5.585202,5.606314,5.76105,5.967555,6.023276,6.086462,6.190188,6.382263,6.231862,6.011573,5.81893,5.89358,6.005905,6.020039,5.924513,5.954029,6.218235,6.546941,6.86891,7.068611,7.290977,7.051559,6.550897,6.011635,5.76731,5.717968,5.721631,5.75174,5.780763,5.681889,5.629537,5.586623,5.930293,6.201426,6.514922,6.416912,6.369352,6.235789,6.073721,5.847272,5.686301,5.666934,6.20975,6.838556,7.481553,7.10064,6.74616,6.363331,6.426738,6.149344,5.933233,5.797128,5.764722,5.594668,5.453125,5.472548,5.625085,5.647283,5.639621,5.837096,6.222168,6.555405,6.567566,6.413279,6.259412,5.993273,5.836282,5.718845,5.876219,6.359873,6.913569,7.312316,6.855393,6.49938,6.249611,6.488738,6.220029,5.826509,5.468172,5.509878,5.668124,5.651684,5.55219,5.480868,5.776867,6.050206,6.320538,6.179636,4.832263,4.775748,4.913662,5.042063,4.886298,5.267017,5.664358,6.190853,5.599437,5.063675,4.609602,4.731749,4.929136,4.990367,5.075219,4.809662,4.699379,4.448029,4.453063,4.464069,4.778076,4.968893,5.026659,4.742275,4.509446,4.349922,4.318112,4.333597,4.712625,5.149869,5.538111,5.250051,5.430985,5.646023,6.171322,5.641228,5.005292,4.269737,4.127678,4.457571,4.924372,5.234745,4.960325,4.707864,4.7212,4.849351,4.856047,4.659763,4.515796,4.40401,4.28801,4.248618,4.343867,4.510173,4.653705,4.873166,5.475965,6.089268,6.458531,6.113302,5.659335,5.043469,4.646805,4.404469,4.426382,4.430821,4.625457,4.844742,5.305028,5.334793,5.238127,5.017317,4.845061,4.712686,4.480259,4.34903,4.303095,4.392626,4.520331,4.550567,4.490779,4.421446,4.612996,5.418715,6.130108,6.557769,5.906486,5.391859,4.76831,4.541351,4.300085,4.28724,4.507887,4.844942,5.067092,5.194992,5.148974,5.109309,4.936994,4.584296,4.385518,4.339996,4.555223,4.600138,4.552129,4.459152,4.490483,4.895494,5.176983,5.367816,5.214093,5.243578,5.553901,5.520566,5.466149,4.951061,4.903601,4.728387,4.690531,4.591224,4.694436,4.82881,4.816989,4.753052,4.823508,5.033822,5.009298,4.840712,4.586339,4.497735,4.521818,4.616727,4.592391,4.390049,4.754736,5.292695,5.990752,5.433798,4.874551,4.609329,6.273603,6.622937,6.406608,6.098107,5.859874,5.761692,5.699095,5.738033,5.928273,6.042024,6.212206,6.283889,6.348515,6.03773,5.856465,5.746708,5.760088,5.574866,5.629056,5.842481,6.212418,6.332498,6.486201,6.673879,6.637943,6.410638,6.228425,6.204078,6.251118,6.120688,6.104847,6.117011,6.128335,6.039968,6.024517,5.996286,5.954031,6.080514,6.325126,6.629632,6.330814,5.879413,5.487668,5.475292,5.606567,6.086079,6.551131,7.044473,6.717788,6.373728,5.90751,5.788284,5.637395,5.605675,5.691471,5.83554,6.151315,6.386746,6.631715,6.344835,6.018192,5.681254,5.689872,5.777793,6.025317,6.133933,6.277648,6.077327,5.987568,5.864989,5.897015,5.98555,6.432356,6.84112,7.113095,6.589542,6.094027,5.623514,5.522933,5.456934,5.553226,5.835291,6.116502,6.442473,6.487873,6.536535,6.249372,6.118733,5.884059,5.657973,5.46341,5.645555,6.014105,6.221535,6.082907,5.97792,6.605409,7.116229,7.513281,6.776364,6.196296,5.634951,5.539648,5.487374,5.53557,5.779974,6.000779,6.112113,5.928658,5.783382,5.959631,6.315152,6.542625,6.299304,6.056088,5.939025,5.911343,5.733488,5.715221,5.846496,6.276358,6.51246,6.639074,6.968599,7.038584,7.128989,6.333121,5.844307,5.497183,5.800551,6.030352,6.103949,5.898767,5.765905,5.739806,5.842296,5.810825,5.774666,5.799678,5.960618,6.175287,6.215175,6.210616,5.967476,5.942759,6.008709,6.133901,6.629062,7.094273,7.601003,7.124397,6.381531,5.775035,5.7209,4.618646,4.612236,4.580121,4.631924,4.788916,4.869726,4.725961,4.426403,4.237035,4.238751,4.471406,4.54099,4.569971,4.736883,5.111344,5.468716,5.242926,4.910903,4.614703,4.604205,5.102441,5.794475,6.579083,6.378665,5.659266,4.851441,4.604152,4.706479,4.903261,4.915074,4.758218,4.438578,4.282497,4.296713,4.442762,4.42422,4.385566,4.367747,4.581674,4.708094,5.002209,5.118579,5.276625,4.994579,5.199706,5.425813,5.857754,5.575338,5.553697,5.519307,5.695908,5.392566,5.153951,4.928129,4.781003,4.505271,4.340054,4.348453,4.475752,4.443477,4.347478,4.295168,4.46318,4.659531,4.704127,4.582243,4.42392,4.515223,4.646424,4.810829,4.866754,5.535652,6.181608,6.558875,6.119795,5.939606,6.024731,6.10155,5.729936,5.191755,4.855069,4.62908,4.539812,4.356187,4.290331,4.258751,4.495982,4.627023,4.629326,4.46164,4.345039,4.251476,4.158577,4.137362,4.384953,5.127785,5.811248,6.339538,6.152728,5.970296,5.531606,5.285539,5.13868,5.059199,4.957679,4.80036,4.814019,4.810097,4.646634,4.485126,4.562479,4.681973,4.686368,4.531101,4.45098,4.408121,4.303228,4.210933,4.199395,4.301117,4.404,4.451049,5.035731,5.597682,6.472714,6.319295,6.139632,5.306536,4.89893,4.676551,4.774042,4.779566,4.770472,4.846208,5.208855,5.144842,4.951127,4.499941,4.32453,4.165687,4.121568,4.111922,4.260117,4.414244,4.572062,4.55377,4.760701,4.939656,5.236439,5.326482,5.35259,5.469586,5.378005,5.429631,5.295584,5.132135,4.957289,4.726218,4.830203,5.014876,5.241954,5.275216,4.94524,4.624836,4.357895,4.32174,4.437574,4.585687,4.677603,4.605942,4.486562,4.446988,4.528397,5.148481,5.659672,6.001403,5.476604,5.043609,4.896314,4.843518,4.862955,4.859315,5.257259,5.43781,5.181337,4.718804,4.696636,4.893918,5.129713,4.867492,4.772701,4.730195,4.764529,4.633799,4.434671,4.385646,4.439964,4.737586,4.931165,4.992294,5.18201,5.429843,5.799209,5.203428,4.704732,4.292338,4.712125,4.914683,5.164046,5.13062,5.254577,6.20602,5.900201,5.838758,6.136142,6.539876,6.490473,6.320498,6.029799,5.849631,5.778629,5.792266,5.814994,5.671524,6.11667,6.634235,7.313299,6.785364,6.318054,5.851944,6.03558,6.030941,5.90854,5.67218,5.566682,5.763776,6.014838,6.306039,6.289419,6.315688,6.387644,6.371196,6.253278,6.054117,6.075445,6.191639,6.123509,5.884337,5.702941,5.645145,5.737004,6.137232,6.651602,7.18268,6.894427,6.427788,5.844523,5.630892,5.536274,5.460717,5.399471,5.384941,5.684967,6.076944,6.346145,6.300043,6.171566,6.270923,6.272039,6.331771,6.232373,6.17044,6.134211,5.890281,5.784696,6.129036,6.758892,7.419302,7.064726,6.499073,5.79491,5.597523,5.56562,5.57104,5.530379,5.483724,5.568086,5.757489,5.865048,5.904134,5.830992,5.84393,6.067724,6.376209,6.61588,6.245042,5.901773,5.832324,6.173587,6.410851,6.245492,6.097784,6.682907,7.287409,7.77155,6.909144,6.205196,5.524181,5.471934,5.425607,5.530089,5.717283,5.864346,5.833852,5.721153,5.648504,5.694641,5.802921,5.806947,5.936552,6.068029,6.303821,6.19461,5.977509,6.05355,6.274451,7.21223,7.568562,7.899143,7.156186,6.614372,6.072601,5.802854,5.645036,5.636112,5.830003,5.917967,5.864038,5.729806,5.70113,5.749439,5.841068,5.777667,5.583263,5.450398,5.449781,5.784586,5.938633,6.145093,6.134809,6.431945,6.731871,6.793005,7.092693,7.301103,7.672924,7.025567,6.260767,5.63989,5.668738,5.772637,5.738042,5.645429,5.666463,5.790594,4.649319,4.62785,4.439407]],"times":[1671612300000,1671612305000,1671612310000,1671612315000,1671612320000,1671612325000,1671612330000,1671612335000,1671612340000,1671612345000,1671612350000,1671612355000,1671612360000,1671612365000,1671612370000,1671612375000,1671612380000,1671612385000,1671612390000,1671612395000,1671612400000,1671612405000,1671612410000,1671612415000,1671612420000,1671612425000,1671612430000,1671612435000,1671612440000,1671612445000,1671612450000,1671612455000,1671612460000,1671612465000,1671612470000,1671612475000,1671612480000,1671612485000,1671612490000,1671612495000,1671612500000,1671612505000,1671612510000,1671612515000,1671612520000,1671612525000,1671612530000,1671612535000,1671612540000,1671612545000,1671612550000,1671612555000,1671612560000,1671612565000,1671612570000,1671612575000,1671612580000,1671612585000,1671612590000,1671612595000,1671612600000,1671612605000,1671612610000,1671612615000,1671612620000,1671612625000,1671612630000,1671612635000,1671612640000,1671612645000,1671612650000,1671612655000,1671612660000,1671612665000,1671612670000,1671612675000,1671612680000,1671612685000,1671612690000,1671612695000,1671612700000,1671612705000,1671612710000,1671612715000,1671612720000,1671612725000,1671612730000,1671612735000,1671612740000,1671612745000,1671612750000,1671612755000,1671612760000,1671612765000,1671612770000,1671612775000,1671612780000,1671612785000,1671612790000,1671612795000,1671612800000,1671612805000,1671612810000,1671612815000,1671612820000,1671612825000,1671612830000,1671612835000,1671612840000,1671612845000,1671612850000,1671612855000,1671612860000,1671612865000,1671612870000,1671612875000,1671612880000,1671612885000,1671612890000,1671612895000,1671612900000,1671612905000,1671612910000,1671612915000,1671612920000,1671612925000,1671612930000,1671612935000,1671612940000,1671612945000,1671612950000,1671612955000,1671612960000,1671612965000,1671612970000,1671612975000,1671612980000,1671612985000,1671612990000,1671612995000,1671613000000,1671613005000,1671613010000,1671613015000,1671613020000,1671613025000,1671613030000,1671613035000,1671613040000,1671613045000,1671613050000,1671613055000,1671613060000,1671613065000,1671613070000,1671613075000,1671613080000,1671613085000,1671613090000,1671613095000,1671613100000,1671613105000,1671613110000,1671613115000,1671613120000,1671613125000,1671613130000,1671613135000,1671613140000,1671613145000,1671613150000,1671613155000,1671613160000,1671613165000,1671613170000,1671613175000,1671613180000,1671613185000,1671613190000,1671613195000,1671613200000,1671613205000,1671613210000,1671613215000,1671613220000,1671613225000,1671613230000,1671613235000,1671613240000,1671613245000,1671613250000,1671613255000,1671613260000,1671613265000,1671613270000,1671613275000,1671613280000,1671613285000,1671613290000,1671613295000,1671613300000,1671613305000,1671613310000,1671613315000,1671613320000,1671613325000,1671613330000,1671613335000,1671613340000,1671613345000,1671613350000,1671613355000,1671613360000,1671613365000,1671613370000,1671613375000,1671613380000,1671613385000,1671613390000,1671613395000,1671613400000,1671613405000,1671613410000,1671613415000,1671613420000,1671613425000,1671613430000,1671613435000,1671613440000,1671613445000,1671613450000,1671613455000,1671613460000,1671613465000,1671613470000,1671613475000,1671613480000,1671613485000,1671613490000,1671613495000,1671613500000,1671613505000,1671613510000,1671613515000,1671613520000,1671613525000,1671613530000,1671613535000,1671613540000,1671613545000,1671613550000,1671613555000,1671613560000,1671613565000,1671613570000,1671613575000,1671613580000,1671613585000,1671613590000,1671613595000,1671613600000,1671613605000,1671613610000,1671613615000,1671613620000,1671613625000,1671613630000,1671613635000,1671613640000,1671613645000,1671613650000,1671613655000,1671613660000,1671613665000,1671613670000,1671613675000,1671613680000,1671613685000,1671613690000,1671613695000,1671613700000,1671613705000,1671613710000,1671613715000,1671613720000,1671613725000,1671613730000,1671613735000,1671613740000,1671613745000,1671613750000,1671613755000,1671613760000,1671613765000,1671613770000,1671613775000,1671613780000,1671613785000,1671613790000,1671613795000,1671613800000,1671613805000,1671613810000,1671613815000,1671613820000,1671613825000,1671613830000,1671613835000,1671613840000,1671613845000,1671613850000,1671613855000,1671613860000,1671613865000,1671613870000,1671613875000,1671613880000,1671613885000,1671613890000,1671613895000,1671613900000,1671613905000,1671613910000,1671613915000,1671613920000,1671613925000,1671613930000,1671613935000,1671613940000,1671613945000,1671613950000,1671613955000,1671613960000,1671613965000,1671613970000,1671613975000,1671613980000,1671613985000,1671613990000,1671613995000,1671614000000,1671614005000,1671614010000,1671614015000,1671614020000,1671614025000,1671614030000,1671614035000,1671614040000,1671614045000,1671614050000,1671614055000,1671614060000,1671614065000,1671614070000,1671614075000,1671614080000,1671614085000,1671614090000,1671614095000,1671614100000,1671614105000,1671614110000,1671614115000,1671614120000,1671614125000,1671614130000,1671614135000,1671614140000,1671614145000,1671614150000,1671614155000,1671614160000,1671614165000,1671614170000,1671614175000,1671614180000,1671614185000,1671614190000,1671614195000,1671614200000,1671614205000,1671614210000,1671614215000,1671614220000,1671614225000,1671614230000,1671614235000,1671614240000,1671614245000,1671614250000,1671614255000,1671614260000,1671614265000,1671614270000,1671614275000,1671614280000,1671614285000,1671614290000,1671614295000,1671614300000,1671614305000,1671614310000,1671614315000,1671614320000,1671614325000,1671614330000,1671614335000,1671614340000,1671614345000,1671614350000,1671614355000,1671614360000,1671614365000,1671614370000,1671614375000,1671614380000,1671614385000,1671614390000,1671614395000,1671614400000,1671614405000,1671614410000,1671614415000,1671614420000,1671614425000,1671614430000,1671614435000,1671614440000,1671614445000,1671614450000,1671614455000,1671614460000,1671614465000,1671614470000,1671614475000,1671614480000,1671614485000,1671614490000,1671614495000,1671614500000,1671614505000,1671614510000,1671614515000,1671614520000,1671614525000,1671614530000,1671614535000,1671614540000,1671614545000,1671614550000,1671614555000,1671614560000,1671614565000,1671614570000,1671614575000,1671614580000,1671614585000,1671614590000,1671614595000,1671614600000,1671614605000,1671614610000,1671614615000,1671614620000,1671614625000,1671614630000,1671614635000,1671614640000,1671614645000,1671614650000,1671614655000,1671614660000,1671614665000,1671614670000,1671614675000,1671614680000,1671614685000,1671614690000,1671614695000,1671614700000,1671614705000,1671614710000,1671614715000,1671614720000,1671614725000,1671614730000,1671614735000,1671614740000,1671614745000,1671614750000,1671614755000,1671614760000,1671614765000,1671614770000,1671614775000,1671614780000,1671614785000,1671614790000,1671614795000,1671614800000,1671614805000,1671614810000,1671614815000,1671614820000,1671614825000,1671614830000,1671614835000,1671614840000,1671614845000,1671614850000,1671614855000,1671614860000,1671614865000,1671614870000,1671614875000,1671614880000,1671614885000,1671614890000,1671614895000,1671614900000,1671614905000,1671614910000,1671614915000,1671614920000,1671614925000,1671614930000,1671614935000,1671614940000,1671614945000,1671614950000,1671614955000,1671614960000,1671614965000,1671614970000,1671614975000,1671614980000,1671614985000,1671614990000,1671614995000,1671615000000,1671615005000,1671615010000,1671615015000,1671615020000,1671615025000,1671615030000,1671615035000,1671615040000,1671615045000,1671615050000,1671615055000,1671615060000,1671615065000,1671615070000,1671615075000,1671615080000,1671615085000,1671615090000,1671615095000,1671615100000,1671615105000,1671615110000,1671615115000,1671615120000,1671615125000,1671615130000,1671615135000,1671615140000,1671615145000,1671615150000,1671615155000,1671615160000,1671615165000,1671615170000,1671615175000,1671615180000,1671615185000,1671615190000,1671615195000,1671615200000,1671615205000,1671615210000,1671615215000,1671615220000,1671615225000,1671615230000,1671615235000,1671615240000,1671615245000,1671615250000,1671615255000,1671615260000,1671615265000,1671615270000,1671615275000,1671615280000,1671615285000,1671615290000,1671615295000,1671615300000,1671615305000,1671615310000,1671615315000,1671615320000,1671615325000,1671615330000,1671615335000,1671615340000,1671615345000,1671615350000,1671615355000,1671615360000,1671615365000,1671615370000,1671615375000,1671615380000,1671615385000,1671615390000,1671615395000,1671615400000,1671615405000,1671615410000,1671615415000,1671615420000,1671615425000,1671615430000,1671615435000,1671615440000,1671615445000,1671615450000,1671615455000,1671615460000,1671615465000,1671615470000,1671615475000,1671615480000,1671615485000,1671615490000,1671615495000,1671615500000,1671615505000,1671615510000,1671615515000,1671615520000,1671615525000,1671615530000,1671615535000,1671615540000,1671615545000,1671615550000,1671615555000,1671615560000,1671615565000,1671615570000,1671615575000,1671615580000,1671615585000,1671615590000,1671615595000,1671615600000,1671615605000,1671615610000,1671615615000,1671615620000,1671615625000,1671615630000,1671615635000,1671615640000,1671615645000,1671615650000,1671615655000,1671615660000,1671615665000,1671615670000,1671615675000,1671615680000,1671615685000,1671615690000,1671615695000,1671615700000,1671615705000,1671615710000,1671615715000,1671615720000,1671615725000,1671615730000,1671615735000,1671615740000,1671615745000,1671615750000,1671615755000,1671615760000,1671615765000,1671615770000,1671615775000,1671615780000,1671615785000,1671615790000,1671615795000,1671615800000,1671615805000,1671615810000,1671615815000,1671615820000,1671615825000,1671615830000,1671615835000,1671615840000,1671615845000,1671615850000,1671615855000,1671615860000,1671615865000,1671615870000,1671615875000,1671615880000,1671615885000,1671615890000,1671615895000,1671615900000,1671615905000,1671615910000,1671615915000,1671615920000,1671615925000,1671615930000,1671615935000,1671615940000,1671615945000,1671615950000,1671615955000,1671615960000,1671615965000,1671615970000,1671615975000,1671615980000,1671615985000,1671615990000,1671615995000,1671616000000,1671616005000,1671616010000,1671616015000,1671616020000,1671616025000,1671616030000,1671616035000,1671616040000,1671616045000,1671616050000,1671616055000,1671616060000,1671616065000,1671616070000,1671616075000,1671616080000,1671616085000,1671616090000,1671616095000,1671616100000,1671616105000,1671616110000,1671616115000,1671616120000,1671616125000,1671616130000,1671616135000,1671616140000,1671616145000,1671616150000,1671616155000,1671616160000,1671616165000,1671616170000,1671616175000,1671616180000,1671616185000,1671616190000,1671616195000,1671616200000,1671616205000,1671616210000,1671616215000,1671616220000,1671616225000,1671616230000,1671616235000,1671616240000,1671616245000,1671616250000,1671616255000,1671616260000,1671616265000,1671616270000,1671616275000,1671616280000,1671616285000,1671616290000,1671616295000,1671616300000,1671616305000,1671616310000,1671616315000,1671616320000,1671616325000,1671616330000,1671616335000,1671616340000,1671616345000,1671616350000,1671616355000,1671616360000,1671616365000,1671616370000,1671616375000,1671616380000,1671616385000,1671616390000,1671616395000,1671616400000,1671616405000,1671616410000,1671616415000,1671616420000,1671616425000,1671616430000,1671616435000,1671616440000,1671616445000,1671616450000,1671616455000,1671616460000,1671616465000,1671616470000,1671616475000,1671616480000,1671616485000,1671616490000,1671616495000,1671616500000,1671616505000,1671616510000,1671616515000,1671616520000,1671616525000,1671616530000,1671616535000,1671616540000,1671616545000,1671616550000,1671616555000,1671616560000,1671616565000,1671616570000,1671616575000,1671616580000,1671616585000,1671616590000,1671616595000,1671616600000,1671616605000,1671616610000,1671616615000,1671616620000,1671616625000,1671616630000,1671616635000,1671616640000,1671616645000,1671616650000,1671616655000,1671616660000,1671616665000,1671616670000,1671616675000,1671616680000,1671616685000,1671616690000,1671616695000,1671616700000,1671616705000,1671616710000,1671616715000,1671616720000,1671616725000,1671616730000,1671616735000,1671616740000,1671616745000,1671616750000,1671616755000,1671616760000,1671616765000,1671616770000,1671616775000,1671616780000,1671616785000,1671616790000,1671616795000,1671616800000,1671616805000,1671616810000,1671616815000,1671616820000,1671616825000,1671616830000,1671616835000,1671616840000,1671616845000,1671616850000,1671616855000,1671616860000,1671616865000,1671616870000,1671616875000,1671616880000,1671616885000,1671616890000,1671616895000,1671616900000,1671616905000,1671616910000,1671616915000,1671616920000,1671616925000,1671616930000,1671616935000,1671616940000,1671616945000,1671616950000,1671616955000,1671616960000,1671616965000,1671616970000,1671616975000,1671616980000,1671616985000,1671616990000,1671616995000,1671617000000,1671617005000,1671617010000,1671617015000,1671617020000,1671617025000,1671617030000,1671617035000,1671617040000,1671617045000,1671617050000,1671617055000,1671617060000,1671617065000,1671617070000,1671617075000,1671617080000,1671617085000,1671617090000,1671617095000,1671617100000,1671617105000,1671617110000,1671617115000,1671617120000,1671617125000,1671617130000,1671617135000,1671617140000,1671617145000,1671617150000,1671617155000,1671617160000,1671617165000,1671617170000,1671617175000,1671617180000,1671617185000,1671617190000,1671617195000,1671617200000,1671617205000,1671617210000,1671617215000,1671617220000,1671617225000,1671617230000,1671617235000,1671617240000,1671617245000,1671617250000,1671617255000,1671617260000,1671617265000,1671617270000,1671617275000,1671617280000,1671617285000,1671617290000,1671617295000,1671617300000,1671617305000,1671617310000,1671617315000,1671617320000,1671617325000,1671617330000,1671617335000,1671617340000,1671617345000,1671617350000,1671617355000,1671617360000,1671617365000,1671617370000,1671617375000,1671617380000,1671617385000,1671617390000,1671617395000,1671617400000,1671617405000,1671617410000,1671617415000,1671617420000,1671617425000,1671617430000,1671617435000,1671617440000,1671617445000,1671617450000,1671617455000,1671617460000,1671617465000,1671617470000,1671617475000,1671617480000,1671617485000,1671617490000,1671617495000,1671617500000,1671617505000,1671617510000,1671617515000,1671617520000,1671617525000,1671617530000,1671617535000,1671617540000,1671617545000,1671617550000,1671617555000,1671617560000,1671617565000,1671617570000,1671617575000,1671617580000,1671617585000,1671617590000,1671617595000,1671617600000,1671617605000,1671617610000,1671617615000,1671617620000,1671617625000,1671617630000,1671617635000,1671617640000,1671617645000,1671617650000,1671617655000,1671617660000,1671617665000,1671617670000,1671617675000,1671617680000,1671617685000,1671617690000,1671617695000,1671617700000,1671617705000,1671617710000,1671617715000,1671617720000,1671617725000,1671617730000,1671617735000,1671617740000,1671617745000,1671617750000,1671617755000,1671617760000,1671617765000,1671617770000,1671617775000,1671617780000,1671617785000,1671617790000,1671617795000,1671617800000,1671617805000,1671617810000,1671617815000,1671617820000,1671617825000,1671617830000,1671617835000,1671617840000,1671617845000,1671617850000,1671617855000,1671617860000,1671617865000,1671617870000,1671617875000,1671617880000,1671617885000,1671617890000,1671617895000,1671617900000,1671617905000,1671617910000,1671617915000,1671617920000,1671617925000,1671617930000,1671617935000,1671617940000,1671617945000,1671617950000,1671617955000,1671617960000,1671617965000,1671617970000,1671617975000,1671617980000,1671617985000,1671617990000,1671617995000,1671618000000,1671618005000,1671618010000,1671618015000,1671618020000,1671618025000,1671618030000,1671618035000,1671618040000,1671618045000,1671618050000,1671618055000,1671618060000,1671618065000,1671618070000,1671618075000,1671618080000,1671618085000,1671618090000,1671618095000,1671618100000,1671618105000,1671618110000,1671618115000,1671618120000,1671618125000,1671618130000,1671618135000,1671618140000,1671618145000,1671618150000,1671618155000,1671618160000,1671618165000,1671618170000,1671618175000,1671618180000,1671618185000,1671618190000,1671618195000,1671618200000,1671618205000,1671618210000,1671618215000,1671618220000,1671618225000,1671618230000,1671618235000,1671618240000,1671618245000,1671618250000,1671618255000,1671618260000,1671618265000,1671618270000,1671618275000,1671618280000,1671618285000,1671618290000,1671618295000,1671618300000,1671618305000,1671618310000,1671618315000,1671618320000,1671618325000,1671618330000,1671618335000,1671618340000,1671618345000,1671618350000,1671618355000,1671618360000,1671618365000,1671618370000,1671618375000,1671618380000,1671618385000,1671618390000,1671618395000,1671618400000,1671618405000,1671618410000,1671618415000,1671618420000,1671618425000,1671618430000,1671618435000,1671618440000,1671618445000,1671618450000,1671618455000,1671618460000,1671618465000,1671618470000,1671618475000,1671618480000,1671618485000,1671618490000,1671618495000,1671618500000,1671618505000,1671618510000,1671618515000,1671618520000,1671618525000,1671618530000,1671618535000,1671618540000,1671618545000,1671618550000,1671618555000,1671618560000,1671618565000,1671618570000,1671618575000,1671618580000,1671618585000,1671618590000,1671618595000,1671618600000,1671618605000,1671618610000,1671618615000,1671618620000,1671618625000,1671618630000,1671618635000,1671618640000,1671618645000,1671618650000,1671618655000,1671618660000,1671618665000,1671618670000,1671618675000,1671618680000,1671618685000,1671618690000,1671618695000,1671618700000,1671618705000,1671618710000,1671618715000,1671618720000,1671618725000,1671618730000,1671618735000,1671618740000,1671618745000,1671618750000,1671618755000,1671618760000,1671618765000,1671618770000,1671618775000,1671618780000,1671618785000,1671618790000,1671618795000,1671618800000,1671618805000,1671618810000,1671618815000,1671618820000,1671618825000,1671618830000,1671618835000,1671618840000,1671618845000,1671618850000,1671618855000,1671618860000,1671618865000,1671618870000,1671618875000,1671618880000,1671618885000,1671618890000,1671618895000,1671618900000,1671618905000,1671618910000,1671618915000,1671618920000,1671618925000,1671618930000,1671618935000,1671618940000,1671618945000,1671618950000,1671618955000,1671618960000,1671618965000,1671618970000,1671618975000,1671618980000,1671618985000,1671618990000,1671618995000,1671619000000,1671619005000,1671619010000,1671619015000,1671619020000,1671619025000,1671619030000,1671619035000,1671619040000,1671619045000,1671619050000,1671619055000,1671619060000,1671619065000,1671619070000,1671619075000,1671619080000,1671619085000,1671619090000,1671619095000,1671619100000,1671619105000,1671619110000,1671619115000,1671619120000,1671619125000,1671619130000,1671619135000,1671619140000,1671619145000,1671619150000,1671619155000,1671619160000,1671619165000,1671619170000,1671619175000,1671619180000,1671619185000,1671619190000,1671619195000,1671619200000,1671619205000,1671619210000,1671619215000,1671619220000,1671619225000,1671619230000,1671619235000,1671619240000,1671619245000,1671619250000,1671619255000,1671619260000,1671619265000,1671619270000,1671619275000,1671619280000,1671619285000,1671619290000,1671619295000,1671619300000,1671619305000,1671619310000,1671619315000,1671619320000,1671619325000,1671619330000,1671619335000,1671619340000,1671619345000,1671619350000,1671619355000,1671619360000,1671619365000,1671619370000,1671619375000,1671619380000,1671619385000,1671619390000,1671619395000,1671619400000,1671619405000,1671619410000,1671619415000,1671619420000,1671619425000,1671619430000,1671619435000,1671619440000,1671619445000,1671619450000,1671619455000,1671619460000,1671619465000,1671619470000,1671619475000,1671619480000,1671619485000,1671619490000,1671619495000,1671619500000,1671619505000,1671619510000,1671619515000,1671619520000,1671619525000,1671619530000,1671619535000,1671619540000,1671619545000,1671619550000,1671619555000,1671619560000,1671619565000,1671619570000,1671619575000,1671619580000,1671619585000,1671619590000,1671619595000,1671619600000,1671619605000,1671619610000,1671619615000,1671619620000,1671619625000,1671619630000,1671619635000,1671619640000,1671619645000,1671619650000,1671619655000,1671619660000,1671619665000,1671619670000,1671619675000,1671619680000,1671619685000,1671619690000,1671619695000,1671619700000,1671619705000,1671619710000,1671619715000,1671619720000,1671619725000,1671619730000,1671619735000,1671619740000,1671619745000,1671619750000,1671619755000,1671619760000,1671619765000,1671619770000,1671619775000,1671619780000,1671619785000,1671619790000,1671619795000,1671619800000,1671619805000,1671619810000,1671619815000,1671619820000,1671619825000,1671619830000,1671619835000,1671619840000,1671619845000,1671619850000,1671619855000,1671619860000,1671619865000,1671619870000,1671619875000,1671619880000,1671619885000,1671619890000,1671619895000,1671619900000,1671619905000,1671619910000,1671619915000,1671619920000,1671619925000,1671619930000,1671619935000,1671619940000,1671619945000,1671619950000,1671619955000,1671619960000,1671619965000,1671619970000,1671619975000,1671619980000,1671619985000,1671619990000,1671619995000,1671620000000,1671620005000,1671620010000,1671620015000,1671620020000,1671620025000,1671620030000,1671620035000,1671620040000,1671620045000,1671620050000,1671620055000,1671620060000,1671620065000,1671620070000,1671620075000,1671620080000,1671620085000,1671620090000,1671620095000,1671620100000,1671620105000,1671620110000,1671620115000,1671620120000,1671620125000,1671620130000,1671620135000,1671620140000,1671620145000,1671620150000,1671620155000,1671620160000,1671620165000,1671620170000,1671620175000,1671620180000,1671620185000,1671620190000,1671620195000,1671620200000,1671620205000,1671620210000,1671620215000,1671620220000,1671620225000,1671620230000,1671620235000,1671620240000,1671620245000,1671620250000,1671620255000,1671620260000,1671620265000,1671620270000,1671620275000,1671620280000,1671620285000,1671620290000,1671620295000,1671620300000,1671620305000,1671620310000,1671620315000,1671620320000,1671620325000,1671620330000,1671620335000,1671620340000,1671620345000,1671620350000,1671620355000,1671620360000,1671620365000,1671620370000,1671620375000,1671620380000,1671620385000,1671620390000,1671620395000,1671620400000,1671620405000,1671620410000,1671620415000,1671620420000,1671620425000,1671620430000,1671620435000,1671620440000,1671620445000,1671620450000,1671620455000,1671620460000,1671620465000,1671620470000,1671620475000,1671620480000,1671620485000,1671620490000,1671620495000,1671620500000,1671620505000],"series":[{"query_index":0,"unit":[{"plural":"percent","scale_factor":1.0,"id":17,"short_name":"%","family":"percentage","name":"percent"},null],"group_tags":[]}]}}}' + code: 200 + duration: '' + headers: + Content-Type: + - application/json + status: 200 OK +version: 1 diff --git a/tests/scenarios/features/v2/metrics.feature b/tests/scenarios/features/v2/metrics.feature index 0d46ae6b31f..4fdbb5c9eca 100644 --- a/tests/scenarios/features/v2/metrics.feature +++ b/tests/scenarios/features/v2/metrics.feature @@ -1,13 +1,13 @@ @endpoint(metrics) @endpoint(metrics-v2) Feature: Metrics The metrics endpoint allows you to: - Post metrics data so it can be - graphed on Datadog’s dashboards - Query metrics from any time period - - Modify tag configurations for metrics - View tags and volumes for metrics - **Note**: A graph can only contain a set number of points and as the - timeframe over which a metric is viewed increases, aggregation between - points occurs to stay below that set number. The Post, Patch, and Delete - `manage_tags` API methods can only be performed by a user who has the - `Manage Tags for Metrics` permission. + graphed on Datadog’s dashboards - Query metrics from any time period + (timeseries and scalar) - Modify tag configurations for metrics - View + tags and volumes for metrics **Note**: A graph can only contain a set + number of points and as the timeframe over which a metric is viewed + increases, aggregation between points occurs to stay below that set + number. The Post, Patch, and Delete `manage_tags` API methods can only be + performed by a user who has the `Manage Tags for Metrics` permission. Background: Given a valid "apiKeyAuth" key in the system @@ -214,6 +214,24 @@ Feature: Metrics Then the response status is 200 Success And the response "data.id" has the same value as "metric_tag_configuration.data.id" + @team:DataDog/metrics-query + Scenario: Scalar cross product query returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And operation "QueryScalarData" enabled + And new "QueryScalarData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a+b", "limit": {"count": 10, "order": "desc"}}], "from": 1568899800000, "queries": [{"aggregator": "avg", "data_source": "metrics", "query": "avg:system.cpu.user{*}", "name": "a"}], "to": 1568923200000}, "type": "scalar_request"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/metrics-query + Scenario: Scalar cross product query returns "OK" response + Given a valid "appKeyAuth" key in the system + And operation "QueryScalarData" enabled + And new "QueryScalarData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": 1671612804000, "queries": [{"aggregator": "avg", "data_source": "metrics", "query": "avg:system.cpu.user{*}", "name": "a"}], "to": 1671620004000}, "type": "scalar_request"}} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/metrics-intake @team:DataDog/metrics-query Scenario: Submit metrics returns "Bad Request" response Given new "SubmitMetrics" request @@ -267,6 +285,24 @@ Feature: Metrics When the request is sent Then the response status is 200 Success + @team:DataDog/metrics-query + Scenario: Timeseries cross product query returns "Bad Request" response + Given a valid "appKeyAuth" key in the system + And operation "QueryTimeseriesData" enabled + And new "QueryTimeseriesData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a+b", "limit": {"count": 10, "order": "desc"}}], "from": {{ timestamp('now - 1h') }}, "interval": 5000, "queries": [{"data_source": "metrics", "query": "avg:system.cpu.user{*}"}], "to": {{ timestamp('now') }}}, "type": "timeseries_rquest"}} + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/metrics-query + Scenario: Timeseries cross product query returns "OK" response + Given a valid "appKeyAuth" key in the system + And operation "QueryTimeseriesData" enabled + And new "QueryTimeseriesData" request + And body with value {"data": {"attributes": {"formulas": [{"formula": "a", "limit": {"count": 10, "order": "desc"}}], "from": 1671612804000, "interval": 5000, "queries": [{"data_source": "metrics", "query": "avg:system.cpu.user{*}", "name": "a"}], "to": 1671620004000}, "type": "timeseries_request"}} + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/points-aggregation Scenario: Update a tag configuration returns "Bad Request" response Given a valid "appKeyAuth" key in the system diff --git a/tests/scenarios/features/v2/undo.json b/tests/scenarios/features/v2/undo.json index a87c568fb74..74c47a214c0 100644 --- a/tests/scenarios/features/v2/undo.json +++ b/tests/scenarios/features/v2/undo.json @@ -591,6 +591,18 @@ "type": "safe" } }, + "QueryScalarData": { + "tag": "Metrics", + "undo": { + "type": "idempotent" + } + }, + "QueryTimeseriesData": { + "tag": "Metrics", + "undo": { + "type": "idempotent" + } + }, "ListRoles": { "tag": "Roles", "undo": {