From 750184d9d845913c83bd17894e2361b68d38aadf Mon Sep 17 00:00:00 2001 From: "ci.datadog-api-spec" Date: Tue, 25 Oct 2022 14:05:11 +0000 Subject: [PATCH] Regenerate client from commit 9c8722f9 of spec repo --- .apigentools-info | 8 +- .generator/schemas/v2/openapi.yaml | 20 +++++ api/datadogV2/api_logs.go | 42 +++++---- api/datadogV2/model_logs_query_filter.go | 55 +++++++++++- api/datadogV2/model_logs_storage_tier.go | 109 +++++++++++++++++++++++ tests/scenarios/features/v2/logs.feature | 4 +- 6 files changed, 213 insertions(+), 25 deletions(-) create mode 100644 api/datadogV2/model_logs_storage_tier.go diff --git a/.apigentools-info b/.apigentools-info index 054a3a37dbc..97f95cc7248 100644 --- a/.apigentools-info +++ b/.apigentools-info @@ -4,13 +4,13 @@ "spec_versions": { "v1": { "apigentools_version": "1.6.4", - "regenerated": "2022-10-24 13:15:47.319813", - "spec_repo_commit": "18dc2450" + "regenerated": "2022-10-25 14:03:55.296570", + "spec_repo_commit": "9c8722f9" }, "v2": { "apigentools_version": "1.6.4", - "regenerated": "2022-10-24 13:15:47.335958", - "spec_repo_commit": "18dc2450" + "regenerated": "2022-10-25 14:03:55.310754", + "spec_repo_commit": "9c8722f9" } } } \ No newline at end of file diff --git a/.generator/schemas/v2/openapi.yaml b/.generator/schemas/v2/openapi.yaml index 64613e52441..cf110334db2 100644 --- a/.generator/schemas/v2/openapi.yaml +++ b/.generator/schemas/v2/openapi.yaml @@ -5235,6 +5235,8 @@ components: description: The search query - following the log search syntax. example: service:web* AND @http.status_code:[200 TO 299] type: string + storage_tier: + $ref: '#/components/schemas/LogsStorageTier' to: default: now description: The maximum time for the requested logs, supports date math @@ -5314,6 +5316,17 @@ components: x-enum-varnames: - ASCENDING - DESCENDING + LogsStorageTier: + default: indexes + description: Specifies storage type as indexes or online-archives + enum: + - indexes + - online-archives + example: indexes + type: string + x-enum-varnames: + - INDEXES + - ONLINE_ARCHIVES LogsWarning: description: A warning message indicating something that went wrong with the query @@ -13136,6 +13149,13 @@ paths: schema: format: date-time type: string + - description: Specifies the storage type to be used + example: indexes + in: query + name: filter[storage_tier] + required: false + schema: + $ref: '#/components/schemas/LogsStorageTier' - description: Order of logs in results. in: query name: sort diff --git a/api/datadogV2/api_logs.go b/api/datadogV2/api_logs.go index 8222826b556..1a009911d96 100644 --- a/api/datadogV2/api_logs.go +++ b/api/datadogV2/api_logs.go @@ -365,25 +365,27 @@ func (a *LogsApi) listLogsExecute(r apiListLogsRequest) (LogsListResponse, *_net } type apiListLogsGetRequest struct { - ctx _context.Context - filterQuery *string - filterIndex *string - filterFrom *time.Time - filterTo *time.Time - sort *LogsSort - pageCursor *string - pageLimit *int32 + ctx _context.Context + filterQuery *string + filterIndex *string + filterFrom *time.Time + filterTo *time.Time + filterStorageTier *LogsStorageTier + sort *LogsSort + pageCursor *string + pageLimit *int32 } // ListLogsGetOptionalParameters holds optional parameters for ListLogsGet. type ListLogsGetOptionalParameters struct { - FilterQuery *string - FilterIndex *string - FilterFrom *time.Time - FilterTo *time.Time - Sort *LogsSort - PageCursor *string - PageLimit *int32 + FilterQuery *string + FilterIndex *string + FilterFrom *time.Time + FilterTo *time.Time + FilterStorageTier *LogsStorageTier + Sort *LogsSort + PageCursor *string + PageLimit *int32 } // NewListLogsGetOptionalParameters creates an empty struct for parameters. @@ -416,6 +418,12 @@ func (r *ListLogsGetOptionalParameters) WithFilterTo(filterTo time.Time) *ListLo return r } +// WithFilterStorageTier sets the corresponding parameter name and returns the struct. +func (r *ListLogsGetOptionalParameters) WithFilterStorageTier(filterStorageTier LogsStorageTier) *ListLogsGetOptionalParameters { + r.FilterStorageTier = &filterStorageTier + return r +} + // WithSort sets the corresponding parameter name and returns the struct. func (r *ListLogsGetOptionalParameters) WithSort(sort LogsSort) *ListLogsGetOptionalParameters { r.Sort = &sort @@ -448,6 +456,7 @@ func (a *LogsApi) buildListLogsGetRequest(ctx _context.Context, o ...ListLogsGet req.filterIndex = o[0].FilterIndex req.filterFrom = o[0].FilterFrom req.filterTo = o[0].FilterTo + req.filterStorageTier = o[0].FilterStorageTier req.sort = o[0].Sort req.pageCursor = o[0].PageCursor req.pageLimit = o[0].PageLimit @@ -568,6 +577,9 @@ func (a *LogsApi) listLogsGetExecute(r apiListLogsGetRequest) (LogsListResponse, if r.filterTo != nil { localVarQueryParams.Add("filter[to]", datadog.ParameterToString(*r.filterTo, "")) } + if r.filterStorageTier != nil { + localVarQueryParams.Add("filter[storage_tier]", datadog.ParameterToString(*r.filterStorageTier, "")) + } if r.sort != nil { localVarQueryParams.Add("sort", datadog.ParameterToString(*r.sort, "")) } diff --git a/api/datadogV2/model_logs_query_filter.go b/api/datadogV2/model_logs_query_filter.go index caf96db380a..944a2e223e9 100644 --- a/api/datadogV2/model_logs_query_filter.go +++ b/api/datadogV2/model_logs_query_filter.go @@ -16,6 +16,8 @@ type LogsQueryFilter struct { Indexes []string `json:"indexes,omitempty"` // The search query - following the log search syntax. Query *string `json:"query,omitempty"` + // Specifies storage type as indexes or online-archives + StorageTier *LogsStorageTier `json:"storage_tier,omitempty"` // The maximum time for the requested logs, supports date math and regular timestamps (milliseconds). To *string `json:"to,omitempty"` // UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct @@ -33,6 +35,8 @@ func NewLogsQueryFilter() *LogsQueryFilter { this.From = &from var query string = "*" this.Query = &query + var storageTier LogsStorageTier = LOGSSTORAGETIER_INDEXES + this.StorageTier = &storageTier var to string = "now" this.To = &to return &this @@ -47,6 +51,8 @@ func NewLogsQueryFilterWithDefaults() *LogsQueryFilter { this.From = &from var query string = "*" this.Query = &query + var storageTier LogsStorageTier = LOGSSTORAGETIER_INDEXES + this.StorageTier = &storageTier var to string = "now" this.To = &to return &this @@ -136,6 +142,34 @@ func (o *LogsQueryFilter) SetQuery(v string) { o.Query = &v } +// GetStorageTier returns the StorageTier field value if set, zero value otherwise. +func (o *LogsQueryFilter) GetStorageTier() LogsStorageTier { + if o == nil || o.StorageTier == nil { + var ret LogsStorageTier + return ret + } + return *o.StorageTier +} + +// GetStorageTierOk returns a tuple with the StorageTier field value if set, nil otherwise +// and a boolean to check if the value has been set. +func (o *LogsQueryFilter) GetStorageTierOk() (*LogsStorageTier, bool) { + if o == nil || o.StorageTier == nil { + return nil, false + } + return o.StorageTier, true +} + +// HasStorageTier returns a boolean if a field has been set. +func (o *LogsQueryFilter) HasStorageTier() bool { + return o != nil && o.StorageTier != nil +} + +// SetStorageTier gets a reference to the given LogsStorageTier and assigns it to the StorageTier field. +func (o *LogsQueryFilter) SetStorageTier(v LogsStorageTier) { + o.StorageTier = &v +} + // GetTo returns the To field value if set, zero value otherwise. func (o *LogsQueryFilter) GetTo() string { if o == nil || o.To == nil { @@ -179,6 +213,9 @@ func (o LogsQueryFilter) MarshalJSON() ([]byte, error) { if o.Query != nil { toSerialize["query"] = o.Query } + if o.StorageTier != nil { + toSerialize["storage_tier"] = o.StorageTier + } if o.To != nil { toSerialize["to"] = o.To } @@ -193,10 +230,11 @@ func (o LogsQueryFilter) MarshalJSON() ([]byte, error) { func (o *LogsQueryFilter) UnmarshalJSON(bytes []byte) (err error) { raw := map[string]interface{}{} all := struct { - From *string `json:"from,omitempty"` - Indexes []string `json:"indexes,omitempty"` - Query *string `json:"query,omitempty"` - To *string `json:"to,omitempty"` + From *string `json:"from,omitempty"` + Indexes []string `json:"indexes,omitempty"` + Query *string `json:"query,omitempty"` + StorageTier *LogsStorageTier `json:"storage_tier,omitempty"` + To *string `json:"to,omitempty"` }{} err = json.Unmarshal(bytes, &all) if err != nil { @@ -207,9 +245,18 @@ func (o *LogsQueryFilter) UnmarshalJSON(bytes []byte) (err error) { o.UnparsedObject = raw return nil } + if v := all.StorageTier; v != nil && !v.IsValid() { + err = json.Unmarshal(bytes, &raw) + if err != nil { + return err + } + o.UnparsedObject = raw + return nil + } o.From = all.From o.Indexes = all.Indexes o.Query = all.Query + o.StorageTier = all.StorageTier o.To = all.To return nil } diff --git a/api/datadogV2/model_logs_storage_tier.go b/api/datadogV2/model_logs_storage_tier.go new file mode 100644 index 00000000000..88e16178f06 --- /dev/null +++ b/api/datadogV2/model_logs_storage_tier.go @@ -0,0 +1,109 @@ +// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License. +// This product includes software developed at Datadog (https://www.datadoghq.com/). +// Copyright 2019-Present Datadog, Inc. + +package datadogV2 + +import ( + "encoding/json" + "fmt" +) + +// LogsStorageTier Specifies storage type as indexes or online-archives +type LogsStorageTier string + +// List of LogsStorageTier. +const ( + LOGSSTORAGETIER_INDEXES LogsStorageTier = "indexes" + LOGSSTORAGETIER_ONLINE_ARCHIVES LogsStorageTier = "online-archives" +) + +var allowedLogsStorageTierEnumValues = []LogsStorageTier{ + LOGSSTORAGETIER_INDEXES, + LOGSSTORAGETIER_ONLINE_ARCHIVES, +} + +// GetAllowedValues reeturns the list of possible values. +func (v *LogsStorageTier) GetAllowedValues() []LogsStorageTier { + return allowedLogsStorageTierEnumValues +} + +// UnmarshalJSON deserializes the given payload. +func (v *LogsStorageTier) UnmarshalJSON(src []byte) error { + var value string + err := json.Unmarshal(src, &value) + if err != nil { + return err + } + *v = LogsStorageTier(value) + return nil +} + +// NewLogsStorageTierFromValue returns a pointer to a valid LogsStorageTier +// for the value passed as argument, or an error if the value passed is not allowed by the enum. +func NewLogsStorageTierFromValue(v string) (*LogsStorageTier, error) { + ev := LogsStorageTier(v) + if ev.IsValid() { + return &ev, nil + } + return nil, fmt.Errorf("invalid value '%v' for LogsStorageTier: valid values are %v", v, allowedLogsStorageTierEnumValues) +} + +// IsValid return true if the value is valid for the enum, false otherwise. +func (v LogsStorageTier) IsValid() bool { + for _, existing := range allowedLogsStorageTierEnumValues { + if existing == v { + return true + } + } + return false +} + +// Ptr returns reference to LogsStorageTier value. +func (v LogsStorageTier) Ptr() *LogsStorageTier { + return &v +} + +// NullableLogsStorageTier handles when a null is used for LogsStorageTier. +type NullableLogsStorageTier struct { + value *LogsStorageTier + isSet bool +} + +// Get returns the associated value. +func (v NullableLogsStorageTier) Get() *LogsStorageTier { + return v.value +} + +// Set changes the value and indicates it's been called. +func (v *NullableLogsStorageTier) Set(val *LogsStorageTier) { + v.value = val + v.isSet = true +} + +// IsSet returns whether Set has been called. +func (v NullableLogsStorageTier) IsSet() bool { + return v.isSet +} + +// Unset sets the value to nil and resets the set flag. +func (v *NullableLogsStorageTier) Unset() { + v.value = nil + v.isSet = false +} + +// NewNullableLogsStorageTier initializes the struct as if Set has been called. +func NewNullableLogsStorageTier(val *LogsStorageTier) *NullableLogsStorageTier { + return &NullableLogsStorageTier{value: val, isSet: true} +} + +// MarshalJSON serializes the associated value. +func (v NullableLogsStorageTier) MarshalJSON() ([]byte, error) { + return json.Marshal(v.value) +} + +// UnmarshalJSON deserializes the payload and sets the flag as if Set has been called. +func (v *NullableLogsStorageTier) UnmarshalJSON(src []byte) error { + v.isSet = true + return json.Unmarshal(src, &v.value) +} diff --git a/tests/scenarios/features/v2/logs.feature b/tests/scenarios/features/v2/logs.feature index 7041773c7fc..3641f8da430 100644 --- a/tests/scenarios/features/v2/logs.feature +++ b/tests/scenarios/features/v2/logs.feature @@ -26,7 +26,7 @@ Feature: Logs Scenario: Aggregate events returns "Bad Request" response Given a valid "appKeyAuth" key in the system And new "AggregateLogs" request - And body with value {"compute": [{"aggregation": "pc90", "interval": "5m", "metric": "@duration", "type": "total"}], "filter": {"from": "now-15m", "indexes": ["main", "web"], "query": "service:web* AND @http.status_code:[200 TO 299]", "to": "now"}, "group_by": [{"facet": "host", "histogram": {"interval": 10, "max": 100, "min": 50}, "limit": 10, "sort": {"aggregation": "count", "order": "asc"}, "total": false}], "options": {"timezone": "GMT"}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ=="}} + And body with value {"compute": [{"aggregation": "pc90", "interval": "5m", "metric": "@duration", "type": "total"}], "filter": {"from": "now-15m", "indexes": ["main", "web"], "query": "service:web* AND @http.status_code:[200 TO 299]", "storage_tier": "indexes", "to": "now"}, "group_by": [{"facet": "host", "histogram": {"interval": 10, "max": 100, "min": 50}, "limit": 10, "sort": {"aggregation": "count", "order": "asc"}, "total": false}], "options": {"timezone": "GMT"}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ=="}} When the request is sent Then the response status is 400 Bad Request @@ -77,7 +77,7 @@ Feature: Logs Scenario: Search logs returns "Bad Request" response Given a valid "appKeyAuth" key in the system And new "ListLogs" request - And body with value {"filter": {"from": "now-15m", "indexes": ["main", "web"], "query": "service:web* AND @http.status_code:[200 TO 299]", "to": "now"}, "options": {"timezone": "GMT"}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "timestamp"} + And body with value {"filter": {"from": "now-15m", "indexes": ["main", "web"], "query": "service:web* AND @http.status_code:[200 TO 299]", "storage_tier": "indexes", "to": "now"}, "options": {"timezone": "GMT"}, "page": {"cursor": "eyJzdGFydEF0IjoiQVFBQUFYS2tMS3pPbm40NGV3QUFBQUJCV0V0clRFdDZVbG8zY3pCRmNsbHJiVmxDWlEifQ==", "limit": 25}, "sort": "timestamp"} When the request is sent Then the response status is 400 Bad Request