Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 52 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16644,6 +16644,14 @@ components:
required:
- id
type: object
DeploymentGateRulesResponse:
description: Response for a deployment gate rules.
properties:
data:
items:
$ref: '#/components/schemas/DeploymentRuleResponseData'
type: array
type: object
DeploymentMetadata:
description: Metadata object containing the publication creation information.
properties:
Expand Down Expand Up @@ -64391,6 +64399,50 @@ paths:

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
/api/v2/deployment_gates/{gate_id}/rules:
get:
description: Endpoint to get rules for a deployment gate.
operationId: GetDeploymentGateRules
parameters:
- description: The ID of the deployment gate.
in: path
name: gate_id
required: true
schema:
type: string
responses:
'200':
content:
application/json:
schema:
$ref: '#/components/schemas/DeploymentGateRulesResponse'
description: OK
'400':
$ref: '#/components/responses/HTTPCDGatesBadRequestResponse'
'401':
$ref: '#/components/responses/UnauthorizedResponse'
'403':
$ref: '#/components/responses/ForbiddenResponse'
'429':
$ref: '#/components/responses/TooManyRequestsResponse'
'500':
content:
application/json:
schema:
$ref: '#/components/schemas/HTTPCIAppErrors'
description: Internal Server Error
security:
- apiKeyAuth: []
appKeyAuth: []
summary: Get rules for a deployment gate
tags:
- Deployment Gates
x-permission:
operator: OR
permissions:
- deployment_gates_read
x-unstable: '**Note**: This endpoint is in preview and may be subject to change.

If you have any feedback, contact [Datadog support](https://docs.datadoghq.com/help/).'
post:
description: Endpoint to create a deployment rule. A gate for the rule must
already exist.
Expand Down
25 changes: 25 additions & 0 deletions examples/v2/deployment-gates/GetDeploymentGateRules.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
/**
* Get rules for a deployment gate returns "OK" response
*/

import { client, v2 } from "@datadog/datadog-api-client";

const configuration = client.createConfiguration();
configuration.unstableOperations["v2.getDeploymentGateRules"] = true;
const apiInstance = new v2.DeploymentGatesApi(configuration);

// there is a valid "deployment_gate" in the system
const DEPLOYMENT_GATE_DATA_ID = process.env.DEPLOYMENT_GATE_DATA_ID as string;

const params: v2.DeploymentGatesApiGetDeploymentGateRulesRequest = {
gateId: DEPLOYMENT_GATE_DATA_ID,
};

apiInstance
.getDeploymentGateRules(params)
.then((data: v2.DeploymentGateRulesResponse) => {
console.log(
"API called successfully. Returned data: " + JSON.stringify(data)
);
})
.catch((error: any) => console.error(error));
7 changes: 7 additions & 0 deletions features/support/scenarios_model_mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5320,6 +5320,13 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
},
"operationResponseType": "DeploymentGateResponse",
},
"v2.GetDeploymentGateRules": {
"gateId": {
"type": "string",
"format": "",
},
"operationResponseType": "DeploymentGateRulesResponse",
},
"v2.CreateDeploymentRule": {
"gateId": {
"type": "string",
Expand Down
17 changes: 17 additions & 0 deletions features/v2/deployment_gates.feature
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,23 @@ Feature: Deployment Gates
When the request is sent
Then the response status is 200 OK

@generated @skip @team:DataDog/ci-app-backend
Scenario: Get rules for a deployment gate returns "Bad request." response
Given operation "GetDeploymentGateRules" enabled
And new "GetDeploymentGateRules" request
And request contains "gate_id" parameter from "REPLACE.ME"
When the request is sent
Then the response status is 400 Bad request.

@team:DataDog/ci-app-backend
Scenario: Get rules for a deployment gate returns "OK" response
Given there is a valid "deployment_gate" in the system
And operation "GetDeploymentGateRules" enabled
And new "GetDeploymentGateRules" request
And request contains "gate_id" parameter from "deployment_gate.data.id"
When the request is sent
Then the response status is 200 OK

@team:DataDog/ci-app-backend
Scenario: Update deployment gate returns "Bad Request" response
Given operation "UpdateDeploymentGate" enabled
Expand Down
6 changes: 6 additions & 0 deletions features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -1323,6 +1323,12 @@
"type": "unsafe"
}
},
"GetDeploymentGateRules": {
"tag": "Deployment Gates",
"undo": {
"type": "safe"
}
},
"CreateDeploymentRule": {
"tag": "Deployment Gates",
"undo": {
Expand Down
1 change: 1 addition & 0 deletions packages/datadog-api-client-common/configuration.ts
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ export function createConfiguration(
"v2.deleteDeploymentGate": false,
"v2.deleteDeploymentRule": false,
"v2.getDeploymentGate": false,
"v2.getDeploymentGateRules": false,
"v2.getDeploymentRule": false,
"v2.updateDeploymentGate": false,
"v2.updateDeploymentRule": false,
Expand Down
175 changes: 175 additions & 0 deletions packages/datadog-api-client-v2/apis/DeploymentGatesApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { APIErrorResponse } from "../models/APIErrorResponse";
import { CreateDeploymentGateParams } from "../models/CreateDeploymentGateParams";
import { CreateDeploymentRuleParams } from "../models/CreateDeploymentRuleParams";
import { DeploymentGateResponse } from "../models/DeploymentGateResponse";
import { DeploymentGateRulesResponse } from "../models/DeploymentGateRulesResponse";
import { DeploymentRuleResponse } from "../models/DeploymentRuleResponse";
import { HTTPCDGatesBadRequestResponse } from "../models/HTTPCDGatesBadRequestResponse";
import { HTTPCDGatesNotFoundResponse } from "../models/HTTPCDGatesNotFoundResponse";
Expand Down Expand Up @@ -249,6 +250,46 @@ export class DeploymentGatesApiRequestFactory extends BaseAPIRequestFactory {
return requestContext;
}

public async getDeploymentGateRules(
gateId: string,
_options?: Configuration
): Promise<RequestContext> {
const _config = _options || this.configuration;

logger.warn("Using unstable operation 'getDeploymentGateRules'");
if (!_config.unstableOperations["v2.getDeploymentGateRules"]) {
throw new Error(
"Unstable operation 'getDeploymentGateRules' is disabled"
);
}

// verify required parameter 'gateId' is not null or undefined
if (gateId === null || gateId === undefined) {
throw new RequiredError("gateId", "getDeploymentGateRules");
}

// Path Params
const localVarPath = "/api/v2/deployment_gates/{gate_id}/rules".replace(
"{gate_id}",
encodeURIComponent(String(gateId))
);

// Make Request Context
const requestContext = _config
.getServer("v2.DeploymentGatesApi.getDeploymentGateRules")
.makeRequestContext(localVarPath, HttpMethod.GET);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);

// Apply auth methods
applySecurityAuthentication(_config, requestContext, [
"apiKeyAuth",
"appKeyAuth",
]);

return requestContext;
}

public async getDeploymentRule(
gateId: string,
id: string,
Expand Down Expand Up @@ -981,6 +1022,111 @@ export class DeploymentGatesApiResponseProcessor {
);
}

/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
*
* @params response Response returned by the server for a request to getDeploymentGateRules
* @throws ApiException if the response code was not in [200, 299]
*/
public async getDeploymentGateRules(
response: ResponseContext
): Promise<DeploymentGateRulesResponse> {
const contentType = ObjectSerializer.normalizeMediaType(
response.headers["content-type"]
);
if (response.httpStatusCode === 200) {
const body: DeploymentGateRulesResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"DeploymentGateRulesResponse"
) as DeploymentGateRulesResponse;
return body;
}
if (response.httpStatusCode === 400) {
const bodyText = ObjectSerializer.parse(
await response.body.text(),
contentType
);
let body: HTTPCDGatesBadRequestResponse;
try {
body = ObjectSerializer.deserialize(
bodyText,
"HTTPCDGatesBadRequestResponse"
) as HTTPCDGatesBadRequestResponse;
} catch (error) {
logger.debug(`Got error deserializing error: ${error}`);
throw new ApiException<HTTPCDGatesBadRequestResponse>(
response.httpStatusCode,
bodyText
);
}
throw new ApiException<HTTPCDGatesBadRequestResponse>(
response.httpStatusCode,
body
);
}
if (
response.httpStatusCode === 401 ||
response.httpStatusCode === 403 ||
response.httpStatusCode === 429
) {
const bodyText = ObjectSerializer.parse(
await response.body.text(),
contentType
);
let body: APIErrorResponse;
try {
body = ObjectSerializer.deserialize(
bodyText,
"APIErrorResponse"
) as APIErrorResponse;
} catch (error) {
logger.debug(`Got error deserializing error: ${error}`);
throw new ApiException<APIErrorResponse>(
response.httpStatusCode,
bodyText
);
}
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
}
if (response.httpStatusCode === 500) {
const bodyText = ObjectSerializer.parse(
await response.body.text(),
contentType
);
let body: HTTPCIAppErrors;
try {
body = ObjectSerializer.deserialize(
bodyText,
"HTTPCIAppErrors"
) as HTTPCIAppErrors;
} catch (error) {
logger.debug(`Got error deserializing error: ${error}`);
throw new ApiException<HTTPCIAppErrors>(
response.httpStatusCode,
bodyText
);
}
throw new ApiException<HTTPCIAppErrors>(response.httpStatusCode, body);
}

// Work around for missing responses in specification, e.g. for petstore.yaml
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
const body: DeploymentGateRulesResponse = ObjectSerializer.deserialize(
ObjectSerializer.parse(await response.body.text(), contentType),
"DeploymentGateRulesResponse",
""
) as DeploymentGateRulesResponse;
return body;
}

const body = (await response.body.text()) || "";
throw new ApiException<string>(
response.httpStatusCode,
'Unknown API Status Code!\nBody: "' + body + '"'
);
}

/**
* Unwraps the actual response sent by the server from the response context and deserializes the response content
* to the expected objects
Expand Down Expand Up @@ -1414,6 +1560,14 @@ export interface DeploymentGatesApiGetDeploymentGateRequest {
id: string;
}

export interface DeploymentGatesApiGetDeploymentGateRulesRequest {
/**
* The ID of the deployment gate.
* @type string
*/
gateId: string;
}

export interface DeploymentGatesApiGetDeploymentRuleRequest {
/**
* The ID of the deployment gate.
Expand Down Expand Up @@ -1580,6 +1734,27 @@ export class DeploymentGatesApi {
});
}

/**
* Endpoint to get rules for a deployment gate.
* @param param The request object
*/
public getDeploymentGateRules(
param: DeploymentGatesApiGetDeploymentGateRulesRequest,
options?: Configuration
): Promise<DeploymentGateRulesResponse> {
const requestContextPromise = this.requestFactory.getDeploymentGateRules(
param.gateId,
options
);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.getDeploymentGateRules(responseContext);
});
});
}

/**
* Endpoint to get a deployment rule.
* @param param The request object
Expand Down
2 changes: 2 additions & 0 deletions packages/datadog-api-client-v2/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,7 @@ export {
DeploymentGatesApiDeleteDeploymentGateRequest,
DeploymentGatesApiDeleteDeploymentRuleRequest,
DeploymentGatesApiGetDeploymentGateRequest,
DeploymentGatesApiGetDeploymentGateRulesRequest,
DeploymentGatesApiGetDeploymentRuleRequest,
DeploymentGatesApiUpdateDeploymentGateRequest,
DeploymentGatesApiUpdateDeploymentRuleRequest,
Expand Down Expand Up @@ -1875,6 +1876,7 @@ export { DeploymentGateResponseData } from "./models/DeploymentGateResponseData"
export { DeploymentGateResponseDataAttributes } from "./models/DeploymentGateResponseDataAttributes";
export { DeploymentGateResponseDataAttributesCreatedBy } from "./models/DeploymentGateResponseDataAttributesCreatedBy";
export { DeploymentGateResponseDataAttributesUpdatedBy } from "./models/DeploymentGateResponseDataAttributesUpdatedBy";
export { DeploymentGateRulesResponse } from "./models/DeploymentGateRulesResponse";
export { DeploymentMetadata } from "./models/DeploymentMetadata";
export { DeploymentRelationship } from "./models/DeploymentRelationship";
export { DeploymentRelationshipData } from "./models/DeploymentRelationshipData";
Expand Down
Loading
Loading