-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regenerate client from commit 4da98699 of spec repo
- Loading branch information
ci.datadog-api-spec
committed
Sep 27, 2024
1 parent
68095bc
commit 311820d
Showing
8 changed files
with
179 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
33
examples/v2/security-monitoring/ListFindings_1668290866.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} |
1 change: 1 addition & 0 deletions
1
...itoring/Scenario_List_findings_with_detection_type_query_param_returns_OK_response.freeze
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
2024-09-27T19:24:51.188Z |
19 changes: 19 additions & 0 deletions
19
...onitoring/Scenario_List_findings_with_detection_type_query_param_returns_OK_response.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters