Skip to content

Commit 913a2a0

Browse files
author
ci.datadog-api-spec
committed
Regenerate client from commit ccb1c01 of spec repo
1 parent 6be4c93 commit 913a2a0

File tree

8 files changed

+313
-0
lines changed

8 files changed

+313
-0
lines changed

.generator/schemas/v2/openapi.yaml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16644,6 +16644,14 @@ components:
1664416644
required:
1664516645
- id
1664616646
type: object
16647+
DeploymentGateRulesResponse:
16648+
description: Response for a deployment gate rules.
16649+
properties:
16650+
data:
16651+
items:
16652+
$ref: '#/components/schemas/DeploymentRuleResponseData'
16653+
type: array
16654+
type: object
1664716655
DeploymentMetadata:
1664816656
description: Metadata object containing the publication creation information.
1664916657
properties:
@@ -64391,6 +64399,50 @@ paths:
6439164399

6439264400
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
6439364401
/api/v2/deployment_gates/{gate_id}/rules:
64402+
get:
64403+
description: Endpoint to get rules for a deployment gate.
64404+
operationId: GetDeploymentGateRules
64405+
parameters:
64406+
- description: The ID of the deployment gate.
64407+
in: path
64408+
name: gate_id
64409+
required: true
64410+
schema:
64411+
type: string
64412+
responses:
64413+
'200':
64414+
content:
64415+
application/json:
64416+
schema:
64417+
$ref: '#/components/schemas/DeploymentGateRulesResponse'
64418+
description: OK
64419+
'400':
64420+
$ref: '#/components/responses/HTTPCDGatesBadRequestResponse'
64421+
'401':
64422+
$ref: '#/components/responses/UnauthorizedResponse'
64423+
'403':
64424+
$ref: '#/components/responses/ForbiddenResponse'
64425+
'429':
64426+
$ref: '#/components/responses/TooManyRequestsResponse'
64427+
'500':
64428+
content:
64429+
application/json:
64430+
schema:
64431+
$ref: '#/components/schemas/HTTPCIAppErrors'
64432+
description: Internal Server Error
64433+
security:
64434+
- apiKeyAuth: []
64435+
appKeyAuth: []
64436+
summary: Get rules for a deployment gate
64437+
tags:
64438+
- Deployment Gates
64439+
x-permission:
64440+
operator: OR
64441+
permissions:
64442+
- deployment_gates_read
64443+
x-unstable: '**Note**: This endpoint is in preview and may be subject to change.
64444+
64445+
If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
6439464446
post:
6439564447
description: Endpoint to create a deployment rule. A gate for the rule must
6439664448
already exist.

api/datadog/configuration.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -651,6 +651,7 @@ func NewConfiguration() *Configuration {
651651
"v2.DeleteDeploymentGate": false,
652652
"v2.DeleteDeploymentRule": false,
653653
"v2.GetDeploymentGate": false,
654+
"v2.GetDeploymentGateRules": false,
654655
"v2.GetDeploymentRule": false,
655656
"v2.UpdateDeploymentGate": false,
656657
"v2.UpdateDeploymentRule": false,

api/datadogV2/api_deployment_gates.go

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,111 @@ func (a *DeploymentGatesApi) GetDeploymentGate(ctx _context.Context, id string)
555555
return localVarReturnValue, localVarHTTPResponse, nil
556556
}
557557

558+
// GetDeploymentGateRules Get rules for a deployment gate.
559+
// Endpoint to get rules for a deployment gate.
560+
func (a *DeploymentGatesApi) GetDeploymentGateRules(ctx _context.Context, gateId string) (DeploymentGateRulesResponse, *_nethttp.Response, error) {
561+
var (
562+
localVarHTTPMethod = _nethttp.MethodGet
563+
localVarPostBody interface{}
564+
localVarReturnValue DeploymentGateRulesResponse
565+
)
566+
567+
operationId := "v2.GetDeploymentGateRules"
568+
isOperationEnabled := a.Client.Cfg.IsUnstableOperationEnabled(operationId)
569+
if !isOperationEnabled {
570+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: _fmt.Sprintf("Unstable operation '%s' is disabled", operationId)}
571+
}
572+
if isOperationEnabled && a.Client.Cfg.Debug {
573+
_log.Printf("WARNING: Using unstable operation '%s'", operationId)
574+
}
575+
576+
localBasePath, err := a.Client.Cfg.ServerURLWithContext(ctx, "v2.DeploymentGatesApi.GetDeploymentGateRules")
577+
if err != nil {
578+
return localVarReturnValue, nil, datadog.GenericOpenAPIError{ErrorMessage: err.Error()}
579+
}
580+
581+
localVarPath := localBasePath + "/api/v2/deployment_gates/{gate_id}/rules"
582+
localVarPath = datadog.ReplacePathParameter(localVarPath, "{gate_id}", _neturl.PathEscape(datadog.ParameterToString(gateId, "")))
583+
584+
localVarHeaderParams := make(map[string]string)
585+
localVarQueryParams := _neturl.Values{}
586+
localVarFormParams := _neturl.Values{}
587+
localVarHeaderParams["Accept"] = "application/json"
588+
589+
if a.Client.Cfg.DelegatedTokenConfig != nil {
590+
err = datadog.UseDelegatedTokenAuth(ctx, &localVarHeaderParams, a.Client.Cfg.DelegatedTokenConfig)
591+
if err != nil {
592+
return localVarReturnValue, nil, err
593+
}
594+
} else {
595+
datadog.SetAuthKeys(
596+
ctx,
597+
&localVarHeaderParams,
598+
[2]string{"apiKeyAuth", "DD-API-KEY"},
599+
[2]string{"appKeyAuth", "DD-APPLICATION-KEY"},
600+
)
601+
}
602+
req, err := a.Client.PrepareRequest(ctx, localVarPath, localVarHTTPMethod, localVarPostBody, localVarHeaderParams, localVarQueryParams, localVarFormParams, nil)
603+
if err != nil {
604+
return localVarReturnValue, nil, err
605+
}
606+
607+
localVarHTTPResponse, err := a.Client.CallAPI(req)
608+
if err != nil || localVarHTTPResponse == nil {
609+
return localVarReturnValue, localVarHTTPResponse, err
610+
}
611+
612+
localVarBody, err := datadog.ReadBody(localVarHTTPResponse)
613+
if err != nil {
614+
return localVarReturnValue, localVarHTTPResponse, err
615+
}
616+
617+
if localVarHTTPResponse.StatusCode >= 300 {
618+
newErr := datadog.GenericOpenAPIError{
619+
ErrorBody: localVarBody,
620+
ErrorMessage: localVarHTTPResponse.Status,
621+
}
622+
if localVarHTTPResponse.StatusCode == 400 {
623+
var v HTTPCDGatesBadRequestResponse
624+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
625+
if err != nil {
626+
return localVarReturnValue, localVarHTTPResponse, newErr
627+
}
628+
newErr.ErrorModel = v
629+
return localVarReturnValue, localVarHTTPResponse, newErr
630+
}
631+
if localVarHTTPResponse.StatusCode == 401 || localVarHTTPResponse.StatusCode == 403 || localVarHTTPResponse.StatusCode == 429 {
632+
var v APIErrorResponse
633+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
634+
if err != nil {
635+
return localVarReturnValue, localVarHTTPResponse, newErr
636+
}
637+
newErr.ErrorModel = v
638+
return localVarReturnValue, localVarHTTPResponse, newErr
639+
}
640+
if localVarHTTPResponse.StatusCode == 500 {
641+
var v HTTPCIAppErrors
642+
err = a.Client.Decode(&v, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
643+
if err != nil {
644+
return localVarReturnValue, localVarHTTPResponse, newErr
645+
}
646+
newErr.ErrorModel = v
647+
}
648+
return localVarReturnValue, localVarHTTPResponse, newErr
649+
}
650+
651+
err = a.Client.Decode(&localVarReturnValue, localVarBody, localVarHTTPResponse.Header.Get("Content-Type"))
652+
if err != nil {
653+
newErr := datadog.GenericOpenAPIError{
654+
ErrorBody: localVarBody,
655+
ErrorMessage: err.Error(),
656+
}
657+
return localVarReturnValue, localVarHTTPResponse, newErr
658+
}
659+
660+
return localVarReturnValue, localVarHTTPResponse, nil
661+
}
662+
558663
// GetDeploymentRule Get deployment rule.
559664
// Endpoint to get a deployment rule.
560665
func (a *DeploymentGatesApi) GetDeploymentRule(ctx _context.Context, gateId string, id string) (DeploymentRuleResponse, *_nethttp.Response, error) {

api/datadogV2/doc.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,7 @@
226226
// - [DeploymentGatesApi.DeleteDeploymentGate]
227227
// - [DeploymentGatesApi.DeleteDeploymentRule]
228228
// - [DeploymentGatesApi.GetDeploymentGate]
229+
// - [DeploymentGatesApi.GetDeploymentGateRules]
229230
// - [DeploymentGatesApi.GetDeploymentRule]
230231
// - [DeploymentGatesApi.UpdateDeploymentGate]
231232
// - [DeploymentGatesApi.UpdateDeploymentRule]
Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
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+
// DeploymentGateRulesResponse Response for a deployment gate rules.
12+
type DeploymentGateRulesResponse struct {
13+
//
14+
Data []DeploymentRuleResponseData `json:"data,omitempty"`
15+
// UnparsedObject contains the raw value of the object if there was an error when deserializing into the struct
16+
UnparsedObject map[string]interface{} `json:"-"`
17+
AdditionalProperties map[string]interface{} `json:"-"`
18+
}
19+
20+
// NewDeploymentGateRulesResponse instantiates a new DeploymentGateRulesResponse object.
21+
// This constructor will assign default values to properties that have it defined,
22+
// and makes sure properties required by API are set, but the set of arguments
23+
// will change when the set of required properties is changed.
24+
func NewDeploymentGateRulesResponse() *DeploymentGateRulesResponse {
25+
this := DeploymentGateRulesResponse{}
26+
return &this
27+
}
28+
29+
// NewDeploymentGateRulesResponseWithDefaults instantiates a new DeploymentGateRulesResponse object.
30+
// This constructor will only assign default values to properties that have it defined,
31+
// but it doesn't guarantee that properties required by API are set.
32+
func NewDeploymentGateRulesResponseWithDefaults() *DeploymentGateRulesResponse {
33+
this := DeploymentGateRulesResponse{}
34+
return &this
35+
}
36+
37+
// GetData returns the Data field value if set, zero value otherwise.
38+
func (o *DeploymentGateRulesResponse) GetData() []DeploymentRuleResponseData {
39+
if o == nil || o.Data == nil {
40+
var ret []DeploymentRuleResponseData
41+
return ret
42+
}
43+
return o.Data
44+
}
45+
46+
// GetDataOk returns a tuple with the Data field value if set, nil otherwise
47+
// and a boolean to check if the value has been set.
48+
func (o *DeploymentGateRulesResponse) GetDataOk() (*[]DeploymentRuleResponseData, bool) {
49+
if o == nil || o.Data == nil {
50+
return nil, false
51+
}
52+
return &o.Data, true
53+
}
54+
55+
// HasData returns a boolean if a field has been set.
56+
func (o *DeploymentGateRulesResponse) HasData() bool {
57+
return o != nil && o.Data != nil
58+
}
59+
60+
// SetData gets a reference to the given []DeploymentRuleResponseData and assigns it to the Data field.
61+
func (o *DeploymentGateRulesResponse) SetData(v []DeploymentRuleResponseData) {
62+
o.Data = v
63+
}
64+
65+
// MarshalJSON serializes the struct using spec logic.
66+
func (o DeploymentGateRulesResponse) MarshalJSON() ([]byte, error) {
67+
toSerialize := map[string]interface{}{}
68+
if o.UnparsedObject != nil {
69+
return datadog.Marshal(o.UnparsedObject)
70+
}
71+
if o.Data != nil {
72+
toSerialize["data"] = o.Data
73+
}
74+
75+
for key, value := range o.AdditionalProperties {
76+
toSerialize[key] = value
77+
}
78+
return datadog.Marshal(toSerialize)
79+
}
80+
81+
// UnmarshalJSON deserializes the given payload.
82+
func (o *DeploymentGateRulesResponse) UnmarshalJSON(bytes []byte) (err error) {
83+
all := struct {
84+
Data []DeploymentRuleResponseData `json:"data,omitempty"`
85+
}{}
86+
if err = datadog.Unmarshal(bytes, &all); err != nil {
87+
return datadog.Unmarshal(bytes, &o.UnparsedObject)
88+
}
89+
additionalProperties := make(map[string]interface{})
90+
if err = datadog.Unmarshal(bytes, &additionalProperties); err == nil {
91+
datadog.DeleteKeys(additionalProperties, &[]string{"data"})
92+
} else {
93+
return err
94+
}
95+
o.Data = all.Data
96+
97+
if len(additionalProperties) > 0 {
98+
o.AdditionalProperties = additionalProperties
99+
}
100+
101+
return nil
102+
}
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// Get rules for a deployment gate returns "OK" response
2+
3+
package main
4+
5+
import (
6+
"context"
7+
"encoding/json"
8+
"fmt"
9+
"os"
10+
11+
"github.com/DataDog/datadog-api-client-go/v2/api/datadog"
12+
"github.com/DataDog/datadog-api-client-go/v2/api/datadogV2"
13+
)
14+
15+
func main() {
16+
ctx := datadog.NewDefaultContext(context.Background())
17+
configuration := datadog.NewConfiguration()
18+
configuration.SetUnstableOperationEnabled("v2.GetDeploymentGateRules", true)
19+
apiClient := datadog.NewAPIClient(configuration)
20+
api := datadogV2.NewDeploymentGatesApi(apiClient)
21+
resp, r, err := api.GetDeploymentGateRules(ctx, "gate_id")
22+
23+
if err != nil {
24+
fmt.Fprintf(os.Stderr, "Error when calling `DeploymentGatesApi.GetDeploymentGateRules`: %v\n", err)
25+
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
26+
}
27+
28+
responseContent, _ := json.MarshalIndent(resp, "", " ")
29+
fmt.Fprintf(os.Stdout, "Response from `DeploymentGatesApi.GetDeploymentGateRules`:\n%s\n", responseContent)
30+
}

tests/scenarios/features/v2/deployment_gates.feature

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,22 @@ Feature: Deployment Gates
207207
When the request is sent
208208
Then the response status is 200 OK
209209

210+
@generated @skip @team:DataDog/ci-app-backend
211+
Scenario: Get rules for a deployment gate returns "Bad request." response
212+
Given operation "GetDeploymentGateRules" enabled
213+
And new "GetDeploymentGateRules" request
214+
And request contains "gate_id" parameter from "REPLACE.ME"
215+
When the request is sent
216+
Then the response status is 400 Bad request.
217+
218+
@generated @skip @team:DataDog/ci-app-backend
219+
Scenario: Get rules for a deployment gate returns "OK" response
220+
Given operation "GetDeploymentGateRules" enabled
221+
And new "GetDeploymentGateRules" request
222+
And request contains "gate_id" parameter from "REPLACE.ME"
223+
When the request is sent
224+
Then the response status is 200 OK
225+
210226
@team:DataDog/ci-app-backend
211227
Scenario: Update deployment gate returns "Bad Request" response
212228
Given operation "UpdateDeploymentGate" enabled

tests/scenarios/features/v2/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,6 +1323,12 @@
13231323
"type": "unsafe"
13241324
}
13251325
},
1326+
"GetDeploymentGateRules": {
1327+
"tag": "Deployment Gates",
1328+
"undo": {
1329+
"type": "safe"
1330+
}
1331+
},
13261332
"CreateDeploymentRule": {
13271333
"tag": "Deployment Gates",
13281334
"undo": {

0 commit comments

Comments
 (0)