Skip to content

Commit b9b7224

Browse files
api-clients-generation-pipeline[bot]ci.datadog-api-spec
andauthored
Regenerate client from commit 5371379 of spec repo (#4476)
Co-authored-by: ci.datadog-api-spec <packages@datadoghq.com>
1 parent 1031dd3 commit b9b7224

22 files changed

Lines changed: 1959 additions & 0 deletions

.generator/schemas/v2/openapi.yaml

Lines changed: 519 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
/**
2+
* List governance insights returns "OK" response
3+
*/
4+
5+
import { client, v2 } from "@datadog/datadog-api-client";
6+
7+
const configuration = client.createConfiguration();
8+
configuration.unstableOperations["v2.listGovernanceInsights"] = true;
9+
const apiInstance = new v2.GovernanceInsightsApi(configuration);
10+
11+
apiInstance
12+
.listGovernanceInsights()
13+
.then((data: v2.GovernanceInsightsResponse) => {
14+
console.log(
15+
"API called successfully. Returned data: " + JSON.stringify(data)
16+
);
17+
})
18+
.catch((error: any) => console.error(error));

features/support/scenarios_model_mapping.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9359,6 +9359,21 @@ export const ScenariosModelMappings: {[key: string]: {[key: string]: any}} = {
93599359
},
93609360
"operationResponseType": "SAMLConfigurationResponse",
93619361
},
9362+
"v2.ListGovernanceInsights": {
9363+
"withValues": {
9364+
"type": "boolean",
9365+
"format": "",
9366+
},
9367+
"orgUuid": {
9368+
"type": "string",
9369+
"format": "",
9370+
},
9371+
"filterProduct": {
9372+
"type": "Array<string>",
9373+
"format": "",
9374+
},
9375+
"operationResponseType": "GovernanceInsightsResponse",
9376+
},
93629377
"v2.GetHamrOrgConnection": {
93639378
"operationResponseType": "HamrOrgConnectionResponse",
93649379
},
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
@endpoint(governance-insights) @endpoint(governance-insights-v2)
2+
Feature: Governance Insights
3+
Governance Insights surface key usage, configuration, and best-practice
4+
signals for an organization within the Governance Console. Each insight
5+
reports a current value (and, optionally, a previous value for comparison)
6+
along with the query used to compute it, so that the Console can render
7+
trends and highlight areas that need attention.
8+
9+
Background:
10+
Given a valid "apiKeyAuth" key in the system
11+
And a valid "appKeyAuth" key in the system
12+
And an instance of "GovernanceInsights" API
13+
And operation "ListGovernanceInsights" enabled
14+
And new "ListGovernanceInsights" request
15+
16+
@generated @skip @team:DataDog/aaa-governance-console
17+
Scenario: List governance insights returns "Bad Request" response
18+
When the request is sent
19+
Then the response status is 400 Bad Request
20+
21+
@generated @skip @team:DataDog/aaa-governance-console
22+
Scenario: List governance insights returns "OK" response
23+
When the request is sent
24+
Then the response status is 200 OK

features/v2/undo.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2762,6 +2762,12 @@
27622762
"type": "safe"
27632763
}
27642764
},
2765+
"ListGovernanceInsights": {
2766+
"tag": "Governance Insights",
2767+
"undo": {
2768+
"type": "safe"
2769+
}
2770+
},
27652771
"GetHamrOrgConnection": {
27662772
"tag": "High Availability MultiRegion",
27672773
"undo": {

packages/datadog-api-client-common/configuration.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -501,6 +501,7 @@ export function createConfiguration(
501501
"v2.upsertAndPublishFormVersion": false,
502502
"v2.upsertFormVersion": false,
503503
"v2.updateOrgSamlConfigurations": false,
504+
"v2.listGovernanceInsights": false,
504505
"v2.createHamrOrgConnection": false,
505506
"v2.getHamrOrgConnection": false,
506507
"v2.deleteEntityIntegrationConfig": false,
Lines changed: 229 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,229 @@
1+
import { BaseAPIRequestFactory } from "../../datadog-api-client-common/baseapi";
2+
import {
3+
Configuration,
4+
applySecurityAuthentication,
5+
} from "../../datadog-api-client-common/configuration";
6+
import {
7+
RequestContext,
8+
HttpMethod,
9+
ResponseContext,
10+
} from "../../datadog-api-client-common/http/http";
11+
12+
import { logger } from "../../../logger";
13+
import { ObjectSerializer } from "../models/ObjectSerializer";
14+
import { ApiException } from "../../datadog-api-client-common/exception";
15+
16+
import { APIErrorResponse } from "../models/APIErrorResponse";
17+
import { GovernanceInsightsResponse } from "../models/GovernanceInsightsResponse";
18+
import { JSONAPIErrorResponse } from "../models/JSONAPIErrorResponse";
19+
20+
export class GovernanceInsightsApiRequestFactory extends BaseAPIRequestFactory {
21+
public async listGovernanceInsights(
22+
withValues?: boolean,
23+
orgUuid?: string,
24+
filterProduct?: Array<string>,
25+
_options?: Configuration
26+
): Promise<RequestContext> {
27+
const _config = _options || this.configuration;
28+
29+
logger.warn("Using unstable operation 'listGovernanceInsights'");
30+
if (!_config.unstableOperations["v2.listGovernanceInsights"]) {
31+
throw new Error(
32+
"Unstable operation 'listGovernanceInsights' is disabled"
33+
);
34+
}
35+
36+
// Path Params
37+
const localVarPath = "/api/v2/governance/insights";
38+
39+
// Make Request Context
40+
const requestContext = _config
41+
.getServer("v2.GovernanceInsightsApi.listGovernanceInsights")
42+
.makeRequestContext(localVarPath, HttpMethod.GET);
43+
requestContext.setHeaderParam("Accept", "application/json");
44+
requestContext.setHttpConfig(_config.httpConfig);
45+
46+
// Query Params
47+
if (withValues !== undefined) {
48+
requestContext.setQueryParam(
49+
"withValues",
50+
ObjectSerializer.serialize(withValues, "boolean", ""),
51+
""
52+
);
53+
}
54+
if (orgUuid !== undefined) {
55+
requestContext.setQueryParam(
56+
"orgUuid",
57+
ObjectSerializer.serialize(orgUuid, "string", ""),
58+
""
59+
);
60+
}
61+
if (filterProduct !== undefined) {
62+
requestContext.setQueryParam(
63+
"filter[product]",
64+
ObjectSerializer.serialize(filterProduct, "Array<string>", ""),
65+
"multi"
66+
);
67+
}
68+
69+
// Apply auth methods
70+
applySecurityAuthentication(_config, requestContext, [
71+
"apiKeyAuth",
72+
"appKeyAuth",
73+
]);
74+
75+
return requestContext;
76+
}
77+
}
78+
79+
export class GovernanceInsightsApiResponseProcessor {
80+
/**
81+
* Unwraps the actual response sent by the server from the response context and deserializes the response content
82+
* to the expected objects
83+
*
84+
* @params response Response returned by the server for a request to listGovernanceInsights
85+
* @throws ApiException if the response code was not in [200, 299]
86+
*/
87+
public async listGovernanceInsights(
88+
response: ResponseContext
89+
): Promise<GovernanceInsightsResponse> {
90+
const contentType = ObjectSerializer.normalizeMediaType(
91+
response.headers["content-type"]
92+
);
93+
if (response.httpStatusCode === 200) {
94+
const body: GovernanceInsightsResponse = ObjectSerializer.deserialize(
95+
ObjectSerializer.parse(await response.body.text(), contentType),
96+
"GovernanceInsightsResponse"
97+
) as GovernanceInsightsResponse;
98+
return body;
99+
}
100+
if (
101+
response.httpStatusCode === 400 ||
102+
response.httpStatusCode === 401 ||
103+
response.httpStatusCode === 403
104+
) {
105+
const bodyText = ObjectSerializer.parse(
106+
await response.body.text(),
107+
contentType
108+
);
109+
let body: JSONAPIErrorResponse;
110+
try {
111+
body = ObjectSerializer.deserialize(
112+
bodyText,
113+
"JSONAPIErrorResponse"
114+
) as JSONAPIErrorResponse;
115+
} catch (error) {
116+
logger.debug(`Got error deserializing error: ${error}`);
117+
throw new ApiException<JSONAPIErrorResponse>(
118+
response.httpStatusCode,
119+
bodyText
120+
);
121+
}
122+
throw new ApiException<JSONAPIErrorResponse>(
123+
response.httpStatusCode,
124+
body
125+
);
126+
}
127+
if (response.httpStatusCode === 429) {
128+
const bodyText = ObjectSerializer.parse(
129+
await response.body.text(),
130+
contentType
131+
);
132+
let body: APIErrorResponse;
133+
try {
134+
body = ObjectSerializer.deserialize(
135+
bodyText,
136+
"APIErrorResponse"
137+
) as APIErrorResponse;
138+
} catch (error) {
139+
logger.debug(`Got error deserializing error: ${error}`);
140+
throw new ApiException<APIErrorResponse>(
141+
response.httpStatusCode,
142+
bodyText
143+
);
144+
}
145+
throw new ApiException<APIErrorResponse>(response.httpStatusCode, body);
146+
}
147+
148+
// Work around for missing responses in specification, e.g. for petstore.yaml
149+
if (response.httpStatusCode >= 200 && response.httpStatusCode <= 299) {
150+
const body: GovernanceInsightsResponse = ObjectSerializer.deserialize(
151+
ObjectSerializer.parse(await response.body.text(), contentType),
152+
"GovernanceInsightsResponse",
153+
""
154+
) as GovernanceInsightsResponse;
155+
return body;
156+
}
157+
158+
const body = (await response.body.text()) || "";
159+
throw new ApiException<string>(
160+
response.httpStatusCode,
161+
'Unknown API Status Code!\nBody: "' + body + '"'
162+
);
163+
}
164+
}
165+
166+
export interface GovernanceInsightsApiListGovernanceInsightsRequest {
167+
/**
168+
* Whether to compute and include the current and previous value of each insight.
169+
* Defaults to `false`, in which case only insight metadata is returned.
170+
* @type boolean
171+
*/
172+
withValues?: boolean;
173+
/**
174+
* The UUID of the organization to compute insights for. Defaults to the organization of
175+
* the authenticated user. Used to retrieve insights for a child organization from a
176+
* parent organization.
177+
* @type string
178+
*/
179+
orgUuid?: string;
180+
/**
181+
* Restrict the results to insights belonging to the given products. May be repeated to
182+
* filter by multiple products. Matching is case-insensitive.
183+
* @type Array<string>
184+
*/
185+
filterProduct?: Array<string>;
186+
}
187+
188+
export class GovernanceInsightsApi {
189+
private requestFactory: GovernanceInsightsApiRequestFactory;
190+
private responseProcessor: GovernanceInsightsApiResponseProcessor;
191+
private configuration: Configuration;
192+
193+
public constructor(
194+
configuration: Configuration,
195+
requestFactory?: GovernanceInsightsApiRequestFactory,
196+
responseProcessor?: GovernanceInsightsApiResponseProcessor
197+
) {
198+
this.configuration = configuration;
199+
this.requestFactory =
200+
requestFactory || new GovernanceInsightsApiRequestFactory(configuration);
201+
this.responseProcessor =
202+
responseProcessor || new GovernanceInsightsApiResponseProcessor();
203+
}
204+
205+
/**
206+
* Retrieve the list of governance insights available to the organization. By default, only
207+
* insight metadata is returned; pass `withValues=true` to also compute and include each
208+
* insight's current and previous values. Insights can be filtered by product.
209+
* @param param The request object
210+
*/
211+
public listGovernanceInsights(
212+
param: GovernanceInsightsApiListGovernanceInsightsRequest = {},
213+
options?: Configuration
214+
): Promise<GovernanceInsightsResponse> {
215+
const requestContextPromise = this.requestFactory.listGovernanceInsights(
216+
param.withValues,
217+
param.orgUuid,
218+
param.filterProduct,
219+
options
220+
);
221+
return requestContextPromise.then((requestContext) => {
222+
return this.configuration.httpApi
223+
.send(requestContext)
224+
.then((responseContext) => {
225+
return this.responseProcessor.listGovernanceInsights(responseContext);
226+
});
227+
});
228+
}
229+
}

packages/datadog-api-client-v2/index.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,11 @@ export {
644644
GoogleChatIntegrationApi,
645645
} from "./apis/GoogleChatIntegrationApi";
646646

647+
export {
648+
GovernanceInsightsApiListGovernanceInsightsRequest,
649+
GovernanceInsightsApi,
650+
} from "./apis/GovernanceInsightsApi";
651+
647652
export {
648653
HighAvailabilityMultiRegionApiCreateHamrOrgConnectionRequest,
649654
HighAvailabilityMultiRegionApi,
@@ -4117,6 +4122,19 @@ export { GoogleChatUpdateOrganizationHandleRequestAttributes } from "./models/Go
41174122
export { GoogleChatUpdateOrganizationHandleRequestData } from "./models/GoogleChatUpdateOrganizationHandleRequestData";
41184123
export { GoogleMeetConfigurationReference } from "./models/GoogleMeetConfigurationReference";
41194124
export { GoogleMeetConfigurationReferenceData } from "./models/GoogleMeetConfigurationReferenceData";
4125+
export { GovernanceBestPracticeDefinition } from "./models/GovernanceBestPracticeDefinition";
4126+
export { GovernanceInsightAttributes } from "./models/GovernanceInsightAttributes";
4127+
export { GovernanceInsightAuditCompute } from "./models/GovernanceInsightAuditCompute";
4128+
export { GovernanceInsightAuditQuery } from "./models/GovernanceInsightAuditQuery";
4129+
export { GovernanceInsightData } from "./models/GovernanceInsightData";
4130+
export { GovernanceInsightEventCompute } from "./models/GovernanceInsightEventCompute";
4131+
export { GovernanceInsightEventQuery } from "./models/GovernanceInsightEventQuery";
4132+
export { GovernanceInsightMetricQuery } from "./models/GovernanceInsightMetricQuery";
4133+
export { GovernanceInsightPercentageQuery } from "./models/GovernanceInsightPercentageQuery";
4134+
export { GovernanceInsightQueryConfig } from "./models/GovernanceInsightQueryConfig";
4135+
export { GovernanceInsightResourceType } from "./models/GovernanceInsightResourceType";
4136+
export { GovernanceInsightsResponse } from "./models/GovernanceInsightsResponse";
4137+
export { GovernanceInsightUsageQuery } from "./models/GovernanceInsightUsageQuery";
41204138
export { GreyNoiseAPIKey } from "./models/GreyNoiseAPIKey";
41214139
export { GreyNoiseAPIKeyType } from "./models/GreyNoiseAPIKeyType";
41224140
export { GreyNoiseAPIKeyUpdate } from "./models/GreyNoiseAPIKeyUpdate";

0 commit comments

Comments
 (0)