Skip to content

Commit

Permalink
Regenerate client from commit 4da98699 of spec repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ci.datadog-api-spec committed Sep 27, 2024
1 parent 68095bc commit 311820d
Show file tree
Hide file tree
Showing 8 changed files with 179 additions and 4 deletions.
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.6",
"regenerated": "2024-09-26 19:34:36.100160",
"spec_repo_commit": "83debf9e"
"regenerated": "2024-09-27 20:18:41.669122",
"spec_repo_commit": "4da98699"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-09-26 19:34:36.115212",
"spec_repo_commit": "83debf9e"
"regenerated": "2024-09-27 20:18:41.682992",
"spec_repo_commit": "4da98699"
}
}
}
25 changes: 25 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9183,6 +9183,20 @@ components:
tags:
$ref: '#/components/schemas/FindingTags'
type: object
FindingDetectionType:
description: The detection type of the finding.
enum:
- misconfiguration
- attack_path
- identity_risk
- api_security
example: misconfiguration
type: string
x-enum-varnames:
- MISCONFIGURATION
- ATTACK_PATH
- IDENTITY_RISK
- API_SECURITY
FindingEvaluation:
description: The evaluation of the finding.
enum:
Expand Down Expand Up @@ -33704,6 +33718,17 @@ paths:
required: false
schema:
type: string
- description: Return findings that match the selected detection types (repeatable).
example:
- misconfiguration
explode: true
in: query
name: filter[detection_type]
required: false
schema:
items:
$ref: '#/components/schemas/FindingDetectionType'
type: array
- description: Return findings that have these associated tags (repeatable).
example: filter[tags]=cloud_provider:aws&filter[tags]=aws_account:999999999999
in: query
Expand Down
19 changes: 19 additions & 0 deletions api/datadogV2/api_security_monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
_log "log"
_nethttp "net/http"
_neturl "net/url"
"reflect"
"strings"
"time"

Expand Down Expand Up @@ -1190,6 +1191,7 @@ type ListFindingsOptionalParameters struct {
PageLimit *int64
SnapshotTimestamp *int64
PageCursor *string
FilterDetectionType *[]FindingDetectionType
FilterTags *string
FilterEvaluationChangedAt *string
FilterMuted *bool
Expand Down Expand Up @@ -1225,6 +1227,12 @@ func (r *ListFindingsOptionalParameters) WithPageCursor(pageCursor string) *List
return r
}

// WithFilterDetectionType sets the corresponding parameter name and returns the struct.
func (r *ListFindingsOptionalParameters) WithFilterDetectionType(filterDetectionType []FindingDetectionType) *ListFindingsOptionalParameters {
r.FilterDetectionType = &filterDetectionType
return r
}

// WithFilterTags sets the corresponding parameter name and returns the struct.
func (r *ListFindingsOptionalParameters) WithFilterTags(filterTags string) *ListFindingsOptionalParameters {
r.FilterTags = &filterTags
Expand Down Expand Up @@ -1351,6 +1359,17 @@ func (a *SecurityMonitoringApi) ListFindings(ctx _context.Context, o ...ListFind
if optionalParams.PageCursor != nil {
localVarQueryParams.Add("page[cursor]", datadog.ParameterToString(*optionalParams.PageCursor, ""))
}
if optionalParams.FilterDetectionType != nil {
t := *optionalParams.FilterDetectionType
if reflect.TypeOf(t).Kind() == reflect.Slice {
s := reflect.ValueOf(t)
for i := 0; i < s.Len(); i++ {
localVarQueryParams.Add("filter[detection_type]", datadog.ParameterToString(s.Index(i), "multi"))
}
} else {
localVarQueryParams.Add("filter[detection_type]", datadog.ParameterToString(t, "multi"))
}
}
if optionalParams.FilterTags != nil {
localVarQueryParams.Add("filter[tags]", datadog.ParameterToString(*optionalParams.FilterTags, ""))
}
Expand Down
70 changes: 70 additions & 0 deletions api/datadogV2/model_finding_detection_type.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
// 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"
)

// FindingDetectionType The detection type of the finding.
type FindingDetectionType string

// List of FindingDetectionType.
const (
FINDINGDETECTIONTYPE_MISCONFIGURATION FindingDetectionType = "misconfiguration"
FINDINGDETECTIONTYPE_ATTACK_PATH FindingDetectionType = "attack_path"
FINDINGDETECTIONTYPE_IDENTITY_RISK FindingDetectionType = "identity_risk"
FINDINGDETECTIONTYPE_API_SECURITY FindingDetectionType = "api_security"
)

var allowedFindingDetectionTypeEnumValues = []FindingDetectionType{
FINDINGDETECTIONTYPE_MISCONFIGURATION,
FINDINGDETECTIONTYPE_ATTACK_PATH,
FINDINGDETECTIONTYPE_IDENTITY_RISK,
FINDINGDETECTIONTYPE_API_SECURITY,
}

// GetAllowedValues reeturns the list of possible values.
func (v *FindingDetectionType) GetAllowedValues() []FindingDetectionType {
return allowedFindingDetectionTypeEnumValues
}

// UnmarshalJSON deserializes the given payload.
func (v *FindingDetectionType) UnmarshalJSON(src []byte) error {
var value string
err := datadog.Unmarshal(src, &value)
if err != nil {
return err
}
*v = FindingDetectionType(value)
return nil
}

// NewFindingDetectionTypeFromValue returns a pointer to a valid FindingDetectionType
// for the value passed as argument, or an error if the value passed is not allowed by the enum.
func NewFindingDetectionTypeFromValue(v string) (*FindingDetectionType, error) {
ev := FindingDetectionType(v)
if ev.IsValid() {
return &ev, nil
}
return nil, fmt.Errorf("invalid value '%v' for FindingDetectionType: valid values are %v", v, allowedFindingDetectionTypeEnumValues)
}

// IsValid return true if the value is valid for the enum, false otherwise.
func (v FindingDetectionType) IsValid() bool {
for _, existing := range allowedFindingDetectionTypeEnumValues {
if existing == v {
return true
}
}
return false
}

// Ptr returns reference to FindingDetectionType value.
func (v FindingDetectionType) Ptr() *FindingDetectionType {
return &v
}
33 changes: 33 additions & 0 deletions examples/v2/security-monitoring/ListFindings_1668290866.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// List findings with detection_type query param returns "OK" response

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()
configuration.SetUnstableOperationEnabled("v2.ListFindings", true)
apiClient := datadog.NewAPIClient(configuration)
api := datadogV2.NewSecurityMonitoringApi(apiClient)
resp, r, err := api.ListFindings(ctx, *datadogV2.NewListFindingsOptionalParameters().WithFilterDetectionType([]datadogV2.FindingDetectionType{
datadogV2.FINDINGDETECTIONTYPE_MISCONFIGURATION,
datadogV2.FINDINGDETECTIONTYPE_ATTACK_PATH,
}))

if err != nil {
fmt.Fprintf(os.Stderr, "Error when calling `SecurityMonitoringApi.ListFindings`: %v\n", err)
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
}

responseContent, _ := json.MarshalIndent(resp, "", " ")
fmt.Fprintf(os.Stdout, "Response from `SecurityMonitoringApi.ListFindings`:\n%s\n", responseContent)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2024-09-27T19:24:51.188Z
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
interactions:
- request:
body: ''
form: {}
headers:
Accept:
- application/json
id: 0
method: GET
url: https://api.datadoghq.com/api/v2/posture_management/findings?filter%5Bdetection_type%5D=misconfiguration&filter%5Bdetection_type%5D=attack_path
response:
body: '{"data":[],"meta":{"page":{"total_filtered_count":0},"snapshot_timestamp":1727465091308}}'
code: 200
duration: 0ms
headers:
Content-Type:
- application/vnd.api+json
status: 200 OK
version: 2
8 changes: 8 additions & 0 deletions tests/scenarios/features/v2/security_monitoring.feature
Original file line number Diff line number Diff line change
Expand Up @@ -484,6 +484,14 @@ Feature: Security Monitoring
When the request with pagination is sent
Then the response status is 200 OK

@team:DataDog/cloud-security-posture-management
Scenario: List findings with detection_type query param returns "OK" response
Given operation "ListFindings" enabled
And new "ListFindings" request
And request contains "filter[detection_type]" parameter with value ["misconfiguration", "attack_path"]
When the request is sent
Then the response status is 200 OK

@generated @skip @team:DataDog/k9-cloud-security-platform
Scenario: List rules returns "Bad Request" response
Given new "ListSecurityMonitoringRules" request
Expand Down

0 comments on commit 311820d

Please sign in to comment.