Skip to content

Commit

Permalink
feat(client-batch): This release adds support for the AWS Batch GetJo…
Browse files Browse the repository at this point in the history
…bQueueSnapshot API operation.
  • Loading branch information
awstools committed Jun 3, 2024
1 parent d391abe commit 2129ba2
Show file tree
Hide file tree
Showing 8 changed files with 368 additions and 8 deletions.
8 changes: 8 additions & 0 deletions clients/client-batch/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,14 @@ DescribeSchedulingPolicies

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/batch/command/DescribeSchedulingPoliciesCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-batch/Interface/DescribeSchedulingPoliciesCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-batch/Interface/DescribeSchedulingPoliciesCommandOutput/)

</details>
<details>
<summary>
GetJobQueueSnapshot
</summary>

[Command API Reference](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/client/batch/command/GetJobQueueSnapshotCommand/) / [Input](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-batch/Interface/GetJobQueueSnapshotCommandInput/) / [Output](https://docs.aws.amazon.com/AWSJavaScriptSDK/v3/latest/Package/-aws-sdk-client-batch/Interface/GetJobQueueSnapshotCommandOutput/)

</details>
<details>
<summary>
Expand Down
23 changes: 23 additions & 0 deletions clients/client-batch/src/Batch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ import {
DescribeSchedulingPoliciesCommandInput,
DescribeSchedulingPoliciesCommandOutput,
} from "./commands/DescribeSchedulingPoliciesCommand";
import {
GetJobQueueSnapshotCommand,
GetJobQueueSnapshotCommandInput,
GetJobQueueSnapshotCommandOutput,
} from "./commands/GetJobQueueSnapshotCommand";
import { ListJobsCommand, ListJobsCommandInput, ListJobsCommandOutput } from "./commands/ListJobsCommand";
import {
ListSchedulingPoliciesCommand,
Expand Down Expand Up @@ -122,6 +127,7 @@ const commands = {
DescribeJobQueuesCommand,
DescribeJobsCommand,
DescribeSchedulingPoliciesCommand,
GetJobQueueSnapshotCommand,
ListJobsCommand,
ListSchedulingPoliciesCommand,
ListTagsForResourceCommand,
Expand Down Expand Up @@ -342,6 +348,23 @@ export interface Batch {
cb: (err: any, data?: DescribeSchedulingPoliciesCommandOutput) => void
): void;

/**
* @see {@link GetJobQueueSnapshotCommand}
*/
getJobQueueSnapshot(
args: GetJobQueueSnapshotCommandInput,
options?: __HttpHandlerOptions
): Promise<GetJobQueueSnapshotCommandOutput>;
getJobQueueSnapshot(
args: GetJobQueueSnapshotCommandInput,
cb: (err: any, data?: GetJobQueueSnapshotCommandOutput) => void
): void;
getJobQueueSnapshot(
args: GetJobQueueSnapshotCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: GetJobQueueSnapshotCommandOutput) => void
): void;

/**
* @see {@link ListJobsCommand}
*/
Expand Down
6 changes: 6 additions & 0 deletions clients/client-batch/src/BatchClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,10 @@ import {
DescribeSchedulingPoliciesCommandInput,
DescribeSchedulingPoliciesCommandOutput,
} from "./commands/DescribeSchedulingPoliciesCommand";
import {
GetJobQueueSnapshotCommandInput,
GetJobQueueSnapshotCommandOutput,
} from "./commands/GetJobQueueSnapshotCommand";
import { ListJobsCommandInput, ListJobsCommandOutput } from "./commands/ListJobsCommand";
import {
ListSchedulingPoliciesCommandInput,
Expand Down Expand Up @@ -144,6 +148,7 @@ export type ServiceInputTypes =
| DescribeJobQueuesCommandInput
| DescribeJobsCommandInput
| DescribeSchedulingPoliciesCommandInput
| GetJobQueueSnapshotCommandInput
| ListJobsCommandInput
| ListSchedulingPoliciesCommandInput
| ListTagsForResourceCommandInput
Expand Down Expand Up @@ -173,6 +178,7 @@ export type ServiceOutputTypes =
| DescribeJobQueuesCommandOutput
| DescribeJobsCommandOutput
| DescribeSchedulingPoliciesCommandOutput
| GetJobQueueSnapshotCommandOutput
| ListJobsCommandOutput
| ListSchedulingPoliciesCommandOutput
| ListTagsForResourceCommandOutput
Expand Down
97 changes: 97 additions & 0 deletions clients/client-batch/src/commands/GetJobQueueSnapshotCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
// smithy-typescript generated code
import { getEndpointPlugin } from "@smithy/middleware-endpoint";
import { getSerdePlugin } from "@smithy/middleware-serde";
import { Command as $Command } from "@smithy/smithy-client";
import { MetadataBearer as __MetadataBearer } from "@smithy/types";

import { BatchClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../BatchClient";
import { commonParams } from "../endpoint/EndpointParameters";
import { GetJobQueueSnapshotRequest, GetJobQueueSnapshotResponse } from "../models/models_0";
import { de_GetJobQueueSnapshotCommand, se_GetJobQueueSnapshotCommand } from "../protocols/Aws_restJson1";

/**
* @public
*/
export { __MetadataBearer, $Command };
/**
* @public
*
* The input for {@link GetJobQueueSnapshotCommand}.
*/
export interface GetJobQueueSnapshotCommandInput extends GetJobQueueSnapshotRequest {}
/**
* @public
*
* The output of {@link GetJobQueueSnapshotCommand}.
*/
export interface GetJobQueueSnapshotCommandOutput extends GetJobQueueSnapshotResponse, __MetadataBearer {}

/**
* <p>Provides a list of the first 100 <code>RUNNABLE</code> jobs associated to a single job queue.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { BatchClient, GetJobQueueSnapshotCommand } from "@aws-sdk/client-batch"; // ES Modules import
* // const { BatchClient, GetJobQueueSnapshotCommand } = require("@aws-sdk/client-batch"); // CommonJS import
* const client = new BatchClient(config);
* const input = { // GetJobQueueSnapshotRequest
* jobQueue: "STRING_VALUE", // required
* };
* const command = new GetJobQueueSnapshotCommand(input);
* const response = await client.send(command);
* // { // GetJobQueueSnapshotResponse
* // frontOfQueue: { // FrontOfQueueDetail
* // jobs: [ // FrontOfQueueJobSummaryList
* // { // FrontOfQueueJobSummary
* // jobArn: "STRING_VALUE",
* // earliestTimeAtPosition: Number("long"),
* // },
* // ],
* // lastUpdatedAt: Number("long"),
* // },
* // };
*
* ```
*
* @param GetJobQueueSnapshotCommandInput - {@link GetJobQueueSnapshotCommandInput}
* @returns {@link GetJobQueueSnapshotCommandOutput}
* @see {@link GetJobQueueSnapshotCommandInput} for command's `input` shape.
* @see {@link GetJobQueueSnapshotCommandOutput} for command's `response` shape.
* @see {@link BatchClientResolvedConfig | config} for BatchClient's `config` shape.
*
* @throws {@link ClientException} (client fault)
* <p>These errors are usually caused by a client action. One example cause is using an action or resource on behalf
* of a user that doesn't have permissions to use the action or resource. Another cause is specifying an identifier
* that's not valid.</p>
*
* @throws {@link ServerException} (server fault)
* <p>These errors are usually caused by a server issue.</p>
*
* @throws {@link BatchServiceException}
* <p>Base exception class for all service exceptions from Batch service.</p>
*
* @public
*/
export class GetJobQueueSnapshotCommand extends $Command
.classBuilder<
GetJobQueueSnapshotCommandInput,
GetJobQueueSnapshotCommandOutput,
BatchClientResolvedConfig,
ServiceInputTypes,
ServiceOutputTypes
>()
.ep({
...commonParams,
})
.m(function (this: any, Command: any, cs: any, config: BatchClientResolvedConfig, o: any) {
return [
getSerdePlugin(config, this.serialize, this.deserialize),
getEndpointPlugin(config, Command.getEndpointParameterInstructions()),
];
})
.s("AWSBatchV20160810", "GetJobQueueSnapshot", {})
.n("BatchClient", "GetJobQueueSnapshotCommand")
.f(void 0, void 0)
.ser(se_GetJobQueueSnapshotCommand)
.de(de_GetJobQueueSnapshotCommand)
.build() {}
1 change: 1 addition & 0 deletions clients/client-batch/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export * from "./DescribeJobDefinitionsCommand";
export * from "./DescribeJobQueuesCommand";
export * from "./DescribeJobsCommand";
export * from "./DescribeSchedulingPoliciesCommand";
export * from "./GetJobQueueSnapshotCommand";
export * from "./ListJobsCommand";
export * from "./ListSchedulingPoliciesCommand";
export * from "./ListTagsForResourceCommand";
Expand Down
82 changes: 75 additions & 7 deletions clients/client-batch/src/models/models_0.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5629,6 +5629,64 @@ export interface DescribeSchedulingPoliciesResponse {
schedulingPolicies?: SchedulingPolicyDetail[];
}

/**
* @public
*/
export interface GetJobQueueSnapshotRequest {
/**
* <p>The job queue’s name or full queue Amazon Resource Name (ARN).</p>
* @public
*/
jobQueue: string | undefined;
}

/**
* <p>An object that represents summary details for the first 100 <code>RUNNABLE</code> jobs in a job queue.</p>
* @public
*/
export interface FrontOfQueueJobSummary {
/**
* <p>The ARN for a job in a named job queue.</p>
* @public
*/
jobArn?: string;

/**
* <p>The Unix timestamp (in milliseconds) for when the job transitioned to its current position in the job queue.</p>
* @public
*/
earliestTimeAtPosition?: number;
}

/**
* <p>Contains a list of the first 100 <code>RUNNABLE</code> jobs associated to a single job queue.</p>
* @public
*/
export interface FrontOfQueueDetail {
/**
* <p>The Amazon Resource Names (ARNs) of the first 100 <code>RUNNABLE</code> jobs in a named job queue. For first-in-first-out (FIFO) job queues, jobs are ordered based on their submission time. For fair share scheduling (FSS) job queues, jobs are ordered based on their job priority and share usage.</p>
* @public
*/
jobs?: FrontOfQueueJobSummary[];

/**
* <p>The Unix timestamp (in milliseconds) for when each of the first 100 <code>RUNNABLE</code> jobs were last updated. </p>
* @public
*/
lastUpdatedAt?: number;
}

/**
* @public
*/
export interface GetJobQueueSnapshotResponse {
/**
* <p>The list of the first 100 <code>RUNNABLE</code> jobs in each job queue. For first-in-first-out (FIFO) job queues, jobs are ordered based on their submission time. For fair share scheduling (FSS) job queues, jobs are ordered based on their job priority and share usage.</p>
* @public
*/
frontOfQueue?: FrontOfQueueDetail;
}

/**
* <p>A filter name and value pair that's used to return a more specific list of results from a
* <code>ListJobs</code> API operation.</p>
Expand Down Expand Up @@ -5683,13 +5741,23 @@ export interface ListJobsRequest {
jobStatus?: JobStatus;

/**
* <p>The maximum number of results returned by <code>ListJobs</code> in paginated output. When
* this parameter is used, <code>ListJobs</code> only returns <code>maxResults</code> results in
* a single page and a <code>nextToken</code> response element. The remaining results of the
* initial request can be seen by sending another <code>ListJobs</code> request with the returned
* <code>nextToken</code> value. This value can be between 1 and
* 100. If this parameter isn't used, then <code>ListJobs</code> returns up to
* 100 results and a <code>nextToken</code> value if applicable.</p>
* <p>The maximum number of results returned by <code>ListJobs</code> in a paginated output. When this parameter is used, <code>ListJobs</code> returns up to <code>maxResults</code> results in a single page and a <code>nextToken</code> response element, if applicable. The remaining results of the initial request can be seen by sending another <code>ListJobs</code> request with the returned <code>nextToken</code> value.</p>
* <p>The following outlines key parameters and limitations:</p>
* <ul>
* <li>
* <p>The minimum value is 1. </p>
* </li>
* <li>
* <p>When <code>--job-status</code> is used, Batch returns up to 1000 values. </p>
* </li>
* <li>
* <p>When <code>--filters</code> is used, Batch returns up to 100 values.</p>
* </li>
* <li>
* <p>If neither parameter is used, then <code>ListJobs</code> returns up to
* 1000 results (jobs that are in the <code>RUNNING</code> status) and a <code>nextToken</code> value, if applicable.</p>
* </li>
* </ul>
* @public
*/
maxResults?: number;
Expand Down
53 changes: 53 additions & 0 deletions clients/client-batch/src/protocols/Aws_restJson1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ import {
DescribeSchedulingPoliciesCommandInput,
DescribeSchedulingPoliciesCommandOutput,
} from "../commands/DescribeSchedulingPoliciesCommand";
import {
GetJobQueueSnapshotCommandInput,
GetJobQueueSnapshotCommandOutput,
} from "../commands/GetJobQueueSnapshotCommand";
import { ListJobsCommandInput, ListJobsCommandOutput } from "../commands/ListJobsCommand";
import {
ListSchedulingPoliciesCommandInput,
Expand Down Expand Up @@ -473,6 +477,28 @@ export const se_DescribeSchedulingPoliciesCommand = async (
return b.build();
};

/**
* serializeAws_restJson1GetJobQueueSnapshotCommand
*/
export const se_GetJobQueueSnapshotCommand = async (
input: GetJobQueueSnapshotCommandInput,
context: __SerdeContext
): Promise<__HttpRequest> => {
const b = rb(input, context);
const headers: any = {
"content-type": "application/json",
};
b.bp("/v1/getjobqueuesnapshot");
let body: any;
body = JSON.stringify(
take(input, {
jobQueue: [],
})
);
b.m("POST").h(headers).b(body);
return b.build();
};

/**
* serializeAws_restJson1ListJobsCommand
*/
Expand Down Expand Up @@ -1015,6 +1041,27 @@ export const de_DescribeSchedulingPoliciesCommand = async (
return contents;
};

/**
* deserializeAws_restJson1GetJobQueueSnapshotCommand
*/
export const de_GetJobQueueSnapshotCommand = async (
output: __HttpResponse,
context: __SerdeContext
): Promise<GetJobQueueSnapshotCommandOutput> => {
if (output.statusCode !== 200 && output.statusCode >= 300) {
return de_CommandError(output, context);
}
const contents: any = map({
$metadata: deserializeMetadata(output),
});
const data: Record<string, any> = __expectNonNull(__expectObject(await parseBody(output.body, context)), "body");
const doc = take(data, {
frontOfQueue: _json,
});
Object.assign(contents, doc);
return contents;
};

/**
* deserializeAws_restJson1ListJobsCommand
*/
Expand Down Expand Up @@ -1676,6 +1723,12 @@ const de_FairsharePolicy = (output: any, context: __SerdeContext): FairsharePoli

// de_FargatePlatformConfiguration omitted.

// de_FrontOfQueueDetail omitted.

// de_FrontOfQueueJobSummary omitted.

// de_FrontOfQueueJobSummaryList omitted.

// de_Host omitted.

// de_ImagePullSecret omitted.
Expand Down
Loading

0 comments on commit 2129ba2

Please sign in to comment.