Skip to content

Commit 289b32d

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Add pagination and sorting parameters on suppression list (#3598)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 9c77a21 commit 289b32d

25 files changed

Lines changed: 1092 additions & 35 deletions

File tree

.generator/schemas/v2/openapi.yaml

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49256,6 +49256,18 @@ components:
4925649256
meta:
4925749257
$ref: '#/components/schemas/ResponseMetaAttributes'
4925849258
type: object
49259+
SecurityMonitoringPaginatedSuppressionsResponse:
49260+
description: Response object containing the available suppression rules with
49261+
pagination metadata.
49262+
properties:
49263+
data:
49264+
description: A list of suppressions objects.
49265+
items:
49266+
$ref: '#/components/schemas/SecurityMonitoringSuppression'
49267+
type: array
49268+
meta:
49269+
$ref: '#/components/schemas/SecurityMonitoringSuppressionsMeta'
49270+
type: object
4925949271
SecurityMonitoringReferenceTable:
4926049272
description: Reference tables used in the queries.
4926149273
properties:
@@ -51405,6 +51417,31 @@ components:
5140551417
data:
5140651418
$ref: '#/components/schemas/SecurityMonitoringSuppression'
5140751419
type: object
51420+
SecurityMonitoringSuppressionSort:
51421+
description: The sort parameters used for querying suppression rules.
51422+
enum:
51423+
- name
51424+
- start_date
51425+
- expiration_date
51426+
- update_date
51427+
- enabled
51428+
- -name
51429+
- -start_date
51430+
- -expiration_date
51431+
- -update_date
51432+
- -enabled
51433+
type: string
51434+
x-enum-varnames:
51435+
- NAME
51436+
- START_DATE
51437+
- EXPIRATION_DATE
51438+
- UPDATE_DATE
51439+
- ENABLED
51440+
- NAME_DESCENDING
51441+
- START_DATE_DESCENDING
51442+
- EXPIRATION_DATE_DESCENDING
51443+
- UPDATE_DATE_DESCENDING
51444+
- ENABLED_DESCENDING
5140851445
SecurityMonitoringSuppressionType:
5140951446
default: suppressions
5141051447
description: The type of the resource. The value should always be `suppressions`.
@@ -51500,6 +51537,31 @@ components:
5150051537
required:
5150151538
- data
5150251539
type: object
51540+
SecurityMonitoringSuppressionsMeta:
51541+
description: Metadata for the suppression list response.
51542+
properties:
51543+
page:
51544+
$ref: '#/components/schemas/SecurityMonitoringSuppressionsPageMeta'
51545+
type: object
51546+
SecurityMonitoringSuppressionsPageMeta:
51547+
description: Pagination metadata.
51548+
properties:
51549+
pageNumber:
51550+
description: Current page number.
51551+
example: 0
51552+
format: int64
51553+
type: integer
51554+
pageSize:
51555+
description: Current page size.
51556+
example: 2
51557+
format: int64
51558+
type: integer
51559+
totalCount:
51560+
description: Total count of suppressions.
51561+
example: 2
51562+
format: int64
51563+
type: integer
51564+
type: object
5150351565
SecurityMonitoringSuppressionsResponse:
5150451566
description: Response object containing the available suppression rules.
5150551567
properties:
@@ -85670,12 +85732,29 @@ paths:
8567085732
required: false
8567185733
schema:
8567285734
type: string
85735+
- description: Attribute used to sort the list of suppression rules. Prefix
85736+
with `-` to sort in descending order.
85737+
in: query
85738+
name: sort
85739+
required: false
85740+
schema:
85741+
$ref: '#/components/schemas/SecurityMonitoringSuppressionSort'
85742+
- description: Size for a given page. Use `-1` to return all items.
85743+
in: query
85744+
name: page[size]
85745+
required: false
85746+
schema:
85747+
default: -1
85748+
example: 10
85749+
format: int64
85750+
type: integer
85751+
- $ref: '#/components/parameters/PageNumber'
8567385752
responses:
8567485753
'200':
8567585754
content:
8567685755
application/json:
8567785756
schema:
85678-
$ref: '#/components/schemas/SecurityMonitoringSuppressionsResponse'
85757+
$ref: '#/components/schemas/SecurityMonitoringPaginatedSuppressionsResponse'
8567985758
description: OK
8568085759
'403':
8568185760
$ref: '#/components/responses/NotAuthorizedResponse'

api/datadogV2/api_security_monitoring.go

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5948,7 +5948,10 @@ func (a *SecurityMonitoringApi) ListSecurityMonitoringSignalsWithPagination(ctx
59485948

59495949
// ListSecurityMonitoringSuppressionsOptionalParameters holds optional parameters for ListSecurityMonitoringSuppressions.
59505950
type ListSecurityMonitoringSuppressionsOptionalParameters struct {
5951-
Query *string
5951+
Query *string
5952+
Sort *SecurityMonitoringSuppressionSort
5953+
PageSize *int64
5954+
PageNumber *int64
59525955
}
59535956

59545957
// NewListSecurityMonitoringSuppressionsOptionalParameters creates an empty struct for parameters.
@@ -5963,13 +5966,31 @@ func (r *ListSecurityMonitoringSuppressionsOptionalParameters) WithQuery(query s
59635966
return r
59645967
}
59655968

5969+
// WithSort sets the corresponding parameter name and returns the struct.
5970+
func (r *ListSecurityMonitoringSuppressionsOptionalParameters) WithSort(sort SecurityMonitoringSuppressionSort) *ListSecurityMonitoringSuppressionsOptionalParameters {
5971+
r.Sort = &sort
5972+
return r
5973+
}
5974+
5975+
// WithPageSize sets the corresponding parameter name and returns the struct.
5976+
func (r *ListSecurityMonitoringSuppressionsOptionalParameters) WithPageSize(pageSize int64) *ListSecurityMonitoringSuppressionsOptionalParameters {
5977+
r.PageSize = &pageSize
5978+
return r
5979+
}
5980+
5981+
// WithPageNumber sets the corresponding parameter name and returns the struct.
5982+
func (r *ListSecurityMonitoringSuppressionsOptionalParameters) WithPageNumber(pageNumber int64) *ListSecurityMonitoringSuppressionsOptionalParameters {
5983+
r.PageNumber = &pageNumber
5984+
return r
5985+
}
5986+
59665987
// ListSecurityMonitoringSuppressions Get all suppression rules.
59675988
// Get the list of all suppression rules.
5968-
func (a *SecurityMonitoringApi) ListSecurityMonitoringSuppressions(ctx _context.Context, o ...ListSecurityMonitoringSuppressionsOptionalParameters) (SecurityMonitoringSuppressionsResponse, *_nethttp.Response, error) {
5989+
func (a *SecurityMonitoringApi) ListSecurityMonitoringSuppressions(ctx _context.Context, o ...ListSecurityMonitoringSuppressionsOptionalParameters) (SecurityMonitoringPaginatedSuppressionsResponse, *_nethttp.Response, error) {
59695990
var (
59705991
localVarHTTPMethod = _nethttp.MethodGet
59715992
localVarPostBody interface{}
5972-
localVarReturnValue SecurityMonitoringSuppressionsResponse
5993+
localVarReturnValue SecurityMonitoringPaginatedSuppressionsResponse
59735994
optionalParams ListSecurityMonitoringSuppressionsOptionalParameters
59745995
)
59755996

@@ -5993,6 +6014,15 @@ func (a *SecurityMonitoringApi) ListSecurityMonitoringSuppressions(ctx _context.
59936014
if optionalParams.Query != nil {
59946015
localVarQueryParams.Add("query", datadog.ParameterToString(*optionalParams.Query, ""))
59956016
}
6017+
if optionalParams.Sort != nil {
6018+
localVarQueryParams.Add("sort", datadog.ParameterToString(*optionalParams.Sort, ""))
6019+
}
6020+
if optionalParams.PageSize != nil {
6021+
localVarQueryParams.Add("page[size]", datadog.ParameterToString(*optionalParams.PageSize, ""))
6022+
}
6023+
if optionalParams.PageNumber != nil {
6024+
localVarQueryParams.Add("page[number]", datadog.ParameterToString(*optionalParams.PageNumber, ""))
6025+
}
59966026
localVarHeaderParams["Accept"] = "application/json"
59976027

59986028
if a.Client.Cfg.DelegatedTokenConfig != nil {
Lines changed: 146 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache-2.0 License.
2+
// This product includes software developed at Datadog (https://www.datadoghq.com/).
3+
// Copyright 2019-Present Datadog, Inc.
4+
5+
package datadogV2
6+
7+
import (
8+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
9+
)
10+
11+
// SecurityMonitoringPaginatedSuppressionsResponse Response object containing the available suppression rules with pagination metadata.
12+
type SecurityMonitoringPaginatedSuppressionsResponse struct {
13+
// A list of suppressions objects.
14+
Data []SecurityMonitoringSuppression `json:"data,omitempty"`
15+
// Metadata for the suppression list response.
16+
Meta *SecurityMonitoringSuppressionsMeta `json:"meta,omitempty"`
17+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
18+
UnparsedObject map[string]interface{} `json:"-"`
19+
AdditionalProperties map[string]interface{} `json:"-"`
20+
}
21+
22+
// NewSecurityMonitoringPaginatedSuppressionsResponse instantiates a new SecurityMonitoringPaginatedSuppressionsResponse object.
23+
// This constructor will assign default values to properties that have it defined,
24+
// and makes sure properties required by API are set, but the set of arguments
25+
// will change when the set of required properties is changed.
26+
func NewSecurityMonitoringPaginatedSuppressionsResponse() *SecurityMonitoringPaginatedSuppressionsResponse {
27+
this := SecurityMonitoringPaginatedSuppressionsResponse{}
28+
return &this
29+
}
30+
31+
// NewSecurityMonitoringPaginatedSuppressionsResponseWithDefaults instantiates a new SecurityMonitoringPaginatedSuppressionsResponse object.
32+
// This constructor will only assign default values to properties that have it defined,
33+
// but it doesn't guarantee that properties required by API are set.
34+
func NewSecurityMonitoringPaginatedSuppressionsResponseWithDefaults() *SecurityMonitoringPaginatedSuppressionsResponse {
35+
this := SecurityMonitoringPaginatedSuppressionsResponse{}
36+
return &this
37+
}
38+
39+
// GetData returns the Data field value if set, zero value otherwise.
40+
func (o *SecurityMonitoringPaginatedSuppressionsResponse) GetData() []SecurityMonitoringSuppression {
41+
if o == nil || o.Data == nil {
42+
var ret []SecurityMonitoringSuppression
43+
return ret
44+
}
45+
return o.Data
46+
}
47+
48+
// GetDataOk returns a tuple with the Data field value if set, nil otherwise
49+
// and a boolean to check if the value has been set.
50+
func (o *SecurityMonitoringPaginatedSuppressionsResponse) GetDataOk() (*[]SecurityMonitoringSuppression, bool) {
51+
if o == nil || o.Data == nil {
52+
return nil, false
53+
}
54+
return &o.Data, true
55+
}
56+
57+
// HasData returns a boolean if a field has been set.
58+
func (o *SecurityMonitoringPaginatedSuppressionsResponse) HasData() bool {
59+
return o != nil && o.Data != nil
60+
}
61+
62+
// SetData gets a reference to the given []SecurityMonitoringSuppression and assigns it to the Data field.
63+
func (o *SecurityMonitoringPaginatedSuppressionsResponse) SetData(v []SecurityMonitoringSuppression) {
64+
o.Data = v
65+
}
66+
67+
// GetMeta returns the Meta field value if set, zero value otherwise.
68+
func (o *SecurityMonitoringPaginatedSuppressionsResponse) GetMeta() SecurityMonitoringSuppressionsMeta {
69+
if o == nil || o.Meta == nil {
70+
var ret SecurityMonitoringSuppressionsMeta
71+
return ret
72+
}
73+
return *o.Meta
74+
}
75+
76+
// GetMetaOk returns a tuple with the Meta field value if set, nil otherwise
77+
// and a boolean to check if the value has been set.
78+
func (o *SecurityMonitoringPaginatedSuppressionsResponse) GetMetaOk() (*SecurityMonitoringSuppressionsMeta, bool) {
79+
if o == nil || o.Meta == nil {
80+
return nil, false
81+
}
82+
return o.Meta, true
83+
}
84+
85+
// HasMeta returns a boolean if a field has been set.
86+
func (o *SecurityMonitoringPaginatedSuppressionsResponse) HasMeta() bool {
87+
return o != nil && o.Meta != nil
88+
}
89+
90+
// SetMeta gets a reference to the given SecurityMonitoringSuppressionsMeta and assigns it to the Meta field.
91+
func (o *SecurityMonitoringPaginatedSuppressionsResponse) SetMeta(v SecurityMonitoringSuppressionsMeta) {
92+
o.Meta = &v
93+
}
94+
95+
// MarshalJSON serializes the struct using spec logic.
96+
func (o SecurityMonitoringPaginatedSuppressionsResponse) MarshalJSON() ([]byte, error) {
97+
toSerialize := map[string]interface{}{}
98+
if o.UnparsedObject != nil {
99+
return datadog.Marshal(o.UnparsedObject)
100+
}
101+
if o.Data != nil {
102+
toSerialize["data"] = o.Data
103+
}
104+
if o.Meta != nil {
105+
toSerialize["meta"] = o.Meta
106+
}
107+
108+
for key, value := range o.AdditionalProperties {
109+
toSerialize[key] = value
110+
}
111+
return datadog.Marshal(toSerialize)
112+
}
113+
114+
// UnmarshalJSON deserializes the given payload.
115+
func (o *SecurityMonitoringPaginatedSuppressionsResponse) UnmarshalJSON(bytes []byte) (err error) {
116+
all := struct {
117+
Data []SecurityMonitoringSuppression `json:"data,omitempty"`
118+
Meta *SecurityMonitoringSuppressionsMeta `json:"meta,omitempty"`
119+
}{}
120+
if err = datadog.Unmarshal(bytes, &all); err != nil {
121+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
122+
}
123+
additionalProperties := make(map[string]interface{})
124+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
125+
datadog.DeleteKeys(additionalProperties, &[]string{"data", "meta"})
126+
} else {
127+
return err
128+
}
129+
130+
hasInvalidField := false
131+
o.Data = all.Data
132+
if all.Meta != nil && all.Meta.UnparsedObject != nil && o.UnparsedObject == nil {
133+
hasInvalidField = true
134+
}
135+
o.Meta = all.Meta
136+
137+
if len(additionalProperties) > 0 {
138+
o.AdditionalProperties = additionalProperties
139+
}
140+
141+
if hasInvalidField {
142+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
143+
}
144+
145+
return nil
146+
}

0 commit comments

Comments
 (0)