Skip to content

Commit 6f03fb8

Browse files
author
awstools
committed
feat(client-workspaces): Added CreateWorkspaceImage API to create a new WorkSpace image from an existing WorkSpace.
1 parent 352b023 commit 6f03fb8

File tree

7 files changed

+518
-50
lines changed

7 files changed

+518
-50
lines changed

clients/client-workspaces/src/WorkSpaces.ts

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,11 @@ import {
4747
CreateWorkspaceBundleCommandInput,
4848
CreateWorkspaceBundleCommandOutput,
4949
} from "./commands/CreateWorkspaceBundleCommand";
50+
import {
51+
CreateWorkspaceImageCommand,
52+
CreateWorkspaceImageCommandInput,
53+
CreateWorkspaceImageCommandOutput,
54+
} from "./commands/CreateWorkspaceImageCommand";
5055
import {
5156
CreateWorkspacesCommand,
5257
CreateWorkspacesCommandInput,
@@ -687,6 +692,38 @@ export class WorkSpaces extends WorkSpacesClient {
687692
}
688693
}
689694

695+
/**
696+
* <p>Creates a new WorkSpace image from an existing WorkSpace.</p>
697+
*/
698+
public createWorkspaceImage(
699+
args: CreateWorkspaceImageCommandInput,
700+
options?: __HttpHandlerOptions
701+
): Promise<CreateWorkspaceImageCommandOutput>;
702+
public createWorkspaceImage(
703+
args: CreateWorkspaceImageCommandInput,
704+
cb: (err: any, data?: CreateWorkspaceImageCommandOutput) => void
705+
): void;
706+
public createWorkspaceImage(
707+
args: CreateWorkspaceImageCommandInput,
708+
options: __HttpHandlerOptions,
709+
cb: (err: any, data?: CreateWorkspaceImageCommandOutput) => void
710+
): void;
711+
public createWorkspaceImage(
712+
args: CreateWorkspaceImageCommandInput,
713+
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: CreateWorkspaceImageCommandOutput) => void),
714+
cb?: (err: any, data?: CreateWorkspaceImageCommandOutput) => void
715+
): Promise<CreateWorkspaceImageCommandOutput> | void {
716+
const command = new CreateWorkspaceImageCommand(args);
717+
if (typeof optionsOrCb === "function") {
718+
this.send(command, optionsOrCb);
719+
} else if (typeof cb === "function") {
720+
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
721+
this.send(command, optionsOrCb || {}, cb);
722+
} else {
723+
return this.send(command, optionsOrCb);
724+
}
725+
}
726+
690727
/**
691728
* <p>Creates one or more WorkSpaces.</p>
692729
* <p>This operation is asynchronous and returns before the WorkSpaces are created.</p>

clients/client-workspaces/src/WorkSpacesClient.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,10 @@ import {
7878
CreateWorkspaceBundleCommandInput,
7979
CreateWorkspaceBundleCommandOutput,
8080
} from "./commands/CreateWorkspaceBundleCommand";
81+
import {
82+
CreateWorkspaceImageCommandInput,
83+
CreateWorkspaceImageCommandOutput,
84+
} from "./commands/CreateWorkspaceImageCommand";
8185
import { CreateWorkspacesCommandInput, CreateWorkspacesCommandOutput } from "./commands/CreateWorkspacesCommand";
8286
import {
8387
DeleteClientBrandingCommandInput,
@@ -250,6 +254,7 @@ export type ServiceInputTypes =
250254
| CreateTagsCommandInput
251255
| CreateUpdatedWorkspaceImageCommandInput
252256
| CreateWorkspaceBundleCommandInput
257+
| CreateWorkspaceImageCommandInput
253258
| CreateWorkspacesCommandInput
254259
| DeleteClientBrandingCommandInput
255260
| DeleteConnectClientAddInCommandInput
@@ -313,6 +318,7 @@ export type ServiceOutputTypes =
313318
| CreateTagsCommandOutput
314319
| CreateUpdatedWorkspaceImageCommandOutput
315320
| CreateWorkspaceBundleCommandOutput
321+
| CreateWorkspaceImageCommandOutput
316322
| CreateWorkspacesCommandOutput
317323
| DeleteClientBrandingCommandOutput
318324
| DeleteConnectClientAddInCommandOutput
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
// smithy-typescript generated code
2+
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
3+
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
4+
import { Command as $Command } from "@aws-sdk/smithy-client";
5+
import {
6+
FinalizeHandlerArguments,
7+
Handler,
8+
HandlerExecutionContext,
9+
HttpHandlerOptions as __HttpHandlerOptions,
10+
MetadataBearer as __MetadataBearer,
11+
MiddlewareStack,
12+
SerdeContext as __SerdeContext,
13+
} from "@aws-sdk/types";
14+
15+
import {
16+
CreateWorkspaceImageRequest,
17+
CreateWorkspaceImageRequestFilterSensitiveLog,
18+
CreateWorkspaceImageResult,
19+
CreateWorkspaceImageResultFilterSensitiveLog,
20+
} from "../models/models_0";
21+
import {
22+
deserializeAws_json1_1CreateWorkspaceImageCommand,
23+
serializeAws_json1_1CreateWorkspaceImageCommand,
24+
} from "../protocols/Aws_json1_1";
25+
import { ServiceInputTypes, ServiceOutputTypes, WorkSpacesClientResolvedConfig } from "../WorkSpacesClient";
26+
27+
export interface CreateWorkspaceImageCommandInput extends CreateWorkspaceImageRequest {}
28+
export interface CreateWorkspaceImageCommandOutput extends CreateWorkspaceImageResult, __MetadataBearer {}
29+
30+
/**
31+
* <p>Creates a new WorkSpace image from an existing WorkSpace.</p>
32+
* @example
33+
* Use a bare-bones client and the command you need to make an API call.
34+
* ```javascript
35+
* import { WorkSpacesClient, CreateWorkspaceImageCommand } from "@aws-sdk/client-workspaces"; // ES Modules import
36+
* // const { WorkSpacesClient, CreateWorkspaceImageCommand } = require("@aws-sdk/client-workspaces"); // CommonJS import
37+
* const client = new WorkSpacesClient(config);
38+
* const command = new CreateWorkspaceImageCommand(input);
39+
* const response = await client.send(command);
40+
* ```
41+
*
42+
* @see {@link CreateWorkspaceImageCommandInput} for command's `input` shape.
43+
* @see {@link CreateWorkspaceImageCommandOutput} for command's `response` shape.
44+
* @see {@link WorkSpacesClientResolvedConfig | config} for WorkSpacesClient's `config` shape.
45+
*
46+
*/
47+
export class CreateWorkspaceImageCommand extends $Command<
48+
CreateWorkspaceImageCommandInput,
49+
CreateWorkspaceImageCommandOutput,
50+
WorkSpacesClientResolvedConfig
51+
> {
52+
// Start section: command_properties
53+
// End section: command_properties
54+
55+
constructor(readonly input: CreateWorkspaceImageCommandInput) {
56+
// Start section: command_constructor
57+
super();
58+
// End section: command_constructor
59+
}
60+
61+
/**
62+
* @internal
63+
*/
64+
resolveMiddleware(
65+
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
66+
configuration: WorkSpacesClientResolvedConfig,
67+
options?: __HttpHandlerOptions
68+
): Handler<CreateWorkspaceImageCommandInput, CreateWorkspaceImageCommandOutput> {
69+
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));
70+
71+
const stack = clientStack.concat(this.middlewareStack);
72+
73+
const { logger } = configuration;
74+
const clientName = "WorkSpacesClient";
75+
const commandName = "CreateWorkspaceImageCommand";
76+
const handlerExecutionContext: HandlerExecutionContext = {
77+
logger,
78+
clientName,
79+
commandName,
80+
inputFilterSensitiveLog: CreateWorkspaceImageRequestFilterSensitiveLog,
81+
outputFilterSensitiveLog: CreateWorkspaceImageResultFilterSensitiveLog,
82+
};
83+
const { requestHandler } = configuration;
84+
return stack.resolve(
85+
(request: FinalizeHandlerArguments<any>) =>
86+
requestHandler.handle(request.request as __HttpRequest, options || {}),
87+
handlerExecutionContext
88+
);
89+
}
90+
91+
private serialize(input: CreateWorkspaceImageCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
92+
return serializeAws_json1_1CreateWorkspaceImageCommand(input, context);
93+
}
94+
95+
private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<CreateWorkspaceImageCommandOutput> {
96+
return deserializeAws_json1_1CreateWorkspaceImageCommand(output, context);
97+
}
98+
99+
// Start section: command_body_extra
100+
// End section: command_body_extra
101+
}

clients/client-workspaces/src/commands/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ export * from "./CreateIpGroupCommand";
99
export * from "./CreateTagsCommand";
1010
export * from "./CreateUpdatedWorkspaceImageCommand";
1111
export * from "./CreateWorkspaceBundleCommand";
12+
export * from "./CreateWorkspaceImageCommand";
1213
export * from "./CreateWorkspacesCommand";
1314
export * from "./DeleteClientBrandingCommand";
1415
export * from "./DeleteConnectClientAddInCommand";

0 commit comments

Comments
 (0)