Skip to content

Commit

Permalink
feat(client-sagemaker-edge): Amazon SageMaker Edge Manager provides l…
Browse files Browse the repository at this point in the history
…ightweight model deployment feature to deploy machine learning models on requested devices.
  • Loading branch information
awstools committed Jul 19, 2022
1 parent 6481e59 commit 316a691
Show file tree
Hide file tree
Showing 8 changed files with 968 additions and 34 deletions.
14 changes: 7 additions & 7 deletions clients/client-sagemaker-edge/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,16 +26,16 @@ using your favorite package manager:

The AWS SDK is modulized by clients and commands.
To send a request, you only need to import the `SagemakerEdgeClient` and
the commands you need, for example `GetDeviceRegistrationCommand`:
the commands you need, for example `GetDeploymentsCommand`:

```js
// ES5 example
const { SagemakerEdgeClient, GetDeviceRegistrationCommand } = require("@aws-sdk/client-sagemaker-edge");
const { SagemakerEdgeClient, GetDeploymentsCommand } = require("@aws-sdk/client-sagemaker-edge");
```

```ts
// ES6+ example
import { SagemakerEdgeClient, GetDeviceRegistrationCommand } from "@aws-sdk/client-sagemaker-edge";
import { SagemakerEdgeClient, GetDeploymentsCommand } from "@aws-sdk/client-sagemaker-edge";
```

### Usage
Expand All @@ -54,7 +54,7 @@ const client = new SagemakerEdgeClient({ region: "REGION" });
const params = {
/** input parameters */
};
const command = new GetDeviceRegistrationCommand(params);
const command = new GetDeploymentsCommand(params);
```

#### Async/await
Expand Down Expand Up @@ -133,15 +133,15 @@ const client = new AWS.SagemakerEdge({ region: "REGION" });

// async/await.
try {
const data = await client.getDeviceRegistration(params);
const data = await client.getDeployments(params);
// process data.
} catch (error) {
// error handling.
}

// Promises.
client
.getDeviceRegistration(params)
.getDeployments(params)
.then((data) => {
// process data.
})
Expand All @@ -150,7 +150,7 @@ client
});

// callbacks.
client.getDeviceRegistration(params, (err, data) => {
client.getDeployments(params, (err, data) => {
// process err and data.
});
```
Expand Down
37 changes: 37 additions & 0 deletions clients/client-sagemaker-edge/src/SagemakerEdge.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
// smithy-typescript generated code
import { HttpHandlerOptions as __HttpHandlerOptions } from "@aws-sdk/types";

import {
GetDeploymentsCommand,
GetDeploymentsCommandInput,
GetDeploymentsCommandOutput,
} from "./commands/GetDeploymentsCommand";
import {
GetDeviceRegistrationCommand,
GetDeviceRegistrationCommandInput,
Expand All @@ -17,6 +22,38 @@ import { SagemakerEdgeClient } from "./SagemakerEdgeClient";
* <p>SageMaker Edge Manager dataplane service for communicating with active agents.</p>
*/
export class SagemakerEdge extends SagemakerEdgeClient {
/**
* <p>Use to get the active deployments from a device.</p>
*/
public getDeployments(
args: GetDeploymentsCommandInput,
options?: __HttpHandlerOptions
): Promise<GetDeploymentsCommandOutput>;
public getDeployments(
args: GetDeploymentsCommandInput,
cb: (err: any, data?: GetDeploymentsCommandOutput) => void
): void;
public getDeployments(
args: GetDeploymentsCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: GetDeploymentsCommandOutput) => void
): void;
public getDeployments(
args: GetDeploymentsCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: GetDeploymentsCommandOutput) => void),
cb?: (err: any, data?: GetDeploymentsCommandOutput) => void
): Promise<GetDeploymentsCommandOutput> | void {
const command = new GetDeploymentsCommand(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>Use to check if a device is registered with SageMaker Edge Manager.</p>
*/
Expand Down
11 changes: 9 additions & 2 deletions clients/client-sagemaker-edge/src/SagemakerEdgeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,23 @@ import {
UserAgent as __UserAgent,
} from "@aws-sdk/types";

import { GetDeploymentsCommandInput, GetDeploymentsCommandOutput } from "./commands/GetDeploymentsCommand";
import {
GetDeviceRegistrationCommandInput,
GetDeviceRegistrationCommandOutput,
} from "./commands/GetDeviceRegistrationCommand";
import { SendHeartbeatCommandInput, SendHeartbeatCommandOutput } from "./commands/SendHeartbeatCommand";
import { getRuntimeConfig as __getRuntimeConfig } from "./runtimeConfig";

export type ServiceInputTypes = GetDeviceRegistrationCommandInput | SendHeartbeatCommandInput;
export type ServiceInputTypes =
| GetDeploymentsCommandInput
| GetDeviceRegistrationCommandInput
| SendHeartbeatCommandInput;

export type ServiceOutputTypes = GetDeviceRegistrationCommandOutput | SendHeartbeatCommandOutput;
export type ServiceOutputTypes =
| GetDeploymentsCommandOutput
| GetDeviceRegistrationCommandOutput
| SendHeartbeatCommandOutput;

export interface ClientDefaults extends Partial<__SmithyResolvedConfiguration<__HttpHandlerOptions>> {
/**
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// 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 { GetDeploymentsRequest, GetDeploymentsResult } from "../models/models_0";
import {
deserializeAws_restJson1GetDeploymentsCommand,
serializeAws_restJson1GetDeploymentsCommand,
} from "../protocols/Aws_restJson1";
import { SagemakerEdgeClientResolvedConfig, ServiceInputTypes, ServiceOutputTypes } from "../SagemakerEdgeClient";

export interface GetDeploymentsCommandInput extends GetDeploymentsRequest {}
export interface GetDeploymentsCommandOutput extends GetDeploymentsResult, __MetadataBearer {}

/**
* <p>Use to get the active deployments from a device.</p>
* @example
* Use a bare-bones client and the command you need to make an API call.
* ```javascript
* import { SagemakerEdgeClient, GetDeploymentsCommand } from "@aws-sdk/client-sagemaker-edge"; // ES Modules import
* // const { SagemakerEdgeClient, GetDeploymentsCommand } = require("@aws-sdk/client-sagemaker-edge"); // CommonJS import
* const client = new SagemakerEdgeClient(config);
* const command = new GetDeploymentsCommand(input);
* const response = await client.send(command);
* ```
*
* @see {@link GetDeploymentsCommandInput} for command's `input` shape.
* @see {@link GetDeploymentsCommandOutput} for command's `response` shape.
* @see {@link SagemakerEdgeClientResolvedConfig | config} for SagemakerEdgeClient's `config` shape.
*
*/
export class GetDeploymentsCommand extends $Command<
GetDeploymentsCommandInput,
GetDeploymentsCommandOutput,
SagemakerEdgeClientResolvedConfig
> {
// Start section: command_properties
// End section: command_properties

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

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

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

const { logger } = configuration;
const clientName = "SagemakerEdgeClient";
const commandName = "GetDeploymentsCommand";
const handlerExecutionContext: HandlerExecutionContext = {
logger,
clientName,
commandName,
inputFilterSensitiveLog: GetDeploymentsRequest.filterSensitiveLog,
outputFilterSensitiveLog: GetDeploymentsResult.filterSensitiveLog,
};
const { requestHandler } = configuration;
return stack.resolve(
(request: FinalizeHandlerArguments<any>) =>
requestHandler.handle(request.request as __HttpRequest, options || {}),
handlerExecutionContext
);
}

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

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

// Start section: command_body_extra
// End section: command_body_extra
}
1 change: 1 addition & 0 deletions clients/client-sagemaker-edge/src/commands/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// smithy-typescript generated code
export * from "./GetDeploymentsCommand";
export * from "./GetDeviceRegistrationCommand";
export * from "./SendHeartbeatCommand";
Loading

0 comments on commit 316a691

Please sign in to comment.