Skip to content

Commit

Permalink
feat(client-workspaces): Added CreateWorkspaceImage API to create a n…
Browse files Browse the repository at this point in the history
…ew WorkSpace image from an existing WorkSpace.
  • Loading branch information
awstools committed Jul 27, 2022
1 parent 352b023 commit 6f03fb8
Show file tree
Hide file tree
Showing 7 changed files with 518 additions and 50 deletions.
37 changes: 37 additions & 0 deletions clients/client-workspaces/src/WorkSpaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ import {
CreateWorkspaceBundleCommandInput,
CreateWorkspaceBundleCommandOutput,
} from "./commands/CreateWorkspaceBundleCommand";
import {
CreateWorkspaceImageCommand,
CreateWorkspaceImageCommandInput,
CreateWorkspaceImageCommandOutput,
} from "./commands/CreateWorkspaceImageCommand";
import {
CreateWorkspacesCommand,
CreateWorkspacesCommandInput,
Expand Down Expand Up @@ -687,6 +692,38 @@ export class WorkSpaces extends WorkSpacesClient {
}
}

/**
* <p>Creates a new WorkSpace image from an existing WorkSpace.</p>
*/
public createWorkspaceImage(
args: CreateWorkspaceImageCommandInput,
options?: __HttpHandlerOptions
): Promise<CreateWorkspaceImageCommandOutput>;
public createWorkspaceImage(
args: CreateWorkspaceImageCommandInput,
cb: (err: any, data?: CreateWorkspaceImageCommandOutput) => void
): void;
public createWorkspaceImage(
args: CreateWorkspaceImageCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: CreateWorkspaceImageCommandOutput) => void
): void;
public createWorkspaceImage(
args: CreateWorkspaceImageCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: CreateWorkspaceImageCommandOutput) => void),
cb?: (err: any, data?: CreateWorkspaceImageCommandOutput) => void
): Promise<CreateWorkspaceImageCommandOutput> | void {
const command = new CreateWorkspaceImageCommand(args);
if (typeof optionsOrCb === "function") {
this.send(command, optionsOrCb);
} else if (typeof cb === "function") {
if (typeof optionsOrCb !== "object") throw new Error(`Expect http options but get ${typeof optionsOrCb}`);
this.send(command, optionsOrCb || {}, cb);
} else {
return this.send(command, optionsOrCb);
}
}

/**
* <p>Creates one or more WorkSpaces.</p>
* <p>This operation is asynchronous and returns before the WorkSpaces are created.</p>
Expand Down
6 changes: 6 additions & 0 deletions clients/client-workspaces/src/WorkSpacesClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ import {
CreateWorkspaceBundleCommandInput,
CreateWorkspaceBundleCommandOutput,
} from "./commands/CreateWorkspaceBundleCommand";
import {
CreateWorkspaceImageCommandInput,
CreateWorkspaceImageCommandOutput,
} from "./commands/CreateWorkspaceImageCommand";
import { CreateWorkspacesCommandInput, CreateWorkspacesCommandOutput } from "./commands/CreateWorkspacesCommand";
import {
DeleteClientBrandingCommandInput,
Expand Down Expand Up @@ -250,6 +254,7 @@ export type ServiceInputTypes =
| CreateTagsCommandInput
| CreateUpdatedWorkspaceImageCommandInput
| CreateWorkspaceBundleCommandInput
| CreateWorkspaceImageCommandInput
| CreateWorkspacesCommandInput
| DeleteClientBrandingCommandInput
| DeleteConnectClientAddInCommandInput
Expand Down Expand Up @@ -313,6 +318,7 @@ export type ServiceOutputTypes =
| CreateTagsCommandOutput
| CreateUpdatedWorkspaceImageCommandOutput
| CreateWorkspaceBundleCommandOutput
| CreateWorkspaceImageCommandOutput
| CreateWorkspacesCommandOutput
| DeleteClientBrandingCommandOutput
| DeleteConnectClientAddInCommandOutput
Expand Down
101 changes: 101 additions & 0 deletions clients/client-workspaces/src/commands/CreateWorkspaceImageCommand.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
// smithy-typescript generated code
import { getSerdePlugin } from "@aws-sdk/middleware-serde";
import { HttpRequest as __HttpRequest, HttpResponse as __HttpResponse } from "@aws-sdk/protocol-http";
import { Command as $Command } from "@aws-sdk/smithy-client";
import {
FinalizeHandlerArguments,
Handler,
HandlerExecutionContext,
HttpHandlerOptions as __HttpHandlerOptions,
MetadataBearer as __MetadataBearer,
MiddlewareStack,
SerdeContext as __SerdeContext,
} from "@aws-sdk/types";

import {
CreateWorkspaceImageRequest,
CreateWorkspaceImageRequestFilterSensitiveLog,
CreateWorkspaceImageResult,
CreateWorkspaceImageResultFilterSensitiveLog,
} from "../models/models_0";
import {
deserializeAws_json1_1CreateWorkspaceImageCommand,
serializeAws_json1_1CreateWorkspaceImageCommand,
} from "../protocols/Aws_json1_1";
import { ServiceInputTypes, ServiceOutputTypes, WorkSpacesClientResolvedConfig } from "../WorkSpacesClient";

export interface CreateWorkspaceImageCommandInput extends CreateWorkspaceImageRequest {}
export interface CreateWorkspaceImageCommandOutput extends CreateWorkspaceImageResult, __MetadataBearer {}

/**
* <p>Creates a new WorkSpace image from an existing WorkSpace.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { WorkSpacesClient, CreateWorkspaceImageCommand } from "@aws-sdk/client-workspaces"; // ES Modules import
* // const { WorkSpacesClient, CreateWorkspaceImageCommand } = require("@aws-sdk/client-workspaces"); // CommonJS import
* const client = new WorkSpacesClient(config);
* const command = new CreateWorkspaceImageCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link CreateWorkspaceImageCommandInput} for command's `input` shape.
* @see {@link CreateWorkspaceImageCommandOutput} for command's `response` shape.
* @see {@link WorkSpacesClientResolvedConfig | config} for WorkSpacesClient's `config` shape.
*
*/
export class CreateWorkspaceImageCommand extends $Command<
CreateWorkspaceImageCommandInput,
CreateWorkspaceImageCommandOutput,
WorkSpacesClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

constructor(readonly input: CreateWorkspaceImageCommandInput) {
// Start section: command_constructor
super();
// End section: command_constructor
}

/**
* @internal
*/
resolveMiddleware(
clientStack: MiddlewareStack<ServiceInputTypes, ServiceOutputTypes>,
configuration: WorkSpacesClientResolvedConfig,
options?: __HttpHandlerOptions
): Handler<CreateWorkspaceImageCommandInput, CreateWorkspaceImageCommandOutput> {
this.middlewareStack.use(getSerdePlugin(configuration, this.serialize, this.deserialize));

const stack = clientStack.concat(this.middlewareStack);

const { logger } = configuration;
const clientName = "WorkSpacesClient";
const commandName = "CreateWorkspaceImageCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: CreateWorkspaceImageRequestFilterSensitiveLog,
outputFilterSensitiveLog: CreateWorkspaceImageResultFilterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

private serialize(input: CreateWorkspaceImageCommandInput, context: __SerdeContext): Promise<__HttpRequest> {
return serializeAws_json1_1CreateWorkspaceImageCommand(input, context);
}

private deserialize(output: __HttpResponse, context: __SerdeContext): Promise<CreateWorkspaceImageCommandOutput> {
return deserializeAws_json1_1CreateWorkspaceImageCommand(output, context);
}

// Start section: command_body_extra
// End section: command_body_extra
}
1 change: 1 addition & 0 deletions clients/client-workspaces/src/commands/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export * from "./CreateIpGroupCommand";
export * from "./CreateTagsCommand";
export * from "./CreateUpdatedWorkspaceImageCommand";
export * from "./CreateWorkspaceBundleCommand";
export * from "./CreateWorkspaceImageCommand";
export * from "./CreateWorkspacesCommand";
export * from "./DeleteClientBrandingCommand";
export * from "./DeleteConnectClientAddInCommand";
Expand Down

0 comments on commit 6f03fb8

Please sign in to comment.