Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for querying logs in Online Archives #1711

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions .apigentools-info
Original file line number Diff line number Diff line change
Expand Up @@ -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:15:19.092009",
"spec_repo_commit": "ecf2f022"
},
"v2": {
"apigentools_version": "1.6.4",
"regenerated": "2022-10-24 13:15:47.335958",
"spec_repo_commit": "18dc2450"
"regenerated": "2022-10-25 14:15:19.105318",
"spec_repo_commit": "ecf2f022"
}
}
}
20 changes: 20 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
42 changes: 27 additions & 15 deletions api/datadogV2/api_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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, ""))
}
Expand Down
55 changes: 51 additions & 4 deletions api/datadogV2/model_logs_query_filter.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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
}
Expand All @@ -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 {
Expand All @@ -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
}
109 changes: 109 additions & 0 deletions api/datadogV2/model_logs_storage_tier.go
Original file line number Diff line number Diff line change
@@ -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)
}
2 changes: 1 addition & 1 deletion tests/api/datadogV1/cassettes/TestLogsList.freeze
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2022-04-22T13:01:55.352493+02:00
2022-10-25T10:03:50.284527-04:00
Loading