Skip to content

Commit

Permalink
Regenerate client from commit d588dddf of spec repo
Browse files Browse the repository at this point in the history
  • Loading branch information
ci.datadog-api-spec committed Jun 26, 2024
1 parent 7c78b44 commit 9da76fa
Show file tree
Hide file tree
Showing 14 changed files with 682 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-06-26 17:58:27.325217",
"spec_repo_commit": "bad4ef97"
"regenerated": "2024-06-26 20:44:46.006545",
"spec_repo_commit": "d588dddf"
},
"v2": {
"apigentools_version": "1.6.6",
"regenerated": "2024-06-26 17:58:27.343333",
"spec_repo_commit": "bad4ef97"
"regenerated": "2024-06-26 20:44:46.025733",
"spec_repo_commit": "d588dddf"
}
}
}
77 changes: 77 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17373,6 +17373,18 @@ components:
required:
- status
type: object
SecurityMonitoringRuleConvertPayload:
description: Convert a rule from JSON to Terraform.
oneOf:
- $ref: '#/components/schemas/SecurityMonitoringStandardRulePayload'
- $ref: '#/components/schemas/SecurityMonitoringSignalRulePayload'
SecurityMonitoringRuleConvertResponse:
description: Result of the convert rule request containing Terraform content.
properties:
terraformContent:
description: Terraform string as a result of converting the rule from JSON.
type: string
type: object
SecurityMonitoringRuleCreatePayload:
description: Create a new rule.
oneOf:
Expand Down Expand Up @@ -33152,6 +33164,42 @@ paths:
tags:
- Security Monitoring
x-codegen-request-body-name: body
/api/v2/security_monitoring/rules/convert:
post:
description: Convert a rule that doesn't (yet) exist from JSON to Terraform.
operationId: ConvertSecurityMonitoringRuleFromJSONToTerraform
requestBody:
content:
application/json:
schema:
$ref: '#/components/schemas/SecurityMonitoringRuleConvertPayload'
required: true
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/SecurityMonitoringRuleConvertResponse'
description: OK
'400':
$ref: '#/components/responses/BadRequestResponse'
'401':
$ref: '#/components/responses/ConcurrentModificationResponse'
'403':
$ref: '#/components/responses/NotAuthorizedResponse'
'404':
$ref: '#/components/responses/NotFoundResponse'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- security_monitoring_rules_write
summary: Convert a rule from JSON to Terraform
tags:
- Security Monitoring
x-codegen-request-body-name: body
/api/v2/security_monitoring/rules/test:
post:
description: Test a rule.
Expand Down Expand Up @@ -33309,6 +33357,35 @@ paths:
tags:
- Security Monitoring
x-codegen-request-body-name: body
/api/v2/security_monitoring/rules/{rule_id}/convert:
get:
description: Convert an existing rule from JSON to Terraform.
operationId: ConvertExistingSecurityMonitoringRule
parameters:
- $ref: '#/components/parameters/SecurityMonitoringRuleID'
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/SecurityMonitoringRuleConvertResponse'
description: OK
'400':
$ref: '#/components/responses/BadRequestResponse'
'403':
$ref: '#/components/responses/NotAuthorizedResponse'
'404':
$ref: '#/components/responses/NotFoundResponse'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
security:
- apiKeyAuth: []
appKeyAuth: []
- AuthZ:
- security_monitoring_rules_read
summary: Convert an existing rule from JSON to Terraform
tags:
- Security Monitoring
/api/v2/security_monitoring/rules/{rule_id}/test:
post:
description: Test an existing rule.
Expand Down
144 changes: 144 additions & 0 deletions api/datadogV2/api_security_monitoring.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,150 @@ import (
// SecurityMonitoringApi service type
type SecurityMonitoringApi datadog.Service

// ConvertExistingSecurityMonitoringRule Convert an existing rule from JSON to Terraform.
// Convert an existing rule from JSON to Terraform.
func (a *SecurityMonitoringApi) ConvertExistingSecurityMonitoringRule(ctx _context.Context, ruleId string) (SecurityMonitoringRuleConvertResponse, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodGet
localVarPostBody interface{}
localVarReturnValue SecurityMonitoringRuleConvertResponse
)

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.ConvertExistingSecurityMonitoringRule")
if err != nil {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
}

localVarPath := localBasePath + "/api/v2/security_monitoring/rules/{rule_id}/convert"
localVarPath = strings.Replace(localVarPath, "{"+"rule_id"+"}", _neturl.PathEscape(datadog.ParameterToString(ruleId, "")), -1)

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
localVarHeaderParams["Accept"] = "application/json"

datadog.SetAuthKeys(
ctx,
&localVarHeaderParams,
[2]string{"apiKeyAuth", "DD-API-KEY"},
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
)
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
if err != nil {
return localVarReturnValue, nil, err
}

localVarHTTPResponse, err := a.Client.CallAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}

localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}

if localVarHTTPResponse.StatusCode >= 300 {
newErr := datadog.GenericOpenAPIError{
ErrorBody: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 {
var v APIErrorResponse
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.ErrorModel = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}

err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := datadog.GenericOpenAPIError{
ErrorBody: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}

return localVarReturnValue, localVarHTTPResponse, nil
}

// ConvertSecurityMonitoringRuleFromJSONToTerraform Convert a rule from JSON to Terraform.
// Convert a rule that doesn't (yet) exist from JSON to Terraform.
func (a *SecurityMonitoringApi) ConvertSecurityMonitoringRuleFromJSONToTerraform(ctx _context.Context, body SecurityMonitoringRuleConvertPayload) (SecurityMonitoringRuleConvertResponse, *_nethttp.Response, error) {
var (
localVarHTTPMethod = _nethttp.MethodPost
localVarPostBody interface{}
localVarReturnValue SecurityMonitoringRuleConvertResponse
)

localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.SecurityMonitoringApi.ConvertSecurityMonitoringRuleFromJSONToTerraform")
if err != nil {
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
}

localVarPath := localBasePath + "/api/v2/security_monitoring/rules/convert"

localVarHeaderParams := make(map[string]string)
localVarQueryParams := _neturl.Values{}
localVarFormParams := _neturl.Values{}
localVarHeaderParams["Content-Type"] = "application/json"
localVarHeaderParams["Accept"] = "application/json"

// body params
localVarPostBody = &body
datadog.SetAuthKeys(
ctx,
&localVarHeaderParams,
[2]string{"apiKeyAuth", "DD-API-KEY"},
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
)
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
if err != nil {
return localVarReturnValue, nil, err
}

localVarHTTPResponse, err := a.Client.CallAPI(req)
if err != nil || localVarHTTPResponse == nil {
return localVarReturnValue, localVarHTTPResponse, err
}

localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
if err != nil {
return localVarReturnValue, localVarHTTPResponse, err
}

if localVarHTTPResponse.StatusCode >= 300 {
newErr := datadog.GenericOpenAPIError{
ErrorBody: localVarBody,
ErrorMessage: localVarHTTPResponse.Status,
}
if localVarHTTPResponse.StatusCode == 400 || localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 404 || localVarHTTPResponse.StatusCode == 429 {
var v APIErrorResponse
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
return localVarReturnValue, localVarHTTPResponse, newErr
}
newErr.ErrorModel = v
}
return localVarReturnValue, localVarHTTPResponse, newErr
}

err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
if err != nil {
newErr := datadog.GenericOpenAPIError{
ErrorBody: localVarBody,
ErrorMessage: err.Error(),
}
return localVarReturnValue, localVarHTTPResponse, newErr
}

return localVarReturnValue, localVarHTTPResponse, nil
}

// CreateSecurityFilter Create a security filter.
// Create a security filter.
//
Expand Down
2 changes: 2 additions & 0 deletions api/datadogV2/doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,8 @@
// - [RolesApi.RemovePermissionFromRole]
// - [RolesApi.RemoveUserFromRole]
// - [RolesApi.UpdateRole]
// - [SecurityMonitoringApi.ConvertExistingSecurityMonitoringRule]
// - [SecurityMonitoringApi.ConvertSecurityMonitoringRuleFromJSONToTerraform]
// - [SecurityMonitoringApi.CreateSecurityFilter]
// - [SecurityMonitoringApi.CreateSecurityMonitoringRule]
// - [SecurityMonitoringApi.CreateSecurityMonitoringSuppression]
Expand Down
105 changes: 105 additions & 0 deletions api/datadogV2/model_security_monitoring_rule_convert_payload.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
// 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 (
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
)

// SecurityMonitoringRuleConvertPayload - Convert a rule from JSON to Terraform.
type SecurityMonitoringRuleConvertPayload struct {
SecurityMonitoringStandardRulePayload *SecurityMonitoringStandardRulePayload
SecurityMonitoringSignalRulePayload *SecurityMonitoringSignalRulePayload

// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
UnparsedObject interface{}
}

// SecurityMonitoringStandardRulePayloadAsSecurityMonitoringRuleConvertPayload is a convenience function that returns SecurityMonitoringStandardRulePayload wrapped in SecurityMonitoringRuleConvertPayload.
func SecurityMonitoringStandardRulePayloadAsSecurityMonitoringRuleConvertPayload(v *SecurityMonitoringStandardRulePayload) SecurityMonitoringRuleConvertPayload {
return SecurityMonitoringRuleConvertPayload{SecurityMonitoringStandardRulePayload: v}
}

// SecurityMonitoringSignalRulePayloadAsSecurityMonitoringRuleConvertPayload is a convenience function that returns SecurityMonitoringSignalRulePayload wrapped in SecurityMonitoringRuleConvertPayload.
func SecurityMonitoringSignalRulePayloadAsSecurityMonitoringRuleConvertPayload(v *SecurityMonitoringSignalRulePayload) SecurityMonitoringRuleConvertPayload {
return SecurityMonitoringRuleConvertPayload{SecurityMonitoringSignalRulePayload: v}
}

// UnmarshalJSON turns data into one of the pointers in the struct.
func (obj *SecurityMonitoringRuleConvertPayload) UnmarshalJSON(data []byte) error {
var err error
match := 0
// try to unmarshal data into SecurityMonitoringStandardRulePayload
err = datadog.Unmarshal(data, &obj.SecurityMonitoringStandardRulePayload)
if err == nil {
if obj.SecurityMonitoringStandardRulePayload != nil && obj.SecurityMonitoringStandardRulePayload.UnparsedObject == nil {
jsonSecurityMonitoringStandardRulePayload, _ := datadog.Marshal(obj.SecurityMonitoringStandardRulePayload)
if string(jsonSecurityMonitoringStandardRulePayload) == "{}" { // empty struct
obj.SecurityMonitoringStandardRulePayload = nil
} else {
match++
}
} else {
obj.SecurityMonitoringStandardRulePayload = nil
}
} else {
obj.SecurityMonitoringStandardRulePayload = nil
}

// try to unmarshal data into SecurityMonitoringSignalRulePayload
err = datadog.Unmarshal(data, &obj.SecurityMonitoringSignalRulePayload)
if err == nil {
if obj.SecurityMonitoringSignalRulePayload != nil && obj.SecurityMonitoringSignalRulePayload.UnparsedObject == nil {
jsonSecurityMonitoringSignalRulePayload, _ := datadog.Marshal(obj.SecurityMonitoringSignalRulePayload)
if string(jsonSecurityMonitoringSignalRulePayload) == "{}" { // empty struct
obj.SecurityMonitoringSignalRulePayload = nil
} else {
match++
}
} else {
obj.SecurityMonitoringSignalRulePayload = nil
}
} else {
obj.SecurityMonitoringSignalRulePayload = nil
}

if match != 1 { // more than 1 match
// reset to nil
obj.SecurityMonitoringStandardRulePayload = nil
obj.SecurityMonitoringSignalRulePayload = nil
return datadog.Unmarshal(data, &obj.UnparsedObject)
}
return nil // exactly one match
}

// MarshalJSON turns data from the first non-nil pointers in the struct to JSON.
func (obj SecurityMonitoringRuleConvertPayload) MarshalJSON() ([]byte, error) {
if obj.SecurityMonitoringStandardRulePayload != nil {
return datadog.Marshal(&obj.SecurityMonitoringStandardRulePayload)
}

if obj.SecurityMonitoringSignalRulePayload != nil {
return datadog.Marshal(&obj.SecurityMonitoringSignalRulePayload)
}

if obj.UnparsedObject != nil {
return datadog.Marshal(obj.UnparsedObject)
}
return nil, nil // no data in oneOf schemas
}

// GetActualInstance returns the actual instance.
func (obj *SecurityMonitoringRuleConvertPayload) GetActualInstance() interface{} {
if obj.SecurityMonitoringStandardRulePayload != nil {
return obj.SecurityMonitoringStandardRulePayload
}

if obj.SecurityMonitoringSignalRulePayload != nil {
return obj.SecurityMonitoringSignalRulePayload
}

// all schemas are nil
return nil
}
Loading

0 comments on commit 9da76fa

Please sign in to comment.