-
Notifications
You must be signed in to change notification settings - Fork 58
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
Updated OpenAPI logs_pattern_query to support Patterns for any attribute #2797
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -12,6 +12,8 @@ import ( | |||||
|
||||||
// ListStreamQuery Updated list stream widget. | ||||||
type ListStreamQuery struct { | ||||||
// Specifies the field for logs pattern clustering. Usable only with logs_pattern_stream. | ||||||
ClusteringPatternFieldPath *string `json:"clustering_pattern_field_path,omitempty"` | ||||||
// Compute configuration for the List Stream Widget. Compute can be used only with the logs_transaction_stream (from 1 to 5 items) list stream source. | ||||||
Compute []ListStreamComputeItems `json:"compute,omitempty"` | ||||||
// Source from which to query items to display in the stream. | ||||||
|
@@ -39,6 +41,8 @@ type ListStreamQuery struct { | |||||
// will change when the set of required properties is changed. | ||||||
func NewListStreamQuery(dataSource ListStreamSource, queryString string) *ListStreamQuery { | ||||||
this := ListStreamQuery{} | ||||||
var clusteringPatternFieldPath string = "message" | ||||||
this.ClusteringPatternFieldPath = &clusteringPatternFieldPath | ||||||
this.DataSource = dataSource | ||||||
this.QueryString = queryString | ||||||
return &this | ||||||
|
@@ -49,11 +53,41 @@ func NewListStreamQuery(dataSource ListStreamSource, queryString string) *ListSt | |||||
// but it doesn't guarantee that properties required by API are set. | ||||||
func NewListStreamQueryWithDefaults() *ListStreamQuery { | ||||||
this := ListStreamQuery{} | ||||||
var clusteringPatternFieldPath string = "message" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔵 Code Quality Violation
Suggested change
redundant type declaration (...read more)In Go, it is considered good practice to avoid declaring the type when it is obvious or when the type can be inferred from the assignment. This is known as type inference, and it offers several benefits:
That being said, it is important to strike a balance and avoid excessive use of type inference. Clear and explicit type declarations are still valuable when they enhance code clarity, such as when documenting or expressing the intent of the code. It is essential to find the right balance between brevity and clarity in your codebase. By utilizing Go's type inference mechanism and avoiding explicit type declarations when the type is obvious, you can achieve more readable, maintainable, and concise code that adheres to Go's idiomatic style. |
||||||
this.ClusteringPatternFieldPath = &clusteringPatternFieldPath | ||||||
var dataSource ListStreamSource = LISTSTREAMSOURCE_APM_ISSUE_STREAM | ||||||
this.DataSource = dataSource | ||||||
return &this | ||||||
} | ||||||
|
||||||
// GetClusteringPatternFieldPath returns the ClusteringPatternFieldPath field value if set, zero value otherwise. | ||||||
func (o *ListStreamQuery) GetClusteringPatternFieldPath() string { | ||||||
if o == nil || o.ClusteringPatternFieldPath == nil { | ||||||
var ret string | ||||||
return ret | ||||||
} | ||||||
return *o.ClusteringPatternFieldPath | ||||||
} | ||||||
|
||||||
// GetClusteringPatternFieldPathOk returns a tuple with the ClusteringPatternFieldPath field value if set, nil otherwise | ||||||
// and a boolean to check if the value has been set. | ||||||
func (o *ListStreamQuery) GetClusteringPatternFieldPathOk() (*string, bool) { | ||||||
if o == nil || o.ClusteringPatternFieldPath == nil { | ||||||
return nil, false | ||||||
} | ||||||
return o.ClusteringPatternFieldPath, true | ||||||
} | ||||||
|
||||||
// HasClusteringPatternFieldPath returns a boolean if a field has been set. | ||||||
func (o *ListStreamQuery) HasClusteringPatternFieldPath() bool { | ||||||
return o != nil && o.ClusteringPatternFieldPath != nil | ||||||
} | ||||||
|
||||||
// SetClusteringPatternFieldPath gets a reference to the given string and assigns it to the ClusteringPatternFieldPath field. | ||||||
func (o *ListStreamQuery) SetClusteringPatternFieldPath(v string) { | ||||||
o.ClusteringPatternFieldPath = &v | ||||||
} | ||||||
|
||||||
// GetCompute returns the Compute field value if set, zero value otherwise. | ||||||
func (o *ListStreamQuery) GetCompute() []ListStreamComputeItems { | ||||||
if o == nil || o.Compute == nil { | ||||||
|
@@ -274,6 +308,9 @@ func (o ListStreamQuery) MarshalJSON() ([]byte, error) { | |||||
if o.UnparsedObject != nil { | ||||||
return datadog.Marshal(o.UnparsedObject) | ||||||
} | ||||||
if o.ClusteringPatternFieldPath != nil { | ||||||
toSerialize["clustering_pattern_field_path"] = o.ClusteringPatternFieldPath | ||||||
} | ||||||
if o.Compute != nil { | ||||||
toSerialize["compute"] = o.Compute | ||||||
} | ||||||
|
@@ -304,14 +341,15 @@ func (o ListStreamQuery) MarshalJSON() ([]byte, error) { | |||||
// UnmarshalJSON deserializes the given payload. | ||||||
func (o *ListStreamQuery) UnmarshalJSON(bytes []byte) (err error) { | ||||||
all := struct { | ||||||
Compute []ListStreamComputeItems `json:"compute,omitempty"` | ||||||
DataSource *ListStreamSource `json:"data_source"` | ||||||
EventSize *WidgetEventSize `json:"event_size,omitempty"` | ||||||
GroupBy []ListStreamGroupByItems `json:"group_by,omitempty"` | ||||||
Indexes []string `json:"indexes,omitempty"` | ||||||
QueryString *string `json:"query_string"` | ||||||
Sort *WidgetFieldSort `json:"sort,omitempty"` | ||||||
Storage *string `json:"storage,omitempty"` | ||||||
ClusteringPatternFieldPath *string `json:"clustering_pattern_field_path,omitempty"` | ||||||
Compute []ListStreamComputeItems `json:"compute,omitempty"` | ||||||
DataSource *ListStreamSource `json:"data_source"` | ||||||
EventSize *WidgetEventSize `json:"event_size,omitempty"` | ||||||
GroupBy []ListStreamGroupByItems `json:"group_by,omitempty"` | ||||||
Indexes []string `json:"indexes,omitempty"` | ||||||
QueryString *string `json:"query_string"` | ||||||
Sort *WidgetFieldSort `json:"sort,omitempty"` | ||||||
Storage *string `json:"storage,omitempty"` | ||||||
}{} | ||||||
if err = datadog.Unmarshal(bytes, &all); err != nil { | ||||||
return datadog.Unmarshal(bytes, &o.UnparsedObject) | ||||||
|
@@ -324,12 +362,13 @@ func (o *ListStreamQuery) UnmarshalJSON(bytes []byte) (err error) { | |||||
} | ||||||
additionalProperties := make(map[string]interface{}) | ||||||
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil { | ||||||
datadog.DeleteKeys(additionalProperties, &[]string{"compute", "data_source", "event_size", "group_by", "indexes", "query_string", "sort", "storage"}) | ||||||
datadog.DeleteKeys(additionalProperties, &[]string{"clustering_pattern_field_path", "compute", "data_source", "event_size", "group_by", "indexes", "query_string", "sort", "storage"}) | ||||||
} else { | ||||||
return err | ||||||
} | ||||||
|
||||||
hasInvalidField := false | ||||||
o.ClusteringPatternFieldPath = all.ClusteringPatternFieldPath | ||||||
o.Compute = all.Compute | ||||||
if !all.DataSource.IsValid() { | ||||||
hasInvalidField = true | ||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2024-11-15T19:32:46.627Z | ||
2024-11-20T19:43:46.485Z |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
interactions: | ||
- request: | ||
body: | | ||
{"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_logs_pattern_stream_list_stream_widget-1731699166 with list_stream widget","widgets":[{"definition":{"requests":[{"columns":[{"field":"timestamp","width":"auto"}],"query":{"data_source":"logs_pattern_stream","group_by":[{"facet":"service"}],"query_string":""},"response_format":"event_list"}],"type":"list_stream"}}]} | ||
{"layout_type":"ordered","title":"Test-Create_a_new_dashboard_with_logs_pattern_stream_list_stream_widget-1732131826 with list_stream widget","widgets":[{"definition":{"requests":[{"columns":[{"field":"timestamp","width":"auto"},{"field":"message","is_clustering_pattern_field_path":true,"width":"auto"}],"query":{"clustering_pattern_field_path":"message","data_source":"logs_pattern_stream","group_by":[{"facet":"service"}],"query_string":""},"response_format":"event_list"}],"type":"list_stream"}}]} | ||
form: {} | ||
headers: | ||
Accept: | ||
|
@@ -12,8 +12,9 @@ interactions: | |
method: POST | ||
url: https://api.datadoghq.com/api/v1/dashboard | ||
response: | ||
body: '{"id":"hem-inu-je6","title":"Test-Create_a_new_dashboard_with_logs_pattern_stream_list_stream_widget-1731699166 | ||
with list_stream widget","description":null,"author_handle":"[email protected]","author_name":null,"layout_type":"ordered","url":"/dashboard/hem-inu-je6/test-createanewdashboardwithlogspatternstreamliststreamwidget-1731699166-with-li","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"requests":[{"columns":[{"field":"timestamp","width":"auto"}],"query":{"data_source":"logs_pattern_stream","group_by":[{"facet":"service"}],"query_string":""},"response_format":"event_list"}],"type":"list_stream"},"id":4012469646916199}],"notify_list":null,"created_at":"2024-11-15T19:32:46.772627+00:00","modified_at":"2024-11-15T19:32:46.772627+00:00","restricted_roles":[]} | ||
body: '{"id":"r75-hd7-sd9","title":"Test-Create_a_new_dashboard_with_logs_pattern_stream_list_stream_widget-1732131826 | ||
with list_stream widget","description":null,"author_handle":"9919ec9b-ebc7-49ee-8dc8-03626e717cca","author_name":"CI | ||
Account","layout_type":"ordered","url":"/dashboard/r75-hd7-sd9/test-createanewdashboardwithlogspatternstreamliststreamwidget-1732131826-with-li","is_read_only":false,"template_variables":null,"widgets":[{"definition":{"requests":[{"columns":[{"field":"timestamp","width":"auto"},{"field":"message","is_clustering_pattern_field_path":true,"width":"auto"}],"query":{"clustering_pattern_field_path":"message","data_source":"logs_pattern_stream","group_by":[{"facet":"service"}],"query_string":""},"response_format":"event_list"}],"type":"list_stream"},"id":6154246442450384}],"notify_list":null,"created_at":"2024-11-20T19:43:46.871965+00:00","modified_at":"2024-11-20T19:43:46.871965+00:00","restricted_roles":[]} | ||
|
||
' | ||
code: 200 | ||
|
@@ -30,9 +31,9 @@ interactions: | |
- application/json | ||
id: 1 | ||
method: DELETE | ||
url: https://api.datadoghq.com/api/v1/dashboard/hem-inu-je6 | ||
url: https://api.datadoghq.com/api/v1/dashboard/r75-hd7-sd9 | ||
response: | ||
body: '{"deleted_dashboard_id":"hem-inu-je6"} | ||
body: '{"deleted_dashboard_id":"r75-hd7-sd9"} | ||
|
||
' | ||
code: 200 | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔵 Code Quality Violation
redundant type declaration (...read more)
In Go, it is considered good practice to avoid declaring the type when it is obvious or when the type can be inferred from the assignment. This is known as type inference, and it offers several benefits:
That being said, it is important to strike a balance and avoid excessive use of type inference. Clear and explicit type declarations are still valuable when they enhance code clarity, such as when documenting or expressing the intent of the code. It is essential to find the right balance between brevity and clarity in your codebase.
By utilizing Go's type inference mechanism and avoiding explicit type declarations when the type is obvious, you can achieve more readable, maintainable, and concise code that adheres to Go's idiomatic style.