From 6842ccea3e163871672989c80d8e11af6202d1be Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Wed, 22 Dec 2021 12:21:42 +0100 Subject: [PATCH 1/3] Fix Go date in MacOS --- run-go-tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/run-go-tests.sh b/run-go-tests.sh index 8f34c8e1311..8eac022e827 100755 --- a/run-go-tests.sh +++ b/run-go-tests.sh @@ -20,7 +20,7 @@ else RUN=$(echo $1 | sed 's/-test.run=//') if [[ ${RUN} =~ ${RE_TEST} ]] && [[ ! ${RUN} =~ ${RE_SCENARIO} ]]; then TEST=$(echo $RUN | tr -d '$^') - echo "{\"Time\":\"$(date --rfc-3339=ns | tr ' ' 'T')\",\"Action\":\"skip\",\"Package\":\"$2\",\"Test\":\"${TEST//\"/\\\"}\",\"Elapsed\":0}" + echo "{\"Time\":\"$(date -u +'%Y-%m-%dT%H:%M:%SZ')\",\"Action\":\"skip\",\"Package\":\"$2\",\"Test\":\"${TEST//\"/\\\"}\",\"Elapsed\":0}" else if [[ ${RERECORD_FAILED_TESTS} == "true" ]]; then RECORD=true "${CMD[@]}" -run "$RUN" "$2" From cde061f66175f861c23042d79a322b099582535f Mon Sep 17 00:00:00 2001 From: Jiri Kuncar Date: Wed, 22 Dec 2021 17:15:32 +0100 Subject: [PATCH 2/3] fix string to []interface{} --- tests/scenarios/scenarios.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/scenarios/scenarios.go b/tests/scenarios/scenarios.go index cea26e85937..6e826e85146 100644 --- a/tests/scenarios/scenarios.go +++ b/tests/scenarios/scenarios.go @@ -437,7 +437,13 @@ func stringToType(s string, t interface{}) (interface{}, error) { return strconv.Unquote(s) case bool: return strconv.ParseBool(s) - case map[string]interface{}, []interface{}: + case []interface{}: + var res []interface{} + if err := json.Unmarshal([]byte(s), &res); err != nil { + return nil, fmt.Errorf("error converting %s to %T: %v", s, t, err) + } + return res, nil + case map[string]interface{}: var res map[string]interface{} if err := json.Unmarshal([]byte(s), &res); err != nil { return nil, fmt.Errorf("error converting %s to %T: %v", s, t, err) From d2786667af55b49035731a98e82d67e0f7bbbfce Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Wed, 22 Dec 2021 22:14:03 +0000 Subject: [PATCH 3/3] Regenerate client from commit 861a3c0 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v1/openapi.yaml | 173 +++++++- api/v1/datadog/.openapi-generator/FILES | 10 + api/v1/datadog/README.md | 6 + api/v1/datadog/api_usage_metering.go | 213 +++++++++ api/v1/datadog/configuration.go | 1 + .../docs/HourlyUsageAttributionBody.md | 238 ++++++++++ .../docs/HourlyUsageAttributionMetadata.md | 56 +++ .../docs/HourlyUsageAttributionPagination.md | 56 +++ .../docs/HourlyUsageAttributionResponse.md | 82 ++++ .../docs/HourlyUsageAttributionUsageType.md | 37 ++ api/v1/datadog/docs/UsageMeteringApi.md | 90 ++++ .../model_hourly_usage_attribution_body.go | 416 ++++++++++++++++++ ...model_hourly_usage_attribution_metadata.go | 134 ++++++ ...del_hourly_usage_attribution_pagination.go | 135 ++++++ ...model_hourly_usage_attribution_response.go | 173 ++++++++ ...del_hourly_usage_attribution_usage_type.go | 128 ++++++ .../GetHourlyUsageAttribution.go | 29 ++ ...age_Attribution_returns_OK_response.freeze | 1 + ...Usage_Attribution_returns_OK_response.yaml | 61 +++ tests/scenarios/features/v1/undo.json | 6 + .../features/v1/usage_metering.feature | 18 + 22 files changed, 2061 insertions(+), 10 deletions(-) create mode 100644 api/v1/datadog/docs/HourlyUsageAttributionBody.md create mode 100644 api/v1/datadog/docs/HourlyUsageAttributionMetadata.md create mode 100644 api/v1/datadog/docs/HourlyUsageAttributionPagination.md create mode 100644 api/v1/datadog/docs/HourlyUsageAttributionResponse.md create mode 100644 api/v1/datadog/docs/HourlyUsageAttributionUsageType.md create mode 100644 api/v1/datadog/model_hourly_usage_attribution_body.go create mode 100644 api/v1/datadog/model_hourly_usage_attribution_metadata.go create mode 100644 api/v1/datadog/model_hourly_usage_attribution_pagination.go create mode 100644 api/v1/datadog/model_hourly_usage_attribution_response.go create mode 100644 api/v1/datadog/model_hourly_usage_attribution_usage_type.go create mode 100644 examples/v1/usage-metering/GetHourlyUsageAttribution.go create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Usage_Metering/Scenario_Get_Hourly_Usage_Attribution_returns_OK_response.freeze create mode 100644 tests/scenarios/cassettes/TestScenarios/v1/Feature_Usage_Metering/Scenario_Get_Hourly_Usage_Attribution_returns_OK_response.yaml diff --git a/.apigentools-info b/.apigentools-info index d02e9442722..91e3c08f384 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.5.1.dev2", - "regenerated": "2021-12-22 15:40:58.067618", - "spec_repo_commit": "fa551a3" + "regenerated": "2021-12-22 22:13:09.436091", + "spec_repo_commit": "861a3c0" }, "v2": { "apigentools_version": "1.5.1.dev2", - "regenerated": "2021-12-22 15:40:58.086721", - "spec_repo_commit": "fa551a3" + "regenerated": "2021-12-22 22:13:09.456795", + "spec_repo_commit": "861a3c0" } } } \ No newline at end of file diff --git a/.generator/schemas/v1/openapi.yaml b/.generator/schemas/v1/openapi.yaml index b79d6b81089..699e8069862 100644 --- a/.generator/schemas/v1/openapi.yaml +++ b/.generator/schemas/v1/openapi.yaml @@ -3365,6 +3365,95 @@ components: format: int64 type: integer type: object + HourlyUsageAttributionBody: + description: The usage for one set of tags for one hour. + properties: + hour: + description: The hour for the usage. + format: date-time + type: string + org_name: + description: The name of the organization. + type: string + public_id: + description: The organization public ID. + type: string + tag_config_source: + description: The source of the usage attribution tag configuration and the + selected tags in the format of `::://////`. + type: string + tags: + $ref: '#/components/schemas/UsageAttributionTagNames' + total_usage_sum: + description: Total product usage for the given tags within the hour. + format: double + type: number + updated_at: + description: Shows the most recent hour in the current month for all organizations + where usages are calculated. + type: string + usage_type: + $ref: '#/components/schemas/HourlyUsageAttributionUsageType' + type: object + HourlyUsageAttributionMetadata: + description: The object containing document metadata. + properties: + pagination: + $ref: '#/components/schemas/HourlyUsageAttributionPagination' + type: object + HourlyUsageAttributionPagination: + description: The metadata for the current pagination. + properties: + next_record_id: + description: The cursor to get the next results (if any). To make the next + request, use the same parameters and add `next_record_id`. + type: string + type: object + HourlyUsageAttributionResponse: + description: Response containing the hourly usage attribution by tag(s). + properties: + metadata: + $ref: '#/components/schemas/HourlyUsageAttributionMetadata' + usage: + description: Get the hourly usage attribution by tag(s). + items: + $ref: '#/components/schemas/HourlyUsageAttributionBody' + type: array + type: object + HourlyUsageAttributionUsageType: + description: Supported products for hourly usage attribution requests. + enum: + - api_usage + - apm_host_usage + - browser_usage + - container_usage + - custom_timeseries_usage + - fargate_usage + - functions_usage + - indexed_logs_usage + - infra_host_usage + - invocations_usage + - npm_host_usage + - profiled_container_usage + - profiled_host_usage + - snmp_usage + type: string + x-enum-varnames: + - API_USAGE + - APM_HOST_USAGE + - BROWSER_USAGE + - CONTAINER_USAGE + - CUSTOM_TIMESERIES_USAGE + - FARGATE_USAGE + - FUNCTIONS_USAGE + - INDEXED_LOGS_USAGE + - INFRA_HOST_USAGE + - INVOCATIONS_USAGE + - NPM_HOST_USAGE + - PROFILED_CONTAINER_USAGE + - PROFILED_HOST_USAGE + - SNMP_USAGE IFrameWidgetDefinition: description: The iframe widget allows you to embed a portion of any other web page on your dashboard. Only available on FREE layout dashboards. @@ -24261,7 +24350,7 @@ paths: summary: Get hourly usage for audit logs tags: - Usage Metering - x-menu-order: 31 + x-menu-order: 32 x-undo: type: safe /api/v1/usage/aws_lambda: @@ -24409,7 +24498,7 @@ paths: summary: Get hourly usage for CSPM tags: - Usage Metering - x-menu-order: 30 + x-menu-order: 31 x-undo: type: safe /api/v1/usage/cws: @@ -24464,7 +24553,7 @@ paths: summary: Get hourly usage for Cloud Workload Security tags: - Usage Metering - x-menu-order: 32 + x-menu-order: 33 x-undo: type: safe /api/v1/usage/dbm: @@ -24514,7 +24603,7 @@ paths: summary: Get hourly usage for Database Monitoring tags: - Usage Metering - x-menu-order: 33 + x-menu-order: 34 x-undo: type: safe /api/v1/usage/fargate: @@ -24623,6 +24712,78 @@ paths: x-menu-order: 1 x-undo: type: safe + /api/v1/usage/hourly-attribution: + get: + description: Get Hourly Usage Attribution. + operationId: GetHourlyUsageAttribution + parameters: + - description: 'Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` + for usage beginning at this hour.' + in: query + name: start_hr + required: true + schema: + format: date-time + type: string + - description: 'Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` + for usage ending + + **before** this hour.' + in: query + name: end_hr + required: false + schema: + format: date-time + type: string + - description: Usage type to retrieve. + in: query + name: usage_type + required: true + schema: + $ref: '#/components/schemas/HourlyUsageAttributionUsageType' + - description: List following results with a next_record_id provided in the + previous query. + in: query + name: next_record_id + required: false + schema: + type: string + - description: Comma separated list of tags used to group usage. If no value + is provided the usage will not be broken down by tags. + in: query + name: tag_breakdown_keys + required: false + schema: + type: string + responses: + '200': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/HourlyUsageAttributionResponse' + description: OK + '403': + content: + application/json;datetime-format=rfc3339: + schema: + $ref: '#/components/schemas/APIErrorResponse' + description: Forbidden - User is not authorized + '429': + $ref: '#/components/responses/TooManyRequestsResponse' + security: + - apiKeyAuth: [] + appKeyAuth: [] + - AuthZ: + - usage_read + summary: Get Hourly Usage Attribution + tags: + - Usage Metering + x-menu-order: 30 + x-undo: + type: safe + x-unstable: '**Note**: This endpoint is in public beta. + + If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).' /api/v1/usage/incident-management: get: description: Get hourly usage for incident management. @@ -25218,7 +25379,7 @@ paths: summary: Get hourly usage for RUM Units tags: - Usage Metering - x-menu-order: 35 + x-menu-order: 36 x-undo: type: safe /api/v1/usage/rum_sessions: @@ -25328,7 +25489,7 @@ paths: summary: Get hourly usage for Sensitive Data Scanner tags: - Usage Metering - x-menu-order: 34 + x-menu-order: 35 x-undo: type: safe /api/v1/usage/snmp: diff --git a/api/v1/datadog/.openapi-generator/FILES b/api/v1/datadog/.openapi-generator/FILES index c4ea4fa160c..e7ed3ba0f7a 100644 --- a/api/v1/datadog/.openapi-generator/FILES +++ b/api/v1/datadog/.openapi-generator/FILES @@ -182,6 +182,11 @@ docs/HostMuteSettings.md docs/HostTags.md docs/HostTotals.md docs/HostsApi.md +docs/HourlyUsageAttributionBody.md +docs/HourlyUsageAttributionMetadata.md +docs/HourlyUsageAttributionPagination.md +docs/HourlyUsageAttributionResponse.md +docs/HourlyUsageAttributionUsageType.md docs/IFrameWidgetDefinition.md docs/IFrameWidgetDefinitionType.md docs/IPPrefixesAPI.md @@ -850,6 +855,11 @@ model_host_mute_response.go model_host_mute_settings.go model_host_tags.go model_host_totals.go +model_hourly_usage_attribution_body.go +model_hourly_usage_attribution_metadata.go +model_hourly_usage_attribution_pagination.go +model_hourly_usage_attribution_response.go +model_hourly_usage_attribution_usage_type.go model_http_log_error.go model_http_log_item.go model_http_method.go diff --git a/api/v1/datadog/README.md b/api/v1/datadog/README.md index 0511045115f..2c810df8f88 100644 --- a/api/v1/datadog/README.md +++ b/api/v1/datadog/README.md @@ -240,6 +240,7 @@ Class | Method | HTTP request | Description *TagsApi* | [**ListHostTags**](docs/TagsApi.md#listhosttags) | **Get** /api/v1/tags/hosts | Get Tags *TagsApi* | [**UpdateHostTags**](docs/TagsApi.md#updatehosttags) | **Put** /api/v1/tags/hosts/{host_name} | Update host tags *UsageMeteringApi* | [**GetDailyCustomReports**](docs/UsageMeteringApi.md#getdailycustomreports) | **Get** /api/v1/daily_custom_reports | Get the list of available daily custom reports +*UsageMeteringApi* | [**GetHourlyUsageAttribution**](docs/UsageMeteringApi.md#gethourlyusageattribution) | **Get** /api/v1/usage/hourly-attribution | Get Hourly Usage Attribution *UsageMeteringApi* | [**GetIncidentManagement**](docs/UsageMeteringApi.md#getincidentmanagement) | **Get** /api/v1/usage/incident-management | Get hourly usage for incident management *UsageMeteringApi* | [**GetIngestedSpans**](docs/UsageMeteringApi.md#getingestedspans) | **Get** /api/v1/usage/ingested-spans | Get hourly usage for ingested spans *UsageMeteringApi* | [**GetMonthlyCustomReports**](docs/UsageMeteringApi.md#getmonthlycustomreports) | **Get** /api/v1/monthly_custom_reports | Get the list of available monthly custom reports @@ -429,6 +430,11 @@ Class | Method | HTTP request | Description - [HostMuteSettings](docs/HostMuteSettings.md) - [HostTags](docs/HostTags.md) - [HostTotals](docs/HostTotals.md) + - [HourlyUsageAttributionBody](docs/HourlyUsageAttributionBody.md) + - [HourlyUsageAttributionMetadata](docs/HourlyUsageAttributionMetadata.md) + - [HourlyUsageAttributionPagination](docs/HourlyUsageAttributionPagination.md) + - [HourlyUsageAttributionResponse](docs/HourlyUsageAttributionResponse.md) + - [HourlyUsageAttributionUsageType](docs/HourlyUsageAttributionUsageType.md) - [IFrameWidgetDefinition](docs/IFrameWidgetDefinition.md) - [IFrameWidgetDefinitionType](docs/IFrameWidgetDefinitionType.md) - [IPPrefixesAPI](docs/IPPrefixesAPI.md) diff --git a/api/v1/datadog/api_usage_metering.go b/api/v1/datadog/api_usage_metering.go index eeaf7220442..b1515e65e9c 100644 --- a/api/v1/datadog/api_usage_metering.go +++ b/api/v1/datadog/api_usage_metering.go @@ -240,6 +240,219 @@ func (a *UsageMeteringApiService) getDailyCustomReportsExecute(r apiGetDailyCust return localVarReturnValue, localVarHTTPResponse, nil } +type apiGetHourlyUsageAttributionRequest struct { + ctx _context.Context + ApiService *UsageMeteringApiService + startHr *time.Time + usageType *HourlyUsageAttributionUsageType + endHr *time.Time + nextRecordId *string + tagBreakdownKeys *string +} + +type GetHourlyUsageAttributionOptionalParameters struct { + EndHr *time.Time + NextRecordId *string + TagBreakdownKeys *string +} + +func NewGetHourlyUsageAttributionOptionalParameters() *GetHourlyUsageAttributionOptionalParameters { + this := GetHourlyUsageAttributionOptionalParameters{} + return &this +} +func (r *GetHourlyUsageAttributionOptionalParameters) WithEndHr(endHr time.Time) *GetHourlyUsageAttributionOptionalParameters { + r.EndHr = &endHr + return r +} +func (r *GetHourlyUsageAttributionOptionalParameters) WithNextRecordId(nextRecordId string) *GetHourlyUsageAttributionOptionalParameters { + r.NextRecordId = &nextRecordId + return r +} +func (r *GetHourlyUsageAttributionOptionalParameters) WithTagBreakdownKeys(tagBreakdownKeys string) *GetHourlyUsageAttributionOptionalParameters { + r.TagBreakdownKeys = &tagBreakdownKeys + return r +} + +/* + * GetHourlyUsageAttribution Get Hourly Usage Attribution + * Get Hourly Usage Attribution. + */ +func (a *UsageMeteringApiService) GetHourlyUsageAttribution(ctx _context.Context, startHr time.Time, usageType HourlyUsageAttributionUsageType, o ...GetHourlyUsageAttributionOptionalParameters) (HourlyUsageAttributionResponse, *_nethttp.Response, error) { + req := apiGetHourlyUsageAttributionRequest{ + ApiService: a, + ctx: ctx, + startHr: &startHr, + usageType: &usageType, + } + + if len(o) > 1 { + var localVarReturnValue HourlyUsageAttributionResponse + return localVarReturnValue, nil, reportError("only one argument of type GetHourlyUsageAttributionOptionalParameters is allowed") + } + + if o != nil { + req.endHr = o[0].EndHr + req.nextRecordId = o[0].NextRecordId + req.tagBreakdownKeys = o[0].TagBreakdownKeys + } + + return req.ApiService.getHourlyUsageAttributionExecute(req) +} + +/* + * Execute executes the request + * @return HourlyUsageAttributionResponse + */ +func (a *UsageMeteringApiService) getHourlyUsageAttributionExecute(r apiGetHourlyUsageAttributionRequest) (HourlyUsageAttributionResponse, *_nethttp.Response, error) { + var ( + localVarHTTPMethod = _nethttp.MethodGet + localVarPostBody interface{} + localVarFormFileName string + localVarFileName string + localVarFileBytes []byte + localVarReturnValue HourlyUsageAttributionResponse + ) + + operationId := "GetHourlyUsageAttribution" + if r.ApiService.client.cfg.IsUnstableOperationEnabled(operationId) { + _log.Printf("WARNING: Using unstable operation '%s'", operationId) + } else { + return localVarReturnValue, nil, GenericOpenAPIError{error: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)} + } + + localBasePath, err := a.client.cfg.ServerURLWithContext(r.ctx, "UsageMeteringApiService.GetHourlyUsageAttribution") + if err != nil { + return localVarReturnValue, nil, GenericOpenAPIError{error: err.Error()} + } + + localVarPath := localBasePath + "/api/v1/usage/hourly-attribution" + + localVarHeaderParams := make(map[string]string) + localVarQueryParams := _neturl.Values{} + localVarFormParams := _neturl.Values{} + if r.startHr == nil { + return localVarReturnValue, nil, reportError("startHr is required and must be specified") + } + if r.usageType == nil { + return localVarReturnValue, nil, reportError("usageType is required and must be specified") + } + + localVarQueryParams.Add("start_hr", parameterToString(*r.startHr, "")) + if r.endHr != nil { + localVarQueryParams.Add("end_hr", parameterToString(*r.endHr, "")) + } + localVarQueryParams.Add("usage_type", parameterToString(*r.usageType, "")) + if r.nextRecordId != nil { + localVarQueryParams.Add("next_record_id", parameterToString(*r.nextRecordId, "")) + } + if r.tagBreakdownKeys != nil { + localVarQueryParams.Add("tag_breakdown_keys", parameterToString(*r.tagBreakdownKeys, "")) + } + // to determine the Content-Type header + localVarHTTPContentTypes := []string{} + + // set Content-Type header + localVarHTTPContentType := selectHeaderContentType(localVarHTTPContentTypes) + if localVarHTTPContentType != "" { + localVarHeaderParams["Content-Type"] = localVarHTTPContentType + } + + // to determine the Accept header + localVarHTTPHeaderAccepts := []string{"application/json;datetime-format=rfc3339", "application/json"} + + // set Accept header + localVarHTTPHeaderAccept := selectHeaderAccept(localVarHTTPHeaderAccepts) + if localVarHTTPHeaderAccept != "" { + localVarHeaderParams["Accept"] = localVarHTTPHeaderAccept + } + + // Set Operation-ID header for telemetry + localVarHeaderParams["DD-OPERATION-ID"] = "GetHourlyUsageAttribution" + + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["apiKeyAuth"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["DD-API-KEY"] = key + } + } + } + if r.ctx != nil { + // API Key Authentication + if auth, ok := r.ctx.Value(ContextAPIKeys).(map[string]APIKey); ok { + if apiKey, ok := auth["appKeyAuth"]; ok { + var key string + if apiKey.Prefix != "" { + key = apiKey.Prefix + " " + apiKey.Key + } else { + key = apiKey.Key + } + localVarHeaderParams["DD-APPLICATION-KEY"] = key + } + } + } + req, err := a.client.PrepareRequest(r.ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, localVarFormFileName, localVarFileName, localVarFileBytes) + if err != nil { + return localVarReturnValue, nil, err + } + + localVarHTTPResponse, err := a.client.CallAPI(req) + if err != nil || localVarHTTPResponse == nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + localVarBody, err := _ioutil.ReadAll(localVarHTTPResponse.Body) + localVarHTTPResponse.Body.Close() + localVarHTTPResponse.Body = _ioutil.NopCloser(bytes.NewBuffer(localVarBody)) + if err != nil { + return localVarReturnValue, localVarHTTPResponse, err + } + + if localVarHTTPResponse.StatusCode >= 300 { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: localVarHTTPResponse.Status, + } + if localVarHTTPResponse.StatusCode == 403 { + var v APIErrorResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.model = v + return localVarReturnValue, localVarHTTPResponse, newErr + } + if localVarHTTPResponse.StatusCode == 429 { + var v APIErrorResponse + err = a.client.decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr.error = err.Error() + return localVarReturnValue, localVarHTTPResponse, newErr + } + newErr.model = v + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + err = a.client.decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type")) + if err != nil { + newErr := GenericOpenAPIError{ + body: localVarBody, + error: err.Error(), + } + return localVarReturnValue, localVarHTTPResponse, newErr + } + + return localVarReturnValue, localVarHTTPResponse, nil +} + type apiGetIncidentManagementRequest struct { ctx _context.Context ApiService *UsageMeteringApiService diff --git a/api/v1/datadog/configuration.go b/api/v1/datadog/configuration.go index f6e7a9177ef..1da19dc077b 100644 --- a/api/v1/datadog/configuration.go +++ b/api/v1/datadog/configuration.go @@ -269,6 +269,7 @@ func NewConfiguration() *Configuration { "GetSLOCorrections": false, "GetSLOHistory": false, "GetDailyCustomReports": false, + "GetHourlyUsageAttribution": false, "GetMonthlyCustomReports": false, "GetSpecifiedDailyCustomReports": false, "GetSpecifiedMonthlyCustomReports": false, diff --git a/api/v1/datadog/docs/HourlyUsageAttributionBody.md b/api/v1/datadog/docs/HourlyUsageAttributionBody.md new file mode 100644 index 00000000000..70680f86ded --- /dev/null +++ b/api/v1/datadog/docs/HourlyUsageAttributionBody.md @@ -0,0 +1,238 @@ +# HourlyUsageAttributionBody + +## Properties + +Name | Type | Description | Notes +---- | ---- | ----------- | ------ +**Hour** | Pointer to **time.Time** | The hour for the usage. | [optional] +**OrgName** | Pointer to **string** | The name of the organization. | [optional] +**PublicId** | Pointer to **string** | The organization public ID. | [optional] +**TagConfigSource** | Pointer to **string** | The source of the usage attribution tag configuration and the selected tags in the format of `<source_org_name>:::<selected tag 1>///<selected tag 2>///<selected tag 3>`. | [optional] +**Tags** | Pointer to **map[string][]string** | Usage Summary by tag name. | [optional] +**TotalUsageSum** | Pointer to **float64** | Total product usage for the given tags within the hour. | [optional] +**UpdatedAt** | Pointer to **string** | Shows the most recent hour in the current month for all organizations where usages are calculated. | [optional] +**UsageType** | Pointer to [**HourlyUsageAttributionUsageType**](HourlyUsageAttributionUsageType.md) | | [optional] + +## Methods + +### NewHourlyUsageAttributionBody + +`func NewHourlyUsageAttributionBody() *HourlyUsageAttributionBody` + +NewHourlyUsageAttributionBody instantiates a new HourlyUsageAttributionBody 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. + +### NewHourlyUsageAttributionBodyWithDefaults + +`func NewHourlyUsageAttributionBodyWithDefaults() *HourlyUsageAttributionBody` + +NewHourlyUsageAttributionBodyWithDefaults instantiates a new HourlyUsageAttributionBody 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. + +### GetHour + +`func (o *HourlyUsageAttributionBody) GetHour() time.Time` + +GetHour returns the Hour field if non-nil, zero value otherwise. + +### GetHourOk + +`func (o *HourlyUsageAttributionBody) GetHourOk() (*time.Time, bool)` + +GetHourOk returns a tuple with the Hour field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetHour + +`func (o *HourlyUsageAttributionBody) SetHour(v time.Time)` + +SetHour sets Hour field to given value. + +### HasHour + +`func (o *HourlyUsageAttributionBody) HasHour() bool` + +HasHour returns a boolean if a field has been set. + +### GetOrgName + +`func (o *HourlyUsageAttributionBody) GetOrgName() string` + +GetOrgName returns the OrgName field if non-nil, zero value otherwise. + +### GetOrgNameOk + +`func (o *HourlyUsageAttributionBody) GetOrgNameOk() (*string, bool)` + +GetOrgNameOk returns a tuple with the OrgName field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetOrgName + +`func (o *HourlyUsageAttributionBody) SetOrgName(v string)` + +SetOrgName sets OrgName field to given value. + +### HasOrgName + +`func (o *HourlyUsageAttributionBody) HasOrgName() bool` + +HasOrgName returns a boolean if a field has been set. + +### GetPublicId + +`func (o *HourlyUsageAttributionBody) GetPublicId() string` + +GetPublicId returns the PublicId field if non-nil, zero value otherwise. + +### GetPublicIdOk + +`func (o *HourlyUsageAttributionBody) GetPublicIdOk() (*string, bool)` + +GetPublicIdOk returns a tuple with the PublicId field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetPublicId + +`func (o *HourlyUsageAttributionBody) SetPublicId(v string)` + +SetPublicId sets PublicId field to given value. + +### HasPublicId + +`func (o *HourlyUsageAttributionBody) HasPublicId() bool` + +HasPublicId returns a boolean if a field has been set. + +### GetTagConfigSource + +`func (o *HourlyUsageAttributionBody) GetTagConfigSource() string` + +GetTagConfigSource returns the TagConfigSource field if non-nil, zero value otherwise. + +### GetTagConfigSourceOk + +`func (o *HourlyUsageAttributionBody) GetTagConfigSourceOk() (*string, bool)` + +GetTagConfigSourceOk returns a tuple with the TagConfigSource field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetTagConfigSource + +`func (o *HourlyUsageAttributionBody) SetTagConfigSource(v string)` + +SetTagConfigSource sets TagConfigSource field to given value. + +### HasTagConfigSource + +`func (o *HourlyUsageAttributionBody) HasTagConfigSource() bool` + +HasTagConfigSource returns a boolean if a field has been set. + +### GetTags + +`func (o *HourlyUsageAttributionBody) GetTags() map[string][]string` + +GetTags returns the Tags field if non-nil, zero value otherwise. + +### GetTagsOk + +`func (o *HourlyUsageAttributionBody) GetTagsOk() (*map[string][]string, bool)` + +GetTagsOk returns a tuple with the Tags field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetTags + +`func (o *HourlyUsageAttributionBody) SetTags(v map[string][]string)` + +SetTags sets Tags field to given value. + +### HasTags + +`func (o *HourlyUsageAttributionBody) HasTags() bool` + +HasTags returns a boolean if a field has been set. + +### GetTotalUsageSum + +`func (o *HourlyUsageAttributionBody) GetTotalUsageSum() float64` + +GetTotalUsageSum returns the TotalUsageSum field if non-nil, zero value otherwise. + +### GetTotalUsageSumOk + +`func (o *HourlyUsageAttributionBody) GetTotalUsageSumOk() (*float64, bool)` + +GetTotalUsageSumOk returns a tuple with the TotalUsageSum field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetTotalUsageSum + +`func (o *HourlyUsageAttributionBody) SetTotalUsageSum(v float64)` + +SetTotalUsageSum sets TotalUsageSum field to given value. + +### HasTotalUsageSum + +`func (o *HourlyUsageAttributionBody) HasTotalUsageSum() bool` + +HasTotalUsageSum returns a boolean if a field has been set. + +### GetUpdatedAt + +`func (o *HourlyUsageAttributionBody) GetUpdatedAt() string` + +GetUpdatedAt returns the UpdatedAt field if non-nil, zero value otherwise. + +### GetUpdatedAtOk + +`func (o *HourlyUsageAttributionBody) GetUpdatedAtOk() (*string, bool)` + +GetUpdatedAtOk returns a tuple with the UpdatedAt field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetUpdatedAt + +`func (o *HourlyUsageAttributionBody) SetUpdatedAt(v string)` + +SetUpdatedAt sets UpdatedAt field to given value. + +### HasUpdatedAt + +`func (o *HourlyUsageAttributionBody) HasUpdatedAt() bool` + +HasUpdatedAt returns a boolean if a field has been set. + +### GetUsageType + +`func (o *HourlyUsageAttributionBody) GetUsageType() HourlyUsageAttributionUsageType` + +GetUsageType returns the UsageType field if non-nil, zero value otherwise. + +### GetUsageTypeOk + +`func (o *HourlyUsageAttributionBody) GetUsageTypeOk() (*HourlyUsageAttributionUsageType, bool)` + +GetUsageTypeOk returns a tuple with the UsageType field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetUsageType + +`func (o *HourlyUsageAttributionBody) SetUsageType(v HourlyUsageAttributionUsageType)` + +SetUsageType sets UsageType field to given value. + +### HasUsageType + +`func (o *HourlyUsageAttributionBody) HasUsageType() bool` + +HasUsageType returns a boolean if a field has been set. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api/v1/datadog/docs/HourlyUsageAttributionMetadata.md b/api/v1/datadog/docs/HourlyUsageAttributionMetadata.md new file mode 100644 index 00000000000..c2505349bb7 --- /dev/null +++ b/api/v1/datadog/docs/HourlyUsageAttributionMetadata.md @@ -0,0 +1,56 @@ +# HourlyUsageAttributionMetadata + +## Properties + +Name | Type | Description | Notes +---- | ---- | ----------- | ------ +**Pagination** | Pointer to [**HourlyUsageAttributionPagination**](HourlyUsageAttributionPagination.md) | | [optional] + +## Methods + +### NewHourlyUsageAttributionMetadata + +`func NewHourlyUsageAttributionMetadata() *HourlyUsageAttributionMetadata` + +NewHourlyUsageAttributionMetadata instantiates a new HourlyUsageAttributionMetadata 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. + +### NewHourlyUsageAttributionMetadataWithDefaults + +`func NewHourlyUsageAttributionMetadataWithDefaults() *HourlyUsageAttributionMetadata` + +NewHourlyUsageAttributionMetadataWithDefaults instantiates a new HourlyUsageAttributionMetadata 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. + +### GetPagination + +`func (o *HourlyUsageAttributionMetadata) GetPagination() HourlyUsageAttributionPagination` + +GetPagination returns the Pagination field if non-nil, zero value otherwise. + +### GetPaginationOk + +`func (o *HourlyUsageAttributionMetadata) GetPaginationOk() (*HourlyUsageAttributionPagination, bool)` + +GetPaginationOk returns a tuple with the Pagination field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetPagination + +`func (o *HourlyUsageAttributionMetadata) SetPagination(v HourlyUsageAttributionPagination)` + +SetPagination sets Pagination field to given value. + +### HasPagination + +`func (o *HourlyUsageAttributionMetadata) HasPagination() bool` + +HasPagination returns a boolean if a field has been set. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api/v1/datadog/docs/HourlyUsageAttributionPagination.md b/api/v1/datadog/docs/HourlyUsageAttributionPagination.md new file mode 100644 index 00000000000..4720a0d1a95 --- /dev/null +++ b/api/v1/datadog/docs/HourlyUsageAttributionPagination.md @@ -0,0 +1,56 @@ +# HourlyUsageAttributionPagination + +## Properties + +Name | Type | Description | Notes +---- | ---- | ----------- | ------ +**NextRecordId** | Pointer to **string** | The cursor to get the next results (if any). To make the next request, use the same parameters and add `next_record_id`. | [optional] + +## Methods + +### NewHourlyUsageAttributionPagination + +`func NewHourlyUsageAttributionPagination() *HourlyUsageAttributionPagination` + +NewHourlyUsageAttributionPagination instantiates a new HourlyUsageAttributionPagination 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. + +### NewHourlyUsageAttributionPaginationWithDefaults + +`func NewHourlyUsageAttributionPaginationWithDefaults() *HourlyUsageAttributionPagination` + +NewHourlyUsageAttributionPaginationWithDefaults instantiates a new HourlyUsageAttributionPagination 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. + +### GetNextRecordId + +`func (o *HourlyUsageAttributionPagination) GetNextRecordId() string` + +GetNextRecordId returns the NextRecordId field if non-nil, zero value otherwise. + +### GetNextRecordIdOk + +`func (o *HourlyUsageAttributionPagination) GetNextRecordIdOk() (*string, bool)` + +GetNextRecordIdOk returns a tuple with the NextRecordId field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetNextRecordId + +`func (o *HourlyUsageAttributionPagination) SetNextRecordId(v string)` + +SetNextRecordId sets NextRecordId field to given value. + +### HasNextRecordId + +`func (o *HourlyUsageAttributionPagination) HasNextRecordId() bool` + +HasNextRecordId returns a boolean if a field has been set. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api/v1/datadog/docs/HourlyUsageAttributionResponse.md b/api/v1/datadog/docs/HourlyUsageAttributionResponse.md new file mode 100644 index 00000000000..c703e92ad60 --- /dev/null +++ b/api/v1/datadog/docs/HourlyUsageAttributionResponse.md @@ -0,0 +1,82 @@ +# HourlyUsageAttributionResponse + +## Properties + +Name | Type | Description | Notes +---- | ---- | ----------- | ------ +**Metadata** | Pointer to [**HourlyUsageAttributionMetadata**](HourlyUsageAttributionMetadata.md) | | [optional] +**Usage** | Pointer to [**[]HourlyUsageAttributionBody**](HourlyUsageAttributionBody.md) | Get the hourly usage attribution by tag(s). | [optional] + +## Methods + +### NewHourlyUsageAttributionResponse + +`func NewHourlyUsageAttributionResponse() *HourlyUsageAttributionResponse` + +NewHourlyUsageAttributionResponse instantiates a new HourlyUsageAttributionResponse 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. + +### NewHourlyUsageAttributionResponseWithDefaults + +`func NewHourlyUsageAttributionResponseWithDefaults() *HourlyUsageAttributionResponse` + +NewHourlyUsageAttributionResponseWithDefaults instantiates a new HourlyUsageAttributionResponse 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. + +### GetMetadata + +`func (o *HourlyUsageAttributionResponse) GetMetadata() HourlyUsageAttributionMetadata` + +GetMetadata returns the Metadata field if non-nil, zero value otherwise. + +### GetMetadataOk + +`func (o *HourlyUsageAttributionResponse) GetMetadataOk() (*HourlyUsageAttributionMetadata, bool)` + +GetMetadataOk returns a tuple with the Metadata field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetMetadata + +`func (o *HourlyUsageAttributionResponse) SetMetadata(v HourlyUsageAttributionMetadata)` + +SetMetadata sets Metadata field to given value. + +### HasMetadata + +`func (o *HourlyUsageAttributionResponse) HasMetadata() bool` + +HasMetadata returns a boolean if a field has been set. + +### GetUsage + +`func (o *HourlyUsageAttributionResponse) GetUsage() []HourlyUsageAttributionBody` + +GetUsage returns the Usage field if non-nil, zero value otherwise. + +### GetUsageOk + +`func (o *HourlyUsageAttributionResponse) GetUsageOk() (*[]HourlyUsageAttributionBody, bool)` + +GetUsageOk returns a tuple with the Usage field if it's non-nil, zero value otherwise +and a boolean to check if the value has been set. + +### SetUsage + +`func (o *HourlyUsageAttributionResponse) SetUsage(v []HourlyUsageAttributionBody)` + +SetUsage sets Usage field to given value. + +### HasUsage + +`func (o *HourlyUsageAttributionResponse) HasUsage() bool` + +HasUsage returns a boolean if a field has been set. + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api/v1/datadog/docs/HourlyUsageAttributionUsageType.md b/api/v1/datadog/docs/HourlyUsageAttributionUsageType.md new file mode 100644 index 00000000000..14953b12807 --- /dev/null +++ b/api/v1/datadog/docs/HourlyUsageAttributionUsageType.md @@ -0,0 +1,37 @@ +# HourlyUsageAttributionUsageType + +## Enum + + +* `API_USAGE` (value: `"api_usage"`) + +* `APM_HOST_USAGE` (value: `"apm_host_usage"`) + +* `BROWSER_USAGE` (value: `"browser_usage"`) + +* `CONTAINER_USAGE` (value: `"container_usage"`) + +* `CUSTOM_TIMESERIES_USAGE` (value: `"custom_timeseries_usage"`) + +* `FARGATE_USAGE` (value: `"fargate_usage"`) + +* `FUNCTIONS_USAGE` (value: `"functions_usage"`) + +* `INDEXED_LOGS_USAGE` (value: `"indexed_logs_usage"`) + +* `INFRA_HOST_USAGE` (value: `"infra_host_usage"`) + +* `INVOCATIONS_USAGE` (value: `"invocations_usage"`) + +* `NPM_HOST_USAGE` (value: `"npm_host_usage"`) + +* `PROFILED_CONTAINER_USAGE` (value: `"profiled_container_usage"`) + +* `PROFILED_HOST_USAGE` (value: `"profiled_host_usage"`) + +* `SNMP_USAGE` (value: `"snmp_usage"`) + + +[[Back to Model list]](../README.md#documentation-for-models) [[Back to API list]](../README.md#documentation-for-api-endpoints) [[Back to README]](../README.md) + + diff --git a/api/v1/datadog/docs/UsageMeteringApi.md b/api/v1/datadog/docs/UsageMeteringApi.md index 8356afb6a83..4ad86c83b8e 100644 --- a/api/v1/datadog/docs/UsageMeteringApi.md +++ b/api/v1/datadog/docs/UsageMeteringApi.md @@ -5,6 +5,7 @@ All URIs are relative to *https://api.datadoghq.com* Method | HTTP request | Description ------ | ------------ | ------------ [**GetDailyCustomReports**](UsageMeteringApi.md#GetDailyCustomReports) | **Get** /api/v1/daily_custom_reports | Get the list of available daily custom reports +[**GetHourlyUsageAttribution**](UsageMeteringApi.md#GetHourlyUsageAttribution) | **Get** /api/v1/usage/hourly-attribution | Get Hourly Usage Attribution [**GetIncidentManagement**](UsageMeteringApi.md#GetIncidentManagement) | **Get** /api/v1/usage/incident-management | Get hourly usage for incident management [**GetIngestedSpans**](UsageMeteringApi.md#GetIngestedSpans) | **Get** /api/v1/usage/ingested-spans | Get hourly usage for ingested spans [**GetMonthlyCustomReports**](UsageMeteringApi.md#GetMonthlyCustomReports) | **Get** /api/v1/monthly_custom_reports | Get the list of available monthly custom reports @@ -125,6 +126,95 @@ Name | Type | Description | Notes [[Back to README]](../README.md) +## GetHourlyUsageAttribution + +> HourlyUsageAttributionResponse GetHourlyUsageAttribution(ctx, startHr, usageType, datadog.GetHourlyUsageAttributionOptionalParameters{}) + +Get Hourly Usage Attribution. + +### Example + +```go +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + "time" + datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + + startHr := time.Now() // time.Time | Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage beginning at this hour. + usageType := datadog.HourlyUsageAttributionUsageType("api_usage") // HourlyUsageAttributionUsageType | Usage type to retrieve. + endHr := time.Now() // time.Time | Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage ending **before** this hour. (optional) + nextRecordId := "nextRecordId_example" // string | List following results with a next_record_id provided in the previous query. (optional) + tagBreakdownKeys := "tagBreakdownKeys_example" // string | Comma separated list of tags used to group usage. If no value is provided the usage will not be broken down by tags. (optional) + optionalParams := datadog.GetHourlyUsageAttributionOptionalParameters{ + EndHr: &endHr, + NextRecordId: &nextRecordId, + TagBreakdownKeys: &tagBreakdownKeys, + } + + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("GetHourlyUsageAttribution", true) + + apiClient := datadog.NewAPIClient(configuration) + resp, r, err := apiClient.UsageMeteringApi.GetHourlyUsageAttribution(ctx, startHr, usageType, optionalParams) + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetHourlyUsageAttribution`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + // response from `GetHourlyUsageAttribution`: HourlyUsageAttributionResponse + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from UsageMeteringApi.GetHourlyUsageAttribution:\n%s\n", responseContent) +} +``` + +### Required Parameters + + +Name | Type | Description | Notes +---- | ---- | ------------ | ------ +**ctx** | **context.Context** | Context for authentication, logging, cancellation, deadlines, tracing, etc. | +**startHr** | **time.Time** | Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage beginning at this hour. | | +**usageType** | [**HourlyUsageAttributionUsageType**](HourlyUsageAttributionUsageType.md) | Usage type to retrieve. | + + +### Optional Parameters + + +Other parameters are passed through a pointer to a GetHourlyUsageAttributionOptionalParameters struct. + + +Name | Type | Description | Notes +---- | ---- | ------------ | ------ +**endHr** | **time.Time** | Datetime in ISO-8601 format, UTC, precise to hour: `[YYYY-MM-DDThh]` for usage ending **before** this hour. | +**nextRecordId** | **string** | List following results with a next_record_id provided in the previous query. | +**tagBreakdownKeys** | **string** | Comma separated list of tags used to group usage. If no value is provided the usage will not be broken down by tags. | + +### Return type + +[**HourlyUsageAttributionResponse**](HourlyUsageAttributionResponse.md) + +### Authorization + +[AuthZ](../README.md#AuthZ), [apiKeyAuth](../README.md#apiKeyAuth), [appKeyAuth](../README.md#appKeyAuth) + +### HTTP request headers + +- **Content-Type**: Not defined +- **Accept**: application/json;datetime-format=rfc3339, application/json + +[[Back to top]](#) [[Back to API list]](../README.md#documentation-for-api-endpoints) +[[Back to Model list]](../README.md#documentation-for-models) +[[Back to README]](../README.md) + + ## GetIncidentManagement > UsageIncidentManagementResponse GetIncidentManagement(ctx, startHr, datadog.GetIncidentManagementOptionalParameters{}) diff --git a/api/v1/datadog/model_hourly_usage_attribution_body.go b/api/v1/datadog/model_hourly_usage_attribution_body.go new file mode 100644 index 00000000000..5c1d6a9faf9 --- /dev/null +++ b/api/v1/datadog/model_hourly_usage_attribution_body.go @@ -0,0 +1,416 @@ +/* + * 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. + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package datadog + +import ( + "encoding/json" + "time" +) + +// HourlyUsageAttributionBody The usage for one set of tags for one hour. +type HourlyUsageAttributionBody struct { + // The hour for the usage. + Hour *time.Time `json:"hour,omitempty"` + // The name of the organization. + OrgName *string `json:"org_name,omitempty"` + // The organization public ID. + PublicId *string `json:"public_id,omitempty"` + // The source of the usage attribution tag configuration and the selected tags in the format of `::://////`. + TagConfigSource *string `json:"tag_config_source,omitempty"` + // Usage Summary by tag name. + Tags *map[string][]string `json:"tags,omitempty"` + // Total product usage for the given tags within the hour. + TotalUsageSum *float64 `json:"total_usage_sum,omitempty"` + // Shows the most recent hour in the current month for all organizations where usages are calculated. + UpdatedAt *string `json:"updated_at,omitempty"` + UsageType *HourlyUsageAttributionUsageType `json:"usage_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:-` +} + +// NewHourlyUsageAttributionBody instantiates a new HourlyUsageAttributionBody 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 NewHourlyUsageAttributionBody() *HourlyUsageAttributionBody { + this := HourlyUsageAttributionBody{} + return &this +} + +// NewHourlyUsageAttributionBodyWithDefaults instantiates a new HourlyUsageAttributionBody 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 NewHourlyUsageAttributionBodyWithDefaults() *HourlyUsageAttributionBody { + this := HourlyUsageAttributionBody{} + return &this +} + +// GetHour returns the Hour field value if set, zero value otherwise. +func (o *HourlyUsageAttributionBody) GetHour() time.Time { + if o == nil || o.Hour == nil { + var ret time.Time + return ret + } + return *o.Hour +} + +// GetHourOk returns a tuple with the Hour field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HourlyUsageAttributionBody) GetHourOk() (*time.Time, bool) { + if o == nil || o.Hour == nil { + return nil, false + } + return o.Hour, true +} + +// HasHour returns a boolean if a field has been set. +func (o *HourlyUsageAttributionBody) HasHour() bool { + if o != nil && o.Hour != nil { + return true + } + + return false +} + +// SetHour gets a reference to the given time.Time and assigns it to the Hour field. +func (o *HourlyUsageAttributionBody) SetHour(v time.Time) { + o.Hour = &v +} + +// GetOrgName returns the OrgName field value if set, zero value otherwise. +func (o *HourlyUsageAttributionBody) GetOrgName() string { + if o == nil || o.OrgName == nil { + var ret string + return ret + } + return *o.OrgName +} + +// GetOrgNameOk returns a tuple with the OrgName field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HourlyUsageAttributionBody) GetOrgNameOk() (*string, bool) { + if o == nil || o.OrgName == nil { + return nil, false + } + return o.OrgName, true +} + +// HasOrgName returns a boolean if a field has been set. +func (o *HourlyUsageAttributionBody) HasOrgName() bool { + if o != nil && o.OrgName != nil { + return true + } + + return false +} + +// SetOrgName gets a reference to the given string and assigns it to the OrgName field. +func (o *HourlyUsageAttributionBody) SetOrgName(v string) { + o.OrgName = &v +} + +// GetPublicId returns the PublicId field value if set, zero value otherwise. +func (o *HourlyUsageAttributionBody) GetPublicId() string { + if o == nil || o.PublicId == nil { + var ret string + return ret + } + return *o.PublicId +} + +// GetPublicIdOk returns a tuple with the PublicId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HourlyUsageAttributionBody) GetPublicIdOk() (*string, bool) { + if o == nil || o.PublicId == nil { + return nil, false + } + return o.PublicId, true +} + +// HasPublicId returns a boolean if a field has been set. +func (o *HourlyUsageAttributionBody) HasPublicId() bool { + if o != nil && o.PublicId != nil { + return true + } + + return false +} + +// SetPublicId gets a reference to the given string and assigns it to the PublicId field. +func (o *HourlyUsageAttributionBody) SetPublicId(v string) { + o.PublicId = &v +} + +// GetTagConfigSource returns the TagConfigSource field value if set, zero value otherwise. +func (o *HourlyUsageAttributionBody) GetTagConfigSource() string { + if o == nil || o.TagConfigSource == nil { + var ret string + return ret + } + return *o.TagConfigSource +} + +// GetTagConfigSourceOk returns a tuple with the TagConfigSource field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HourlyUsageAttributionBody) GetTagConfigSourceOk() (*string, bool) { + if o == nil || o.TagConfigSource == nil { + return nil, false + } + return o.TagConfigSource, true +} + +// HasTagConfigSource returns a boolean if a field has been set. +func (o *HourlyUsageAttributionBody) HasTagConfigSource() bool { + if o != nil && o.TagConfigSource != nil { + return true + } + + return false +} + +// SetTagConfigSource gets a reference to the given string and assigns it to the TagConfigSource field. +func (o *HourlyUsageAttributionBody) SetTagConfigSource(v string) { + o.TagConfigSource = &v +} + +// GetTags returns the Tags field value if set, zero value otherwise. +func (o *HourlyUsageAttributionBody) GetTags() map[string][]string { + if o == nil || o.Tags == nil { + var ret map[string][]string + return ret + } + return *o.Tags +} + +// GetTagsOk returns a tuple with the Tags field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HourlyUsageAttributionBody) GetTagsOk() (*map[string][]string, bool) { + if o == nil || o.Tags == nil { + return nil, false + } + return o.Tags, true +} + +// HasTags returns a boolean if a field has been set. +func (o *HourlyUsageAttributionBody) HasTags() bool { + if o != nil && o.Tags != nil { + return true + } + + return false +} + +// SetTags gets a reference to the given map[string][]string and assigns it to the Tags field. +func (o *HourlyUsageAttributionBody) SetTags(v map[string][]string) { + o.Tags = &v +} + +// GetTotalUsageSum returns the TotalUsageSum field value if set, zero value otherwise. +func (o *HourlyUsageAttributionBody) GetTotalUsageSum() float64 { + if o == nil || o.TotalUsageSum == nil { + var ret float64 + return ret + } + return *o.TotalUsageSum +} + +// GetTotalUsageSumOk returns a tuple with the TotalUsageSum field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HourlyUsageAttributionBody) GetTotalUsageSumOk() (*float64, bool) { + if o == nil || o.TotalUsageSum == nil { + return nil, false + } + return o.TotalUsageSum, true +} + +// HasTotalUsageSum returns a boolean if a field has been set. +func (o *HourlyUsageAttributionBody) HasTotalUsageSum() bool { + if o != nil && o.TotalUsageSum != nil { + return true + } + + return false +} + +// SetTotalUsageSum gets a reference to the given float64 and assigns it to the TotalUsageSum field. +func (o *HourlyUsageAttributionBody) SetTotalUsageSum(v float64) { + o.TotalUsageSum = &v +} + +// GetUpdatedAt returns the UpdatedAt field value if set, zero value otherwise. +func (o *HourlyUsageAttributionBody) GetUpdatedAt() string { + if o == nil || o.UpdatedAt == nil { + var ret string + return ret + } + return *o.UpdatedAt +} + +// GetUpdatedAtOk returns a tuple with the UpdatedAt field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HourlyUsageAttributionBody) GetUpdatedAtOk() (*string, bool) { + if o == nil || o.UpdatedAt == nil { + return nil, false + } + return o.UpdatedAt, true +} + +// HasUpdatedAt returns a boolean if a field has been set. +func (o *HourlyUsageAttributionBody) HasUpdatedAt() bool { + if o != nil && o.UpdatedAt != nil { + return true + } + + return false +} + +// SetUpdatedAt gets a reference to the given string and assigns it to the UpdatedAt field. +func (o *HourlyUsageAttributionBody) SetUpdatedAt(v string) { + o.UpdatedAt = &v +} + +// GetUsageType returns the UsageType field value if set, zero value otherwise. +func (o *HourlyUsageAttributionBody) GetUsageType() HourlyUsageAttributionUsageType { + if o == nil || o.UsageType == nil { + var ret HourlyUsageAttributionUsageType + return ret + } + return *o.UsageType +} + +// GetUsageTypeOk returns a tuple with the UsageType field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HourlyUsageAttributionBody) GetUsageTypeOk() (*HourlyUsageAttributionUsageType, bool) { + if o == nil || o.UsageType == nil { + return nil, false + } + return o.UsageType, true +} + +// HasUsageType returns a boolean if a field has been set. +func (o *HourlyUsageAttributionBody) HasUsageType() bool { + if o != nil && o.UsageType != nil { + return true + } + + return false +} + +// SetUsageType gets a reference to the given HourlyUsageAttributionUsageType and assigns it to the UsageType field. +func (o *HourlyUsageAttributionBody) SetUsageType(v HourlyUsageAttributionUsageType) { + o.UsageType = &v +} + +func (o HourlyUsageAttributionBody) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Hour != nil { + toSerialize["hour"] = o.Hour + } + if o.OrgName != nil { + toSerialize["org_name"] = o.OrgName + } + if o.PublicId != nil { + toSerialize["public_id"] = o.PublicId + } + if o.TagConfigSource != nil { + toSerialize["tag_config_source"] = o.TagConfigSource + } + if o.Tags != nil { + toSerialize["tags"] = o.Tags + } + if o.TotalUsageSum != nil { + toSerialize["total_usage_sum"] = o.TotalUsageSum + } + if o.UpdatedAt != nil { + toSerialize["updated_at"] = o.UpdatedAt + } + if o.UsageType != nil { + toSerialize["usage_type"] = o.UsageType + } + return json.Marshal(toSerialize) +} + +func (o *HourlyUsageAttributionBody) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Hour *time.Time `json:"hour,omitempty"` + OrgName *string `json:"org_name,omitempty"` + PublicId *string `json:"public_id,omitempty"` + TagConfigSource *string `json:"tag_config_source,omitempty"` + Tags *map[string][]string `json:"tags,omitempty"` + TotalUsageSum *float64 `json:"total_usage_sum,omitempty"` + UpdatedAt *string `json:"updated_at,omitempty"` + UsageType *HourlyUsageAttributionUsageType `json:"usage_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.UsageType; v != nil && !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } + o.Hour = all.Hour + o.OrgName = all.OrgName + o.PublicId = all.PublicId + o.TagConfigSource = all.TagConfigSource + o.Tags = all.Tags + o.TotalUsageSum = all.TotalUsageSum + o.UpdatedAt = all.UpdatedAt + o.UsageType = all.UsageType + return nil +} + +type NullableHourlyUsageAttributionBody struct { + value *HourlyUsageAttributionBody + isSet bool +} + +func (v NullableHourlyUsageAttributionBody) Get() *HourlyUsageAttributionBody { + return v.value +} + +func (v *NullableHourlyUsageAttributionBody) Set(val *HourlyUsageAttributionBody) { + v.value = val + v.isSet = true +} + +func (v NullableHourlyUsageAttributionBody) IsSet() bool { + return v.isSet +} + +func (v *NullableHourlyUsageAttributionBody) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableHourlyUsageAttributionBody(val *HourlyUsageAttributionBody) *NullableHourlyUsageAttributionBody { + return &NullableHourlyUsageAttributionBody{value: val, isSet: true} +} + +func (v NullableHourlyUsageAttributionBody) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableHourlyUsageAttributionBody) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/v1/datadog/model_hourly_usage_attribution_metadata.go b/api/v1/datadog/model_hourly_usage_attribution_metadata.go new file mode 100644 index 00000000000..e44ae2013d8 --- /dev/null +++ b/api/v1/datadog/model_hourly_usage_attribution_metadata.go @@ -0,0 +1,134 @@ +/* + * 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. + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package datadog + +import ( + "encoding/json" +) + +// HourlyUsageAttributionMetadata The object containing document metadata. +type HourlyUsageAttributionMetadata struct { + Pagination *HourlyUsageAttributionPagination `json:"pagination,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:-` +} + +// NewHourlyUsageAttributionMetadata instantiates a new HourlyUsageAttributionMetadata 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 NewHourlyUsageAttributionMetadata() *HourlyUsageAttributionMetadata { + this := HourlyUsageAttributionMetadata{} + return &this +} + +// NewHourlyUsageAttributionMetadataWithDefaults instantiates a new HourlyUsageAttributionMetadata 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 NewHourlyUsageAttributionMetadataWithDefaults() *HourlyUsageAttributionMetadata { + this := HourlyUsageAttributionMetadata{} + return &this +} + +// GetPagination returns the Pagination field value if set, zero value otherwise. +func (o *HourlyUsageAttributionMetadata) GetPagination() HourlyUsageAttributionPagination { + if o == nil || o.Pagination == nil { + var ret HourlyUsageAttributionPagination + return ret + } + return *o.Pagination +} + +// GetPaginationOk returns a tuple with the Pagination field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HourlyUsageAttributionMetadata) GetPaginationOk() (*HourlyUsageAttributionPagination, bool) { + if o == nil || o.Pagination == nil { + return nil, false + } + return o.Pagination, true +} + +// HasPagination returns a boolean if a field has been set. +func (o *HourlyUsageAttributionMetadata) HasPagination() bool { + if o != nil && o.Pagination != nil { + return true + } + + return false +} + +// SetPagination gets a reference to the given HourlyUsageAttributionPagination and assigns it to the Pagination field. +func (o *HourlyUsageAttributionMetadata) SetPagination(v HourlyUsageAttributionPagination) { + o.Pagination = &v +} + +func (o HourlyUsageAttributionMetadata) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Pagination != nil { + toSerialize["pagination"] = o.Pagination + } + return json.Marshal(toSerialize) +} + +func (o *HourlyUsageAttributionMetadata) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Pagination *HourlyUsageAttributionPagination `json:"pagination,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.Pagination = all.Pagination + return nil +} + +type NullableHourlyUsageAttributionMetadata struct { + value *HourlyUsageAttributionMetadata + isSet bool +} + +func (v NullableHourlyUsageAttributionMetadata) Get() *HourlyUsageAttributionMetadata { + return v.value +} + +func (v *NullableHourlyUsageAttributionMetadata) Set(val *HourlyUsageAttributionMetadata) { + v.value = val + v.isSet = true +} + +func (v NullableHourlyUsageAttributionMetadata) IsSet() bool { + return v.isSet +} + +func (v *NullableHourlyUsageAttributionMetadata) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableHourlyUsageAttributionMetadata(val *HourlyUsageAttributionMetadata) *NullableHourlyUsageAttributionMetadata { + return &NullableHourlyUsageAttributionMetadata{value: val, isSet: true} +} + +func (v NullableHourlyUsageAttributionMetadata) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableHourlyUsageAttributionMetadata) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/v1/datadog/model_hourly_usage_attribution_pagination.go b/api/v1/datadog/model_hourly_usage_attribution_pagination.go new file mode 100644 index 00000000000..d774e1b7d44 --- /dev/null +++ b/api/v1/datadog/model_hourly_usage_attribution_pagination.go @@ -0,0 +1,135 @@ +/* + * 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. + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package datadog + +import ( + "encoding/json" +) + +// HourlyUsageAttributionPagination The metadata for the current pagination. +type HourlyUsageAttributionPagination struct { + // The cursor to get the next results (if any). To make the next request, use the same parameters and add `next_record_id`. + NextRecordId *string `json:"next_record_id,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:-` +} + +// NewHourlyUsageAttributionPagination instantiates a new HourlyUsageAttributionPagination 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 NewHourlyUsageAttributionPagination() *HourlyUsageAttributionPagination { + this := HourlyUsageAttributionPagination{} + return &this +} + +// NewHourlyUsageAttributionPaginationWithDefaults instantiates a new HourlyUsageAttributionPagination 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 NewHourlyUsageAttributionPaginationWithDefaults() *HourlyUsageAttributionPagination { + this := HourlyUsageAttributionPagination{} + return &this +} + +// GetNextRecordId returns the NextRecordId field value if set, zero value otherwise. +func (o *HourlyUsageAttributionPagination) GetNextRecordId() string { + if o == nil || o.NextRecordId == nil { + var ret string + return ret + } + return *o.NextRecordId +} + +// GetNextRecordIdOk returns a tuple with the NextRecordId field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HourlyUsageAttributionPagination) GetNextRecordIdOk() (*string, bool) { + if o == nil || o.NextRecordId == nil { + return nil, false + } + return o.NextRecordId, true +} + +// HasNextRecordId returns a boolean if a field has been set. +func (o *HourlyUsageAttributionPagination) HasNextRecordId() bool { + if o != nil && o.NextRecordId != nil { + return true + } + + return false +} + +// SetNextRecordId gets a reference to the given string and assigns it to the NextRecordId field. +func (o *HourlyUsageAttributionPagination) SetNextRecordId(v string) { + o.NextRecordId = &v +} + +func (o HourlyUsageAttributionPagination) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.NextRecordId != nil { + toSerialize["next_record_id"] = o.NextRecordId + } + return json.Marshal(toSerialize) +} + +func (o *HourlyUsageAttributionPagination) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + NextRecordId *string `json:"next_record_id,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.NextRecordId = all.NextRecordId + return nil +} + +type NullableHourlyUsageAttributionPagination struct { + value *HourlyUsageAttributionPagination + isSet bool +} + +func (v NullableHourlyUsageAttributionPagination) Get() *HourlyUsageAttributionPagination { + return v.value +} + +func (v *NullableHourlyUsageAttributionPagination) Set(val *HourlyUsageAttributionPagination) { + v.value = val + v.isSet = true +} + +func (v NullableHourlyUsageAttributionPagination) IsSet() bool { + return v.isSet +} + +func (v *NullableHourlyUsageAttributionPagination) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableHourlyUsageAttributionPagination(val *HourlyUsageAttributionPagination) *NullableHourlyUsageAttributionPagination { + return &NullableHourlyUsageAttributionPagination{value: val, isSet: true} +} + +func (v NullableHourlyUsageAttributionPagination) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableHourlyUsageAttributionPagination) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/v1/datadog/model_hourly_usage_attribution_response.go b/api/v1/datadog/model_hourly_usage_attribution_response.go new file mode 100644 index 00000000000..d89076f86d6 --- /dev/null +++ b/api/v1/datadog/model_hourly_usage_attribution_response.go @@ -0,0 +1,173 @@ +/* + * 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. + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package datadog + +import ( + "encoding/json" +) + +// HourlyUsageAttributionResponse Response containing the hourly usage attribution by tag(s). +type HourlyUsageAttributionResponse struct { + Metadata *HourlyUsageAttributionMetadata `json:"metadata,omitempty"` + // Get the hourly usage attribution by tag(s). + Usage *[]HourlyUsageAttributionBody `json:"usage,omitempty"` + // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct + UnparsedObject map[string]interface{} `json:-` +} + +// NewHourlyUsageAttributionResponse instantiates a new HourlyUsageAttributionResponse 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 NewHourlyUsageAttributionResponse() *HourlyUsageAttributionResponse { + this := HourlyUsageAttributionResponse{} + return &this +} + +// NewHourlyUsageAttributionResponseWithDefaults instantiates a new HourlyUsageAttributionResponse 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 NewHourlyUsageAttributionResponseWithDefaults() *HourlyUsageAttributionResponse { + this := HourlyUsageAttributionResponse{} + return &this +} + +// GetMetadata returns the Metadata field value if set, zero value otherwise. +func (o *HourlyUsageAttributionResponse) GetMetadata() HourlyUsageAttributionMetadata { + if o == nil || o.Metadata == nil { + var ret HourlyUsageAttributionMetadata + return ret + } + return *o.Metadata +} + +// GetMetadataOk returns a tuple with the Metadata field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HourlyUsageAttributionResponse) GetMetadataOk() (*HourlyUsageAttributionMetadata, bool) { + if o == nil || o.Metadata == nil { + return nil, false + } + return o.Metadata, true +} + +// HasMetadata returns a boolean if a field has been set. +func (o *HourlyUsageAttributionResponse) HasMetadata() bool { + if o != nil && o.Metadata != nil { + return true + } + + return false +} + +// SetMetadata gets a reference to the given HourlyUsageAttributionMetadata and assigns it to the Metadata field. +func (o *HourlyUsageAttributionResponse) SetMetadata(v HourlyUsageAttributionMetadata) { + o.Metadata = &v +} + +// GetUsage returns the Usage field value if set, zero value otherwise. +func (o *HourlyUsageAttributionResponse) GetUsage() []HourlyUsageAttributionBody { + if o == nil || o.Usage == nil { + var ret []HourlyUsageAttributionBody + return ret + } + return *o.Usage +} + +// GetUsageOk returns a tuple with the Usage field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *HourlyUsageAttributionResponse) GetUsageOk() (*[]HourlyUsageAttributionBody, bool) { + if o == nil || o.Usage == nil { + return nil, false + } + return o.Usage, true +} + +// HasUsage returns a boolean if a field has been set. +func (o *HourlyUsageAttributionResponse) HasUsage() bool { + if o != nil && o.Usage != nil { + return true + } + + return false +} + +// SetUsage gets a reference to the given []HourlyUsageAttributionBody and assigns it to the Usage field. +func (o *HourlyUsageAttributionResponse) SetUsage(v []HourlyUsageAttributionBody) { + o.Usage = &v +} + +func (o HourlyUsageAttributionResponse) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return json.Marshal(o.UnparsedObject) + } + if o.Metadata != nil { + toSerialize["metadata"] = o.Metadata + } + if o.Usage != nil { + toSerialize["usage"] = o.Usage + } + return json.Marshal(toSerialize) +} + +func (o *HourlyUsageAttributionResponse) UnmarshalJSON(bytes []byte) (err error) { + raw := map[string]interface{}{} + all := struct { + Metadata *HourlyUsageAttributionMetadata `json:"metadata,omitempty"` + Usage *[]HourlyUsageAttributionBody `json:"usage,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.Metadata = all.Metadata + o.Usage = all.Usage + return nil +} + +type NullableHourlyUsageAttributionResponse struct { + value *HourlyUsageAttributionResponse + isSet bool +} + +func (v NullableHourlyUsageAttributionResponse) Get() *HourlyUsageAttributionResponse { + return v.value +} + +func (v *NullableHourlyUsageAttributionResponse) Set(val *HourlyUsageAttributionResponse) { + v.value = val + v.isSet = true +} + +func (v NullableHourlyUsageAttributionResponse) IsSet() bool { + return v.isSet +} + +func (v *NullableHourlyUsageAttributionResponse) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableHourlyUsageAttributionResponse(val *HourlyUsageAttributionResponse) *NullableHourlyUsageAttributionResponse { + return &NullableHourlyUsageAttributionResponse{value: val, isSet: true} +} + +func (v NullableHourlyUsageAttributionResponse) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableHourlyUsageAttributionResponse) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/api/v1/datadog/model_hourly_usage_attribution_usage_type.go b/api/v1/datadog/model_hourly_usage_attribution_usage_type.go new file mode 100644 index 00000000000..8da26c1e417 --- /dev/null +++ b/api/v1/datadog/model_hourly_usage_attribution_usage_type.go @@ -0,0 +1,128 @@ +/* + * 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. + */ + +// Code generated by OpenAPI Generator (https://openapi-generator.tech); DO NOT EDIT. + +package datadog + +import ( + "encoding/json" + "fmt" +) + +// HourlyUsageAttributionUsageType Supported products for hourly usage attribution requests. +type HourlyUsageAttributionUsageType string + +// List of HourlyUsageAttributionUsageType +const ( + HOURLYUSAGEATTRIBUTIONUSAGETYPE_API_USAGE HourlyUsageAttributionUsageType = "api_usage" + HOURLYUSAGEATTRIBUTIONUSAGETYPE_APM_HOST_USAGE HourlyUsageAttributionUsageType = "apm_host_usage" + HOURLYUSAGEATTRIBUTIONUSAGETYPE_BROWSER_USAGE HourlyUsageAttributionUsageType = "browser_usage" + HOURLYUSAGEATTRIBUTIONUSAGETYPE_CONTAINER_USAGE HourlyUsageAttributionUsageType = "container_usage" + HOURLYUSAGEATTRIBUTIONUSAGETYPE_CUSTOM_TIMESERIES_USAGE HourlyUsageAttributionUsageType = "custom_timeseries_usage" + HOURLYUSAGEATTRIBUTIONUSAGETYPE_FARGATE_USAGE HourlyUsageAttributionUsageType = "fargate_usage" + HOURLYUSAGEATTRIBUTIONUSAGETYPE_FUNCTIONS_USAGE HourlyUsageAttributionUsageType = "functions_usage" + HOURLYUSAGEATTRIBUTIONUSAGETYPE_INDEXED_LOGS_USAGE HourlyUsageAttributionUsageType = "indexed_logs_usage" + HOURLYUSAGEATTRIBUTIONUSAGETYPE_INFRA_HOST_USAGE HourlyUsageAttributionUsageType = "infra_host_usage" + HOURLYUSAGEATTRIBUTIONUSAGETYPE_INVOCATIONS_USAGE HourlyUsageAttributionUsageType = "invocations_usage" + HOURLYUSAGEATTRIBUTIONUSAGETYPE_NPM_HOST_USAGE HourlyUsageAttributionUsageType = "npm_host_usage" + HOURLYUSAGEATTRIBUTIONUSAGETYPE_PROFILED_CONTAINER_USAGE HourlyUsageAttributionUsageType = "profiled_container_usage" + HOURLYUSAGEATTRIBUTIONUSAGETYPE_PROFILED_HOST_USAGE HourlyUsageAttributionUsageType = "profiled_host_usage" + HOURLYUSAGEATTRIBUTIONUSAGETYPE_SNMP_USAGE HourlyUsageAttributionUsageType = "snmp_usage" +) + +var allowedHourlyUsageAttributionUsageTypeEnumValues = []HourlyUsageAttributionUsageType{ + "api_usage", + "apm_host_usage", + "browser_usage", + "container_usage", + "custom_timeseries_usage", + "fargate_usage", + "functions_usage", + "indexed_logs_usage", + "infra_host_usage", + "invocations_usage", + "npm_host_usage", + "profiled_container_usage", + "profiled_host_usage", + "snmp_usage", +} + +func (w *HourlyUsageAttributionUsageType) GetAllowedValues() []HourlyUsageAttributionUsageType { + return allowedHourlyUsageAttributionUsageTypeEnumValues +} + +func (v *HourlyUsageAttributionUsageType) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = HourlyUsageAttributionUsageType(value) + return nil +} + +// NewHourlyUsageAttributionUsageTypeFromValue returns a pointer to a valid HourlyUsageAttributionUsageType +// for the value passed as argument, or an error if the value passed is not allowed by the enum +func NewHourlyUsageAttributionUsageTypeFromValue(v string) (*HourlyUsageAttributionUsageType, error) { + ev := HourlyUsageAttributionUsageType(v) + if ev.IsValid() { + return &ev, nil + } else { + return nil, fmt.Errorf("invalid value '%v' for HourlyUsageAttributionUsageType: valid values are %v", v, allowedHourlyUsageAttributionUsageTypeEnumValues) + } +} + +// IsValid return true if the value is valid for the enum, false otherwise +func (v HourlyUsageAttributionUsageType) IsValid() bool { + for _, existing := range allowedHourlyUsageAttributionUsageTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to HourlyUsageAttributionUsageType value +func (v HourlyUsageAttributionUsageType) Ptr() *HourlyUsageAttributionUsageType { + return &v +} + +type NullableHourlyUsageAttributionUsageType struct { + value *HourlyUsageAttributionUsageType + isSet bool +} + +func (v NullableHourlyUsageAttributionUsageType) Get() *HourlyUsageAttributionUsageType { + return v.value +} + +func (v *NullableHourlyUsageAttributionUsageType) Set(val *HourlyUsageAttributionUsageType) { + v.value = val + v.isSet = true +} + +func (v NullableHourlyUsageAttributionUsageType) IsSet() bool { + return v.isSet +} + +func (v *NullableHourlyUsageAttributionUsageType) Unset() { + v.value = nil + v.isSet = false +} + +func NewNullableHourlyUsageAttributionUsageType(val *HourlyUsageAttributionUsageType) *NullableHourlyUsageAttributionUsageType { + return &NullableHourlyUsageAttributionUsageType{value: val, isSet: true} +} + +func (v NullableHourlyUsageAttributionUsageType) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +func (v *NullableHourlyUsageAttributionUsageType) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/examples/v1/usage-metering/GetHourlyUsageAttribution.go b/examples/v1/usage-metering/GetHourlyUsageAttribution.go new file mode 100644 index 00000000000..43dd3c9e87e --- /dev/null +++ b/examples/v1/usage-metering/GetHourlyUsageAttribution.go @@ -0,0 +1,29 @@ +// Get Hourly Usage Attribution returns "OK" response + +package main + +import ( + "context" + "encoding/json" + "fmt" + "os" + "time" + + datadog "github.com/DataDog/datadog-api-client-go/api/v1/datadog" +) + +func main() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + configuration.SetUnstableOperationEnabled("GetHourlyUsageAttribution", true) + apiClient := datadog.NewAPIClient(configuration) + resp, r, err := apiClient.UsageMeteringApi.GetHourlyUsageAttribution(ctx, time.Now().AddDate(0, 0, -3), datadog.HOURLYUSAGEATTRIBUTIONUSAGETYPE_INFRA_HOST_USAGE, *datadog.NewGetHourlyUsageAttributionOptionalParameters()) + + if err != nil { + fmt.Fprintf(os.Stderr, "Error when calling `UsageMeteringApi.GetHourlyUsageAttribution`: %v\n", err) + fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r) + } + + responseContent, _ := json.MarshalIndent(resp, "", " ") + fmt.Fprintf(os.Stdout, "Response from `UsageMeteringApi.GetHourlyUsageAttribution`:\n%s\n", responseContent) +} diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Usage_Metering/Scenario_Get_Hourly_Usage_Attribution_returns_OK_response.freeze b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Usage_Metering/Scenario_Get_Hourly_Usage_Attribution_returns_OK_response.freeze new file mode 100644 index 00000000000..abf419f9fee --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Usage_Metering/Scenario_Get_Hourly_Usage_Attribution_returns_OK_response.freeze @@ -0,0 +1 @@ +2021-12-22T21:22:28.553Z \ No newline at end of file diff --git a/tests/scenarios/cassettes/TestScenarios/v1/Feature_Usage_Metering/Scenario_Get_Hourly_Usage_Attribution_returns_OK_response.yaml b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Usage_Metering/Scenario_Get_Hourly_Usage_Attribution_returns_OK_response.yaml new file mode 100644 index 00000000000..ace97ff4959 --- /dev/null +++ b/tests/scenarios/cassettes/TestScenarios/v1/Feature_Usage_Metering/Scenario_Get_Hourly_Usage_Attribution_returns_OK_response.yaml @@ -0,0 +1,61 @@ +interactions: +- request: + body: '' + form: {} + headers: + Accept: + - application/json;datetime-format=rfc3339 + Connection: + - close + Host: + - api.datadoghq.com + User-Agent: + - datadog-api-spec/scripts/bdd-runner + X-Datadog-Parent-Id: + - '8346895373953849084' + X-Datadog-Trace-Id: + - '8346895373953849084' + method: GET + url: https://api.datadoghq.com/api/v1/usage/hourly-attribution?start_hr=2021-12-19T21%3A22%3A28.553Z&usage_type=infra_host_usage + response: + body: '{"usage":[{"org_name":"DD Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","hour":"2021-12-19T21:00:00+00:00","tag_config_source":"DD + Integration Tests (321813):::project","tags":null,"total_usage_sum":17,"updated_at":"2021-12-20T17","usage_type":"infra_host_usage"},{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","hour":"2021-12-19T22:00:00+00:00","tag_config_source":"DD + Integration Tests (321813):::project","tags":null,"total_usage_sum":17,"updated_at":"2021-12-20T17","usage_type":"infra_host_usage"},{"org_name":"DD + Integration Tests (321813)","public_id":"fasjyydbcgwwc2uc","hour":"2021-12-19T23:00:00+00:00","tag_config_source":"DD + Integration Tests (321813):::project","tags":null,"total_usage_sum":17,"updated_at":"2021-12-20T17","usage_type":"infra_host_usage"}],"metadata":{"pagination":{"next_record_id":null}}}' + code: 200 + duration: '' + headers: + Cache-Control: + - no-cache + Connection: + - close + Content-Length: + - '862' + Content-Security-Policy: + - frame-ancestors 'self'; report-uri https://api.datadoghq.com/csp-report + Content-Type: + - application/json + Date: + - Wed, 22 Dec 2021 21:22:29 GMT + Pragma: + - no-cache + Strict-Transport-Security: + - max-age=15724800; + Vary: + - Accept-Encoding + X-Content-Type-Options: + - nosniff + X-Frame-Options: + - SAMEORIGIN + X-Ratelimit-Limit: + - '1' + X-Ratelimit-Period: + - '60' + X-Ratelimit-Remaining: + - '0' + X-Ratelimit-Reset: + - '31' + status: 200 OK +version: 1 diff --git a/tests/scenarios/features/v1/undo.json b/tests/scenarios/features/v1/undo.json index bb7164b2f13..9db6aacbddb 100644 --- a/tests/scenarios/features/v1/undo.json +++ b/tests/scenarios/features/v1/undo.json @@ -1224,6 +1224,12 @@ "type": "safe" } }, + "GetHourlyUsageAttribution": { + "tag": "Usage Metering", + "undo": { + "type": "safe" + } + }, "GetIncidentManagement": { "tag": "Usage Metering", "undo": { diff --git a/tests/scenarios/features/v1/usage_metering.feature b/tests/scenarios/features/v1/usage_metering.feature index 32f0f1fde01..f7ed361a2b4 100644 --- a/tests/scenarios/features/v1/usage_metering.feature +++ b/tests/scenarios/features/v1/usage_metering.feature @@ -14,6 +14,24 @@ Feature: Usage Metering And a valid "appKeyAuth" key in the system And an instance of "UsageMetering" API + @skip @team:DataDog/red-zone-revenue-query + Scenario: Get Hourly Usage Attribution returns "Bad Request" response + Given operation "GetHourlyUsageAttribution" enabled + And new "GetHourlyUsageAttribution" request + And request contains "start_hr" parameter with value "{{ timeISO('now - 3d') }}" + And request contains "usage_type" parameter with value "not_a_product" + When the request is sent + Then the response status is 400 Bad Request + + @team:DataDog/red-zone-revenue-query + Scenario: Get Hourly Usage Attribution returns "OK" response + Given operation "GetHourlyUsageAttribution" enabled + And new "GetHourlyUsageAttribution" request + And request contains "start_hr" parameter with value "{{ timeISO('now - 3d') }}" + And request contains "usage_type" parameter with value "infra_host_usage" + When the request is sent + Then the response status is 200 OK + @generated @skip @team:DataDog/red-zone-revenue-query Scenario: Get Usage Attribution returns "OK" response Given operation "GetUsageAttribution" enabled