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
58 changes: 58 additions & 0 deletions .generator/schemas/v2/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -86549,6 +86549,34 @@ components:
required:
- data
type: object
TestExample:
description: A test example resource.
properties:
created_at:
description: Creation time of the test example.
format: date-time
readOnly: true
type: string
id:
description: The ID of the test example.
example: "abc-123"
type: string
name:
description: The name of the test example.
example: "My Test Example"
type: string
required:
- id
- name
type: object
TestExamplesResponse:
description: Response containing a list of test examples.
properties:
data:
items:
$ref: "#/components/schemas/TestExample"
type: array
type: object
TestOptimizationDeleteServiceSettingsRequest:
description: Request object for deleting Test Optimization service settings.
properties:
Expand Down Expand Up @@ -158742,6 +158770,34 @@ paths:
operator: OR
permissions:
- teams_read
/api/v2/test-examples:
get:
description: Get a list of all test examples.
operationId: ListTestExamples
responses:
"200":
content:
application/json:
examples:
default:
value:
data:
- id: "abc-123"
name: "My Test Example"
schema:
$ref: "#/components/schemas/TestExamplesResponse"
description: OK
"403":
$ref: "#/components/responses/ForbiddenResponse"
"429":
$ref: "#/components/responses/TooManyRequestsResponse"
summary: List test examples
tags:
- Test Examples
x-permission:
operator: OR
permissions:
- test_read
/api/v2/test/flaky-test-management/tests:
patch:
description: |-
Expand Down Expand Up @@ -162115,6 +162171,8 @@ tags:
name: Synthetics
- description: View and manage teams within Datadog. See the [Teams page](https://docs.datadoghq.com/account_management/teams/) for more information.
name: Teams
- description: Manage test example resources.
name: Test Examples
- description: |-
Search and manage flaky tests through Test Optimization. See the [Test Optimization page](https://docs.datadoghq.com/tests/) for more information.
name: Test Optimization
Expand Down
12 changes: 12 additions & 0 deletions features/v2/test_examples.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
@endpoint(test-examples) @endpoint(test-examples-v2)
Feature: Test Examples
Manage test example resources.

@generated @skip @team:DataDog/webframeworks-test
Scenario: List test examples returns "OK" response
Given a valid "apiKeyAuth" key in the system
And a valid "appKeyAuth" key in the system
And an instance of "TestExamples" API
And new "ListTestExamples" request
When the request is sent
Then the response status is 200 OK
6 changes: 6 additions & 0 deletions features/v2/undo.json
Original file line number Diff line number Diff line change
Expand Up @@ -7776,6 +7776,12 @@
"type": "idempotent"
}
},
"ListTestExamples": {
"tag": "Test Examples",
"undo": {
"type": "safe"
}
},
"UpdateFlakyTests": {
"tag": "Test Optimization",
"undo": {
Expand Down
1 change: 1 addition & 0 deletions packages/datadog-api-client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,7 @@ apiInstance
| Synthetics | @datadog/datadog-api-client-synthetics | [README.md](../../services/synthetics/README.md) |
| Tags | @datadog/datadog-api-client-tags | [README.md](../../services/tags/README.md) |
| Teams | @datadog/datadog-api-client-teams | [README.md](../../services/teams/README.md) |
| Test Examples | @datadog/datadog-api-client-test-examples | [README.md](../../services/test-examples/README.md) |
| Test Optimization | @datadog/datadog-api-client-test-optimization | [README.md](../../services/test-optimization/README.md) |
| Usage Metering | @datadog/datadog-api-client-usage-metering | [README.md](../../services/usage-metering/README.md) |
| Users | @datadog/datadog-api-client-users | [README.md](../../services/users/README.md) |
Expand Down
3 changes: 3 additions & 0 deletions private/bdd_runner/src/support/scenarios_model_mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14481,6 +14481,9 @@ export const ScenariosModelMappings: { [key: string]: OperationMapping } = {
},
operationResponseType: "UserTeamsResponse",
},
"TestExamplesApi.V2.ListTestExamples": {
operationResponseType: "TestExamplesResponse",
},
"WebIntegrationsApi.V2.ListWebIntegrationAccounts": {
integrationName: {
type: "string",
Expand Down
1 change: 1 addition & 0 deletions services/test_examples/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodeLinker: node-modules
35 changes: 35 additions & 0 deletions services/test_examples/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# @datadog/datadog-api-client-test-examples

## Description

Manage test example resources.

## Navigation

- [Installation](#installation)
- [Getting Started](#getting-started)

## Installation

```sh
# NPM
npm install @datadog/datadog-api-client-test-examples
# Yarn
yarn add @datadog/datadog-api-client-test-examples
```

## Getting Started
```ts
import { createConfiguration } from "@datadog/datadog-api-client";
import { TestExamplesApiV2 } from "@datadog/datadog-api-client-test-examples";
import { v2 } from "@datadog/datadog-api-client-test-examples";

const configuration = createConfiguration();
const apiInstance = new TestExamplesApiV2(configuration);

apiInstance.listTestExamples().then((data) => {
console.log("API called successfully. Returned data: " + JSON.stringify(data));
}).catch((error) => {
console.error("Error calling API: " + error);
});
```
43 changes: 43 additions & 0 deletions services/test_examples/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "@datadog/datadog-api-client-test-examples",
"description": "",
"author": "",
"keywords": [
"api",
"fetch",
"typescript"
],
"license": "Apache-2.0",
"licenses": [
{
"type": "Apache-2.0",
"url": "http://www.apache.org/licenses/LICENSE-2.0"
}
],
"repository": {
"type": "git",
"url": "https://github.com/DataDog/datadog-api-client-typescript.git",
"directory": "services/test-examples"
},
"files": [
"dist/**/*"
],
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"scripts": {
"prepack": "yarn workspace @datadog/datadog-api-client build && yarn build",
"build": "yarn generate-version-files && tsc",
"generate-version-files": "node -p \"'export const version = ' + JSON.stringify(require('./package.json').version)\" > src/version.ts"
},
"dependencies": {
"@datadog/datadog-api-client": "^2.0.0-beta.2"
},
"devDependencies": {
"typescript": "5.8.3"
},
"engines": {
"node": ">=18.0.0"
},
"version": "0.0.1",
"packageManager": "yarn@4.9.1"
}
3 changes: 3 additions & 0 deletions services/test_examples/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
export * as v2 from "./v2";

export { TestExamplesApi as TestExamplesApiV2 } from "./v2/TestExamplesApi";
167 changes: 167 additions & 0 deletions services/test_examples/src/v2/TestExamplesApi.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
import {
ApiException,
BaseAPIRequestFactory,
BaseServerConfiguration,
buildUserAgent,
Configuration,
createConfiguration,
deserialize,
getPreferredMediaType,
HttpMethod,
isBrowser,
logger,
normalizeMediaType,
parse,
RequiredError,
RequestContext,
ResponseContext,
serialize,
ServerConfiguration,
stringify,
applySecurityAuthentication,
} from "@datadog/datadog-api-client";

import { TypingInfo } from "./models/TypingInfo";
import { APIErrorResponse } from "./models/APIErrorResponse";
import { TestExamplesResponse } from "./models/TestExamplesResponse";
import { version } from "../version";

export class TestExamplesApiRequestFactory extends BaseAPIRequestFactory {
public userAgent: string | undefined;

public constructor(configuration: Configuration) {
super(configuration);
if (!isBrowser) {
this.userAgent = buildUserAgent("test-examples", version);
}
}
public async listTestExamples(
_options?: Configuration,
): Promise<RequestContext> {
const _config = _options || this.configuration;

// Path Params
const localVarPath = "/api/v2/test-examples";

// Make Request Context
const { server, overrides } = _config.getServerAndOverrides(
"TestExamplesApi.v2.listTestExamples",
TestExamplesApi.operationServers,
);
const requestContext = server.makeRequestContext(
localVarPath,
HttpMethod.GET,
overrides,
);
requestContext.setHeaderParam("Accept", "application/json");
requestContext.setHttpConfig(_config.httpConfig);

// Set User-Agent
if (this.userAgent) {
requestContext.setHeaderParam("User-Agent", this.userAgent);
}

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

return requestContext;
}
}

export class TestExamplesApiResponseProcessor {
/**
* 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 listTestExamples
* @throws ApiException if the response code was not in [200, 299]
*/
public async listTestExamples(
response: ResponseContext,
): Promise<TestExamplesResponse> {
const contentType = normalizeMediaType(response.headers["content-type"]);
if (response.httpStatusCode === 200) {
const body: TestExamplesResponse = deserialize(
parse(await response.body.text(), contentType),
TypingInfo,
"TestExamplesResponse",
) as TestExamplesResponse;
return body;
}
if (response.httpStatusCode === 403 || response.httpStatusCode === 429) {
const bodyText = parse(await response.body.text(), contentType);
let body: APIErrorResponse;
try {
body = deserialize(
bodyText,
TypingInfo,
"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);
}

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

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

export class TestExamplesApi {
private requestFactory: TestExamplesApiRequestFactory;
private responseProcessor: TestExamplesApiResponseProcessor;
private configuration: Configuration;

static operationServers: { [key: string]: BaseServerConfiguration[] } = {};

public constructor(
configuration?: Configuration,
requestFactory?: TestExamplesApiRequestFactory,
responseProcessor?: TestExamplesApiResponseProcessor,
) {
this.configuration = configuration || createConfiguration();
this.requestFactory =
requestFactory || new TestExamplesApiRequestFactory(this.configuration);
this.responseProcessor =
responseProcessor || new TestExamplesApiResponseProcessor();
}

/**
* Get a list of all test examples.
* @param param The request object
*/
public listTestExamples(
options?: Configuration,
): Promise<TestExamplesResponse> {
const requestContextPromise = this.requestFactory.listTestExamples(options);
return requestContextPromise.then((requestContext) => {
return this.configuration.httpApi
.send(requestContext)
.then((responseContext) => {
return this.responseProcessor.listTestExamples(responseContext);
});
});
}
}
5 changes: 5 additions & 0 deletions services/test_examples/src/v2/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
export { TestExamplesApi } from "./TestExamplesApi";

export { APIErrorResponse } from "./models/APIErrorResponse";
export { TestExample } from "./models/TestExample";
export { TestExamplesResponse } from "./models/TestExamplesResponse";
Loading
Loading