diff --git a/.apigentools-info b/.apigentools-info index d04ba0341e1..7fe3ce3c043 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.6", - "regenerated": "2024-09-23 19:10:10.010692", - "spec_repo_commit": "41592dc6" + "regenerated": "2024-09-24 14:49:07.421285", + "spec_repo_commit": "53c64681" }, "v2": { "apigentools_version": "1.6.6", - "regenerated": "2024-09-23 19:10:10.024754", - "spec_repo_commit": "41592dc6" + "regenerated": "2024-09-24 14:49:07.435987", + "spec_repo_commit": "53c64681" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index ee4788c60a5..be92fdbd850 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -14207,6 +14207,35 @@ components: - COUNT - RATE - GAUGE + MetricMetaPage: + description: Paging attributes. Only present if pagination query parameters + were provided. + properties: + cursor: + description: The cursor used to get the current results, if any. + type: string + limit: + description: Number of results returned + format: int32 + maximum: 20000 + minimum: 0 + type: integer + next_cursor: + description: The cursor used to get the next results, if any. + nullable: true + type: string + type: + $ref: '#/components/schemas/MetricMetaPageType' + type: object + MetricMetaPageType: + default: cursor_limit + description: Type of Metric pagination. + enum: + - cursor_limit + example: cursor_limit + type: string + x-enum-varnames: + - CURSOR_LIMIT MetricMetadata: description: Metadata for the metric. properties: @@ -14289,6 +14318,12 @@ components: maximum: 1000 type: integer type: object + MetricPaginationMeta: + description: Response metadata object. + properties: + pagination: + $ref: '#/components/schemas/MetricMetaPage' + type: object MetricPayload: description: The metrics' payload. properties: @@ -14754,6 +14789,10 @@ components: items: $ref: '#/components/schemas/MetricsAndMetricTagConfigurations' type: array + links: + $ref: '#/components/schemas/MetricsListResponseLinks' + meta: + $ref: '#/components/schemas/MetricPaginationMeta' readOnly: true type: object MetricsDataSource: @@ -14767,6 +14806,29 @@ components: x-enum-varnames: - METRICS - CLOUD_COST + MetricsListResponseLinks: + description: Pagination links. Only present if pagination query parameters were + provided. + properties: + first: + description: Link to the first page. + type: string + last: + description: Link to the last page. + nullable: true + type: string + next: + description: Link to the next page. + nullable: true + type: string + prev: + description: Link to previous page. + nullable: true + type: string + self: + description: Link to current page. + type: string + type: object MetricsScalarQuery: description: An individual scalar metrics query. properties: @@ -32472,7 +32534,12 @@ paths: get: description: "Returns all metrics that can be configured in the Metrics Summary page or with Metrics without Limits\u2122 (matching additional filters if - specified)." + specified).\nOptionally, paginate by using the page[cursor] and/or page[size] + query parameters.\nTo fetch the first page, pass in a query parameter with + either a valid page[size] or an empty cursor like \"page[cursor]=\". To fetch + the next page, pass in the next_cursor value from the response as the new + page[cursor] value.\nOnce the meta.pagination.next_cursor value is null, all + pages have been retrieved." operationId: ListTagConfigurations parameters: - description: Filter custom metrics that have configured tags. @@ -32537,6 +32604,26 @@ paths: schema: format: int64 type: integer + - description: Maximum number of results returned. + in: query + name: page[size] + required: false + schema: + default: 10000 + format: int32 + maximum: 10000 + minimum: 1 + type: integer + - description: 'String to query the next page of results. + + This key is provided with each valid response from the API in `meta.pagination.next_cursor`. + + Once the meta.pagination.next_cursor key is null, all pages have been retrieved.' + in: query + name: page[cursor] + required: false + schema: + type: string responses: '200': content: @@ -32570,6 +32657,11 @@ paths: summary: Get a list of metrics tags: - Metrics + x-pagination: + cursorParam: page[cursor] + cursorPath: meta.pagination.next_cursor + limitParam: page[size] + resultsPath: data x-permission: operator: OR permissions: diff --git a/api/datadogV2/api_metrics.go b/api/datadogV2/api_metrics.go index 8420e5707cf..1ae7a3fccfb 100644 --- a/api/datadogV2/api_metrics.go +++ b/api/datadogV2/api_metrics.go @@ -702,6 +702,8 @@ type ListTagConfigurationsOptionalParameters struct { FilterQueried *bool FilterTags *string WindowSeconds *int64 + PageSize *int32 + PageCursor *string } // NewListTagConfigurationsOptionalParameters creates an empty struct for parameters. @@ -752,8 +754,23 @@ func (r *ListTagConfigurationsOptionalParameters) WithWindowSeconds(windowSecond return r } +// WithPageSize sets the corresponding parameter name and returns the struct. +func (r *ListTagConfigurationsOptionalParameters) WithPageSize(pageSize int32) *ListTagConfigurationsOptionalParameters { + r.PageSize = &pageSize + return r +} + +// WithPageCursor sets the corresponding parameter name and returns the struct. +func (r *ListTagConfigurationsOptionalParameters) WithPageCursor(pageCursor string) *ListTagConfigurationsOptionalParameters { + r.PageCursor = &pageCursor + return r +} + // ListTagConfigurations Get a list of metrics. // Returns all metrics that can be configured in the Metrics Summary page or with Metrics without Limits™ (matching additional filters if specified). +// Optionally, paginate by using the page[cursor] and/or page[size] query parameters. +// To fetch the first page, pass in a query parameter with either a valid page[size] or an empty cursor like "page[cursor]=". To fetch the next page, pass in the next_cursor value from the response as the new page[cursor] value. +// Once the meta.pagination.next_cursor value is null, all pages have been retrieved. func (a *MetricsApi) ListTagConfigurations(ctx _context.Context, o ...ListTagConfigurationsOptionalParameters) (MetricsAndMetricTagConfigurationsResponse, *_nethttp.Response, error) { var ( localVarHTTPMethod = _nethttp.MethodGet @@ -800,6 +817,12 @@ func (a *MetricsApi) ListTagConfigurations(ctx _context.Context, o ...ListTagCon if optionalParams.WindowSeconds != nil { localVarQueryParams.Add("window[seconds]", datadog.ParameterToString(*optionalParams.WindowSeconds, "")) } + if optionalParams.PageSize != nil { + localVarQueryParams.Add("page[size]", datadog.ParameterToString(*optionalParams.PageSize, "")) + } + if optionalParams.PageCursor != nil { + localVarQueryParams.Add("page[cursor]", datadog.ParameterToString(*optionalParams.PageCursor, "")) + } localVarHeaderParams["Accept"] = "application/json" datadog.SetAuthKeys( @@ -851,6 +874,64 @@ func (a *MetricsApi) ListTagConfigurations(ctx _context.Context, o ...ListTagCon return localVarReturnValue, localVarHTTPResponse, nil } +// ListTagConfigurationsWithPagination provides a paginated version of ListTagConfigurations returning a channel with all items. +func (a *MetricsApi) ListTagConfigurationsWithPagination(ctx _context.Context, o ...ListTagConfigurationsOptionalParameters) (<-chan datadog.PaginationResult[MetricsAndMetricTagConfigurations], func()) { + ctx, cancel := _context.WithCancel(ctx) + pageSize_ := int32(10000) + if len(o) == 0 { + o = append(o, ListTagConfigurationsOptionalParameters{}) + } + if o[0].PageSize != nil { + pageSize_ = *o[0].PageSize + } + o[0].PageSize = &pageSize_ + + items := make(chan datadog.PaginationResult[MetricsAndMetricTagConfigurations], pageSize_) + go func() { + for { + resp, _, err := a.ListTagConfigurations(ctx, o...) + if err != nil { + var returnItem MetricsAndMetricTagConfigurations + items <- datadog.PaginationResult[MetricsAndMetricTagConfigurations]{Item: returnItem, Error: err} + break + } + respData, ok := resp.GetDataOk() + if !ok { + break + } + results := *respData + + for _, item := range results { + select { + case items <- datadog.PaginationResult[MetricsAndMetricTagConfigurations]{Item: item, Error: nil}: + case <-ctx.Done(): + close(items) + return + } + } + if len(results) < int(pageSize_) { + break + } + cursorMeta, ok := resp.GetMetaOk() + if !ok { + break + } + cursorMetaPagination, ok := cursorMeta.GetPaginationOk() + if !ok { + break + } + cursorMetaPaginationNextCursor, ok := cursorMetaPagination.GetNextCursorOk() + if !ok { + break + } + + o[0].PageCursor = cursorMetaPaginationNextCursor + } + close(items) + }() + return items, cancel +} + // ListTagsByMetricName List tags by metric name. // View indexed tag key-value pairs for a given metric name. func (a *MetricsApi) ListTagsByMetricName(ctx _context.Context, metricName string) (MetricAllTagsResponse, *_nethttp.Response, error) { diff --git a/api/datadogV2/model_metric_meta_page.go b/api/datadogV2/model_metric_meta_page.go new file mode 100644 index 00000000000..7bb0a68503c --- /dev/null +++ b/api/datadogV2/model_metric_meta_page.go @@ -0,0 +1,232 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// MetricMetaPage Paging attributes. Only present if pagination query parameters were provided. +type MetricMetaPage struct { + // The cursor used to get the current results, if any. + Cursor *string `json:"cursor,omitempty"` + // Number of results returned + Limit *int32 `json:"limit,omitempty"` + // The cursor used to get the next results, if any. + NextCursor datadog.NullableString `json:"next_cursor,omitempty"` + // Type of Metric pagination. + Type *MetricMetaPageType `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{} `json:"-"` +} + +// NewMetricMetaPage instantiates a new MetricMetaPage 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 NewMetricMetaPage() *MetricMetaPage { + this := MetricMetaPage{} + var typeVar MetricMetaPageType = METRICMETAPAGETYPE_CURSOR_LIMIT + this.Type = &typeVar + return &this +} + +// NewMetricMetaPageWithDefaults instantiates a new MetricMetaPage 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 NewMetricMetaPageWithDefaults() *MetricMetaPage { + this := MetricMetaPage{} + var typeVar MetricMetaPageType = METRICMETAPAGETYPE_CURSOR_LIMIT + this.Type = &typeVar + return &this +} + +// GetCursor returns the Cursor field value if set, zero value otherwise. +func (o *MetricMetaPage) GetCursor() string { + if o == nil || o.Cursor == nil { + var ret string + return ret + } + return *o.Cursor +} + +// GetCursorOk returns a tuple with the Cursor field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MetricMetaPage) GetCursorOk() (*string, bool) { + if o == nil || o.Cursor == nil { + return nil, false + } + return o.Cursor, true +} + +// HasCursor returns a boolean if a field has been set. +func (o *MetricMetaPage) HasCursor() bool { + return o != nil && o.Cursor != nil +} + +// SetCursor gets a reference to the given string and assigns it to the Cursor field. +func (o *MetricMetaPage) SetCursor(v string) { + o.Cursor = &v +} + +// GetLimit returns the Limit field value if set, zero value otherwise. +func (o *MetricMetaPage) 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 *MetricMetaPage) 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 *MetricMetaPage) 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 *MetricMetaPage) SetLimit(v int32) { + o.Limit = &v +} + +// GetNextCursor returns the NextCursor field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *MetricMetaPage) GetNextCursor() string { + if o == nil || o.NextCursor.Get() == nil { + var ret string + return ret + } + return *o.NextCursor.Get() +} + +// GetNextCursorOk returns a tuple with the NextCursor field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *MetricMetaPage) GetNextCursorOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.NextCursor.Get(), o.NextCursor.IsSet() +} + +// HasNextCursor returns a boolean if a field has been set. +func (o *MetricMetaPage) HasNextCursor() bool { + return o != nil && o.NextCursor.IsSet() +} + +// SetNextCursor gets a reference to the given datadog.NullableString and assigns it to the NextCursor field. +func (o *MetricMetaPage) SetNextCursor(v string) { + o.NextCursor.Set(&v) +} + +// SetNextCursorNil sets the value for NextCursor to be an explicit nil. +func (o *MetricMetaPage) SetNextCursorNil() { + o.NextCursor.Set(nil) +} + +// UnsetNextCursor ensures that no value is present for NextCursor, not even an explicit nil. +func (o *MetricMetaPage) UnsetNextCursor() { + o.NextCursor.Unset() +} + +// GetType returns the Type field value if set, zero value otherwise. +func (o *MetricMetaPage) GetType() MetricMetaPageType { + if o == nil || o.Type == nil { + var ret MetricMetaPageType + 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 *MetricMetaPage) GetTypeOk() (*MetricMetaPageType, 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 *MetricMetaPage) HasType() bool { + return o != nil && o.Type != nil +} + +// SetType gets a reference to the given MetricMetaPageType and assigns it to the Type field. +func (o *MetricMetaPage) SetType(v MetricMetaPageType) { + o.Type = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MetricMetaPage) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Cursor != nil { + toSerialize["cursor"] = o.Cursor + } + if o.Limit != nil { + toSerialize["limit"] = o.Limit + } + if o.NextCursor.IsSet() { + toSerialize["next_cursor"] = o.NextCursor.Get() + } + if o.Type != nil { + toSerialize["type"] = o.Type + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MetricMetaPage) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Cursor *string `json:"cursor,omitempty"` + Limit *int32 `json:"limit,omitempty"` + NextCursor datadog.NullableString `json:"next_cursor,omitempty"` + Type *MetricMetaPageType `json:"type,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"cursor", "limit", "next_cursor", "type"}) + } else { + return err + } + + hasInvalidField := false + o.Cursor = all.Cursor + o.Limit = all.Limit + o.NextCursor = all.NextCursor + if all.Type != nil && !all.Type.IsValid() { + hasInvalidField = true + } else { + o.Type = all.Type + } + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_metric_meta_page_type.go b/api/datadogV2/model_metric_meta_page_type.go new file mode 100644 index 00000000000..fe8cf4c1d9d --- /dev/null +++ b/api/datadogV2/model_metric_meta_page_type.go @@ -0,0 +1,64 @@ +// 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 ( + "fmt" + + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// MetricMetaPageType Type of Metric pagination. +type MetricMetaPageType string + +// List of MetricMetaPageType. +const ( + METRICMETAPAGETYPE_CURSOR_LIMIT MetricMetaPageType = "cursor_limit" +) + +var allowedMetricMetaPageTypeEnumValues = []MetricMetaPageType{ + METRICMETAPAGETYPE_CURSOR_LIMIT, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *MetricMetaPageType) GetAllowedValues() []MetricMetaPageType { + return allowedMetricMetaPageTypeEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *MetricMetaPageType) UnmarshalJSON(src []byte) error { + var value string + err := datadog.Unmarshal(src, &value) + if err != nil { + return err + } + *v = MetricMetaPageType(value) + return nil +} + +// NewMetricMetaPageTypeFromValue returns a pointer to a valid MetricMetaPageType +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewMetricMetaPageTypeFromValue(v string) (*MetricMetaPageType, error) { + ev := MetricMetaPageType(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for MetricMetaPageType: valid values are %v", v, allowedMetricMetaPageTypeEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v MetricMetaPageType) IsValid() bool { + for _, existing := range allowedMetricMetaPageTypeEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to MetricMetaPageType value. +func (v MetricMetaPageType) Ptr() *MetricMetaPageType { + return &v +} diff --git a/api/datadogV2/model_metric_pagination_meta.go b/api/datadogV2/model_metric_pagination_meta.go new file mode 100644 index 00000000000..0b3c849f10e --- /dev/null +++ b/api/datadogV2/model_metric_pagination_meta.go @@ -0,0 +1,111 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// MetricPaginationMeta Response metadata object. +type MetricPaginationMeta struct { + // Paging attributes. Only present if pagination query parameters were provided. + Pagination *MetricMetaPage `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:"-"` + AdditionalProperties map[string]interface{} `json:"-"` +} + +// NewMetricPaginationMeta instantiates a new MetricPaginationMeta 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 NewMetricPaginationMeta() *MetricPaginationMeta { + this := MetricPaginationMeta{} + return &this +} + +// NewMetricPaginationMetaWithDefaults instantiates a new MetricPaginationMeta 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 NewMetricPaginationMetaWithDefaults() *MetricPaginationMeta { + this := MetricPaginationMeta{} + return &this +} + +// GetPagination returns the Pagination field value if set, zero value otherwise. +func (o *MetricPaginationMeta) GetPagination() MetricMetaPage { + if o == nil || o.Pagination == nil { + var ret MetricMetaPage + 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 *MetricPaginationMeta) GetPaginationOk() (*MetricMetaPage, 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 *MetricPaginationMeta) HasPagination() bool { + return o != nil && o.Pagination != nil +} + +// SetPagination gets a reference to the given MetricMetaPage and assigns it to the Pagination field. +func (o *MetricPaginationMeta) SetPagination(v MetricMetaPage) { + o.Pagination = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MetricPaginationMeta) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.Pagination != nil { + toSerialize["pagination"] = o.Pagination + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MetricPaginationMeta) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + Pagination *MetricMetaPage `json:"pagination,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"pagination"}) + } else { + return err + } + + hasInvalidField := false + if all.Pagination != nil && all.Pagination.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Pagination = all.Pagination + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + + return nil +} diff --git a/api/datadogV2/model_metrics_and_metric_tag_configurations_response.go b/api/datadogV2/model_metrics_and_metric_tag_configurations_response.go index deea11c4a3e..bfd09393d8a 100644 --- a/api/datadogV2/model_metrics_and_metric_tag_configurations_response.go +++ b/api/datadogV2/model_metrics_and_metric_tag_configurations_response.go @@ -12,6 +12,10 @@ import ( type MetricsAndMetricTagConfigurationsResponse struct { // Array of metrics and metric tag configurations. Data []MetricsAndMetricTagConfigurations `json:"data,omitempty"` + // Pagination links. Only present if pagination query parameters were provided. + Links *MetricsListResponseLinks `json:"links,omitempty"` + // Response metadata object. + Meta *MetricPaginationMeta `json:"meta,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{} `json:"-"` @@ -62,6 +66,62 @@ func (o *MetricsAndMetricTagConfigurationsResponse) SetData(v []MetricsAndMetric o.Data = v } +// GetLinks returns the Links field value if set, zero value otherwise. +func (o *MetricsAndMetricTagConfigurationsResponse) GetLinks() MetricsListResponseLinks { + if o == nil || o.Links == nil { + var ret MetricsListResponseLinks + return ret + } + return *o.Links +} + +// GetLinksOk returns a tuple with the Links field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MetricsAndMetricTagConfigurationsResponse) GetLinksOk() (*MetricsListResponseLinks, bool) { + if o == nil || o.Links == nil { + return nil, false + } + return o.Links, true +} + +// HasLinks returns a boolean if a field has been set. +func (o *MetricsAndMetricTagConfigurationsResponse) HasLinks() bool { + return o != nil && o.Links != nil +} + +// SetLinks gets a reference to the given MetricsListResponseLinks and assigns it to the Links field. +func (o *MetricsAndMetricTagConfigurationsResponse) SetLinks(v MetricsListResponseLinks) { + o.Links = &v +} + +// GetMeta returns the Meta field value if set, zero value otherwise. +func (o *MetricsAndMetricTagConfigurationsResponse) GetMeta() MetricPaginationMeta { + if o == nil || o.Meta == nil { + var ret MetricPaginationMeta + return ret + } + return *o.Meta +} + +// GetMetaOk returns a tuple with the Meta field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MetricsAndMetricTagConfigurationsResponse) GetMetaOk() (*MetricPaginationMeta, bool) { + if o == nil || o.Meta == nil { + return nil, false + } + return o.Meta, true +} + +// HasMeta returns a boolean if a field has been set. +func (o *MetricsAndMetricTagConfigurationsResponse) HasMeta() bool { + return o != nil && o.Meta != nil +} + +// SetMeta gets a reference to the given MetricPaginationMeta and assigns it to the Meta field. +func (o *MetricsAndMetricTagConfigurationsResponse) SetMeta(v MetricPaginationMeta) { + o.Meta = &v +} + // MarshalJSON serializes the struct using spec logic. func (o MetricsAndMetricTagConfigurationsResponse) MarshalJSON() ([]byte, error) { toSerialize := map[string]interface{}{} @@ -71,6 +131,12 @@ func (o MetricsAndMetricTagConfigurationsResponse) MarshalJSON() ([]byte, error) if o.Data != nil { toSerialize["data"] = o.Data } + if o.Links != nil { + toSerialize["links"] = o.Links + } + if o.Meta != nil { + toSerialize["meta"] = o.Meta + } for key, value := range o.AdditionalProperties { toSerialize[key] = value @@ -81,22 +147,38 @@ func (o MetricsAndMetricTagConfigurationsResponse) MarshalJSON() ([]byte, error) // UnmarshalJSON deserializes the given payload. func (o *MetricsAndMetricTagConfigurationsResponse) UnmarshalJSON(bytes []byte) (err error) { all := struct { - Data []MetricsAndMetricTagConfigurations `json:"data,omitempty"` + Data []MetricsAndMetricTagConfigurations `json:"data,omitempty"` + Links *MetricsListResponseLinks `json:"links,omitempty"` + Meta *MetricPaginationMeta `json:"meta,omitempty"` }{} if err = datadog.Unmarshal(bytes, &all); err != nil { return datadog.Unmarshal(bytes, &o.UnparsedObject) } additionalProperties := make(map[string]interface{}) if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { - datadog.DeleteKeys(additionalProperties, &[]string{"data"}) + datadog.DeleteKeys(additionalProperties, &[]string{"data", "links", "meta"}) } else { return err } + + hasInvalidField := false o.Data = all.Data + if all.Links != nil && all.Links.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Links = all.Links + if all.Meta != nil && all.Meta.UnparsedObject != nil && o.UnparsedObject == nil { + hasInvalidField = true + } + o.Meta = all.Meta if len(additionalProperties) > 0 { o.AdditionalProperties = additionalProperties } + if hasInvalidField { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + return nil } diff --git a/api/datadogV2/model_metrics_list_response_links.go b/api/datadogV2/model_metrics_list_response_links.go new file mode 100644 index 00000000000..47a962ce681 --- /dev/null +++ b/api/datadogV2/model_metrics_list_response_links.go @@ -0,0 +1,275 @@ +// 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 ( + "github.com/DataDog/datadog-api-client-go/v2/api/datadog" +) + +// MetricsListResponseLinks Pagination links. Only present if pagination query parameters were provided. +type MetricsListResponseLinks struct { + // Link to the first page. + First *string `json:"first,omitempty"` + // Link to the last page. + Last datadog.NullableString `json:"last,omitempty"` + // Link to the next page. + Next datadog.NullableString `json:"next,omitempty"` + // Link to previous page. + Prev datadog.NullableString `json:"prev,omitempty"` + // Link to current page. + Self *string `json:"self,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{} `json:"-"` +} + +// NewMetricsListResponseLinks instantiates a new MetricsListResponseLinks 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 NewMetricsListResponseLinks() *MetricsListResponseLinks { + this := MetricsListResponseLinks{} + return &this +} + +// NewMetricsListResponseLinksWithDefaults instantiates a new MetricsListResponseLinks 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 NewMetricsListResponseLinksWithDefaults() *MetricsListResponseLinks { + this := MetricsListResponseLinks{} + return &this +} + +// GetFirst returns the First field value if set, zero value otherwise. +func (o *MetricsListResponseLinks) GetFirst() string { + if o == nil || o.First == nil { + var ret string + return ret + } + return *o.First +} + +// GetFirstOk returns a tuple with the First field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MetricsListResponseLinks) GetFirstOk() (*string, bool) { + if o == nil || o.First == nil { + return nil, false + } + return o.First, true +} + +// HasFirst returns a boolean if a field has been set. +func (o *MetricsListResponseLinks) HasFirst() bool { + return o != nil && o.First != nil +} + +// SetFirst gets a reference to the given string and assigns it to the First field. +func (o *MetricsListResponseLinks) SetFirst(v string) { + o.First = &v +} + +// GetLast returns the Last field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *MetricsListResponseLinks) GetLast() string { + if o == nil || o.Last.Get() == nil { + var ret string + return ret + } + return *o.Last.Get() +} + +// GetLastOk returns a tuple with the Last field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *MetricsListResponseLinks) GetLastOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Last.Get(), o.Last.IsSet() +} + +// HasLast returns a boolean if a field has been set. +func (o *MetricsListResponseLinks) HasLast() bool { + return o != nil && o.Last.IsSet() +} + +// SetLast gets a reference to the given datadog.NullableString and assigns it to the Last field. +func (o *MetricsListResponseLinks) SetLast(v string) { + o.Last.Set(&v) +} + +// SetLastNil sets the value for Last to be an explicit nil. +func (o *MetricsListResponseLinks) SetLastNil() { + o.Last.Set(nil) +} + +// UnsetLast ensures that no value is present for Last, not even an explicit nil. +func (o *MetricsListResponseLinks) UnsetLast() { + o.Last.Unset() +} + +// GetNext returns the Next field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *MetricsListResponseLinks) GetNext() string { + if o == nil || o.Next.Get() == nil { + var ret string + return ret + } + return *o.Next.Get() +} + +// GetNextOk returns a tuple with the Next field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *MetricsListResponseLinks) GetNextOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Next.Get(), o.Next.IsSet() +} + +// HasNext returns a boolean if a field has been set. +func (o *MetricsListResponseLinks) HasNext() bool { + return o != nil && o.Next.IsSet() +} + +// SetNext gets a reference to the given datadog.NullableString and assigns it to the Next field. +func (o *MetricsListResponseLinks) SetNext(v string) { + o.Next.Set(&v) +} + +// SetNextNil sets the value for Next to be an explicit nil. +func (o *MetricsListResponseLinks) SetNextNil() { + o.Next.Set(nil) +} + +// UnsetNext ensures that no value is present for Next, not even an explicit nil. +func (o *MetricsListResponseLinks) UnsetNext() { + o.Next.Unset() +} + +// GetPrev returns the Prev field value if set, zero value otherwise (both if not set or set to explicit null). +func (o *MetricsListResponseLinks) GetPrev() string { + if o == nil || o.Prev.Get() == nil { + var ret string + return ret + } + return *o.Prev.Get() +} + +// GetPrevOk returns a tuple with the Prev field value if set, nil otherwise +// and a boolean to check if the value has been set. +// NOTE: If the value is an explicit nil, `nil, true` will be returned. +func (o *MetricsListResponseLinks) GetPrevOk() (*string, bool) { + if o == nil { + return nil, false + } + return o.Prev.Get(), o.Prev.IsSet() +} + +// HasPrev returns a boolean if a field has been set. +func (o *MetricsListResponseLinks) HasPrev() bool { + return o != nil && o.Prev.IsSet() +} + +// SetPrev gets a reference to the given datadog.NullableString and assigns it to the Prev field. +func (o *MetricsListResponseLinks) SetPrev(v string) { + o.Prev.Set(&v) +} + +// SetPrevNil sets the value for Prev to be an explicit nil. +func (o *MetricsListResponseLinks) SetPrevNil() { + o.Prev.Set(nil) +} + +// UnsetPrev ensures that no value is present for Prev, not even an explicit nil. +func (o *MetricsListResponseLinks) UnsetPrev() { + o.Prev.Unset() +} + +// GetSelf returns the Self field value if set, zero value otherwise. +func (o *MetricsListResponseLinks) GetSelf() string { + if o == nil || o.Self == nil { + var ret string + return ret + } + return *o.Self +} + +// GetSelfOk returns a tuple with the Self field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *MetricsListResponseLinks) GetSelfOk() (*string, bool) { + if o == nil || o.Self == nil { + return nil, false + } + return o.Self, true +} + +// HasSelf returns a boolean if a field has been set. +func (o *MetricsListResponseLinks) HasSelf() bool { + return o != nil && o.Self != nil +} + +// SetSelf gets a reference to the given string and assigns it to the Self field. +func (o *MetricsListResponseLinks) SetSelf(v string) { + o.Self = &v +} + +// MarshalJSON serializes the struct using spec logic. +func (o MetricsListResponseLinks) MarshalJSON() ([]byte, error) { + toSerialize := map[string]interface{}{} + if o.UnparsedObject != nil { + return datadog.Marshal(o.UnparsedObject) + } + if o.First != nil { + toSerialize["first"] = o.First + } + if o.Last.IsSet() { + toSerialize["last"] = o.Last.Get() + } + if o.Next.IsSet() { + toSerialize["next"] = o.Next.Get() + } + if o.Prev.IsSet() { + toSerialize["prev"] = o.Prev.Get() + } + if o.Self != nil { + toSerialize["self"] = o.Self + } + + for key, value := range o.AdditionalProperties { + toSerialize[key] = value + } + return datadog.Marshal(toSerialize) +} + +// UnmarshalJSON deserializes the given payload. +func (o *MetricsListResponseLinks) UnmarshalJSON(bytes []byte) (err error) { + all := struct { + First *string `json:"first,omitempty"` + Last datadog.NullableString `json:"last,omitempty"` + Next datadog.NullableString `json:"next,omitempty"` + Prev datadog.NullableString `json:"prev,omitempty"` + Self *string `json:"self,omitempty"` + }{} + if err = datadog.Unmarshal(bytes, &all); err != nil { + return datadog.Unmarshal(bytes, &o.UnparsedObject) + } + additionalProperties := make(map[string]interface{}) + if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { + datadog.DeleteKeys(additionalProperties, &[]string{"first", "last", "next", "prev", "self"}) + } else { + return err + } + o.First = all.First + o.Last = all.Last + o.Next = all.Next + o.Prev = all.Prev + o.Self = all.Self + + if len(additionalProperties) > 0 { + o.AdditionalProperties = additionalProperties + } + + return nil +} diff --git a/examples/v2/metrics/ListTagConfigurations_3969783727.go b/examples/v2/metrics/ListTagConfigurations_3969783727.go new file mode 100644 index 00000000000..069958d68f3 --- /dev/null +++ b/examples/v2/metrics/ListTagConfigurations_3969783727.go @@ -0,0 +1,29 @@ +// Get a list of metrics returns "Success" response with pagination + +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() { + ctx := datadog.NewDefaultContext(context.Background()) + configuration := datadog.NewConfiguration() + apiClient := datadog.NewAPIClient(configuration) + api := datadogV2.NewMetricsApi(apiClient) + resp, _ := api.ListTagConfigurationsWithPagination(ctx, *datadogV2.NewListTagConfigurationsOptionalParameters()) + + for paginationResult := range resp { + if paginationResult.Error != nil { + fmt.Fprintf(os.Stderr, "Error when calling `MetricsApi.ListTagConfigurations`: %v\n", paginationResult.Error) + } + responseContent, _ := json.MarshalIndent(paginationResult.Item, "", " ") + fmt.Fprintf(os.Stdout, "%s\n", responseContent) + } +} diff --git a/tests/scenarios/features/v2/metrics.feature b/tests/scenarios/features/v2/metrics.feature index 033fe70ef99..80b42dc75a7 100644 --- a/tests/scenarios/features/v2/metrics.feature +++ b/tests/scenarios/features/v2/metrics.feature @@ -125,6 +125,13 @@ Feature: Metrics When the request is sent Then the response status is 200 Success + @generated @skip @team:DataDog/metrics-experience @with-pagination + Scenario: Get a list of metrics returns "Success" response with pagination + Given a valid "appKeyAuth" key in the system + And new "ListTagConfigurations" request + When the request with pagination is sent + Then the response status is 200 Success + @team:DataDog/metrics-experience Scenario: Get a list of metrics with a tag filter returns "Success" response Given a valid "appKeyAuth" key in the system