Skip to content

Commit

Permalink
feat: add client-ebs (#643)
Browse files Browse the repository at this point in the history
  • Loading branch information
trivikr committed Jan 6, 2020
1 parent 9600c99 commit 7b0957d
Show file tree
Hide file tree
Showing 19 changed files with 1,991 additions and 0 deletions.
14 changes: 14 additions & 0 deletions clients/client-ebs/.gitignore
@@ -0,0 +1,14 @@
/node_modules/
/build/
/coverage/
/docs/
/types/
/dist/
*.tsbuildinfo
*.tgz
*.log
package-lock.json

*.d.ts
*.js
*.js.map
4 changes: 4 additions & 0 deletions clients/client-ebs/.npmignore
@@ -0,0 +1,4 @@
/coverage/
/docs/
tsconfig.test.json
*.tsbuildinfo
152 changes: 152 additions & 0 deletions clients/client-ebs/EBS.ts
@@ -0,0 +1,152 @@
import { EBSClient } from "./EBSClient";
import {
GetSnapshotBlockCommand,
GetSnapshotBlockCommandInput,
GetSnapshotBlockCommandOutput
} from "./commands/GetSnapshotBlockCommand";
import {
ListChangedBlocksCommand,
ListChangedBlocksCommandInput,
ListChangedBlocksCommandOutput
} from "./commands/ListChangedBlocksCommand";
import {
ListSnapshotBlocksCommand,
ListSnapshotBlocksCommandInput,
ListSnapshotBlocksCommandOutput
} from "./commands/ListSnapshotBlocksCommand";
import { HttpHandlerOptions as __HttpHandlerOptions } from "@aws-sdk/types";

/**
*
* <p>You can use the Amazon Elastic Block Store (EBS) direct APIs to directly read the data on your EBS
* snapshots, and identify the difference between two snapshots. You can view the details
* of blocks in an EBS snapshot, compare the block difference between two snapshots, and
* directly access the data in a snapshot. If you’re an independent software vendor (ISV)
* who offers backup services for EBS, the EBS direct APIs makes it easier and more
* cost-effective to track incremental changes on your EBS volumes via EBS snapshots. This
* can be done without having to create new volumes from EBS snapshots, and then use EC2
* instances to compare the differences.</p>
*
*
* <p>This API reference provides detailed information about the actions, data types,
* parameters, and errors of the EBS direct APIs. For more information about the elements that
* make up the EBS direct APIs, and examples of how to use them effectively, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-accessing-snapshot.html">Accessing the Contents of an EBS Snapshot</a>. For more information about how
* to use the EBS direct APIs, see the <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-accessing-snapshots.html">EBS direct APIs User Guide</a>. To view the currently supported AWS Regions and
* endpoints for the EBS direct APIs, see <a href="https://docs.aws.amazon.com/general/latest/gr/rande.html#ebs_region">AWS
* Service Endpoints</a> in the <i>AWS General
* Reference</i>.</p>
*
*/
export class EBS extends EBSClient {
/**
*
* <p>Returns the block indexes and block tokens for blocks in an Amazon Elastic Block Store snapshot.</p>
*
*/
public listSnapshotBlocks(
args: ListSnapshotBlocksCommandInput,
options?: __HttpHandlerOptions
): Promise<ListSnapshotBlocksCommandOutput>;
public listSnapshotBlocks(
args: ListSnapshotBlocksCommandInput,
cb: (err: any, data?: ListSnapshotBlocksCommandOutput) => void
): void;
public listSnapshotBlocks(
args: ListSnapshotBlocksCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: ListSnapshotBlocksCommandOutput) => void
): void;
public listSnapshotBlocks(
args: ListSnapshotBlocksCommandInput,
optionsOrCb?:
| __HttpHandlerOptions
| ((err: any, data?: ListSnapshotBlocksCommandOutput) => void),
cb?: (err: any, data?: ListSnapshotBlocksCommandOutput) => void
): Promise<ListSnapshotBlocksCommandOutput> | void {
const command = new ListSnapshotBlocksCommand(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>Returns the data in a block in an Amazon Elastic Block Store snapshot.</p>
*
*/
public getSnapshotBlock(
args: GetSnapshotBlockCommandInput,
options?: __HttpHandlerOptions
): Promise<GetSnapshotBlockCommandOutput>;
public getSnapshotBlock(
args: GetSnapshotBlockCommandInput,
cb: (err: any, data?: GetSnapshotBlockCommandOutput) => void
): void;
public getSnapshotBlock(
args: GetSnapshotBlockCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: GetSnapshotBlockCommandOutput) => void
): void;
public getSnapshotBlock(
args: GetSnapshotBlockCommandInput,
optionsOrCb?:
| __HttpHandlerOptions
| ((err: any, data?: GetSnapshotBlockCommandOutput) => void),
cb?: (err: any, data?: GetSnapshotBlockCommandOutput) => void
): Promise<GetSnapshotBlockCommandOutput> | void {
const command = new GetSnapshotBlockCommand(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>Returns the block indexes and block tokens for blocks that are different between two
* Amazon Elastic Block Store snapshots of the same volume/snapshot lineage.</p>
*
*/
public listChangedBlocks(
args: ListChangedBlocksCommandInput,
options?: __HttpHandlerOptions
): Promise<ListChangedBlocksCommandOutput>;
public listChangedBlocks(
args: ListChangedBlocksCommandInput,
cb: (err: any, data?: ListChangedBlocksCommandOutput) => void
): void;
public listChangedBlocks(
args: ListChangedBlocksCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: ListChangedBlocksCommandOutput) => void
): void;
public listChangedBlocks(
args: ListChangedBlocksCommandInput,
optionsOrCb?:
| __HttpHandlerOptions
| ((err: any, data?: ListChangedBlocksCommandOutput) => void),
cb?: (err: any, data?: ListChangedBlocksCommandOutput) => void
): Promise<ListChangedBlocksCommandOutput> | void {
const command = new ListChangedBlocksCommand(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);
}
}
}
222 changes: 222 additions & 0 deletions clients/client-ebs/EBSClient.ts
@@ -0,0 +1,222 @@
import {
GetSnapshotBlockRequest,
GetSnapshotBlockResponse,
ListChangedBlocksRequest,
ListChangedBlocksResponse,
ListSnapshotBlocksRequest,
ListSnapshotBlocksResponse
} from "./models/index";
import { ClientDefaultValues as __ClientDefaultValues } from "./runtimeConfig";
import {
EndpointsInputConfig,
EndpointsResolvedConfig,
RegionInputConfig,
RegionResolvedConfig,
resolveEndpointsConfig,
resolveRegionConfig
} from "@aws-sdk/config-resolver";
import { getContentLengthPlugin } from "@aws-sdk/middleware-content-length";
import {
HostHeaderInputConfig,
HostHeaderResolvedConfig,
getHostHeaderPlugin,
resolveHostHeaderConfig
} from "@aws-sdk/middleware-host-header";
import {
RetryInputConfig,
RetryResolvedConfig,
getRetryPlugin,
resolveRetryConfig
} from "@aws-sdk/middleware-retry";
import {
AwsAuthInputConfig,
AwsAuthResolvedConfig,
getAwsAuthPlugin,
resolveAwsAuthConfig
} from "@aws-sdk/middleware-signing";
import {
UserAgentInputConfig,
UserAgentResolvedConfig,
getUserAgentPlugin,
resolveUserAgentConfig
} from "@aws-sdk/middleware-user-agent";
import { HttpHandler as __HttpHandler } from "@aws-sdk/protocol-http";
import {
Client as __Client,
SmithyConfiguration as __SmithyConfiguration,
SmithyResolvedConfiguration as __SmithyResolvedConfiguration
} from "@aws-sdk/smithy-client";
import {
RegionInfoProvider,
Credentials as __Credentials,
Decoder as __Decoder,
Encoder as __Encoder,
HashConstructor as __HashConstructor,
HttpHandlerOptions as __HttpHandlerOptions,
Provider as __Provider,
StreamCollector as __StreamCollector,
UrlParser as __UrlParser
} from "@aws-sdk/types";

export type ServiceInputTypes =
| GetSnapshotBlockRequest
| ListChangedBlocksRequest
| ListSnapshotBlocksRequest;

export type ServiceOutputTypes =
| GetSnapshotBlockResponse
| ListChangedBlocksResponse
| ListSnapshotBlocksResponse;

export interface ClientDefaults
extends Partial<__SmithyResolvedConfiguration<__HttpHandlerOptions>> {
/**
* The HTTP handler to use. Fetch in browser and Https in Nodejs.
*/
requestHandler?: __HttpHandler;

/**
* A constructor for a class implementing the @aws-sdk/types.Hash interface
* that computes the SHA-256 HMAC or checksum of a string or binary buffer.
*/
sha256?: __HashConstructor;

/**
* The function that will be used to convert strings into HTTP endpoints.
*/
urlParser?: __UrlParser;

/**
* A function that can calculate the length of a request body.
*/
bodyLengthChecker?: (body: any) => number | undefined;

/**
* A function that converts a stream into an array of bytes.
*/
streamCollector?: __StreamCollector;

/**
* The function that will be used to convert a base64-encoded string to a byte array
*/
base64Decoder?: __Decoder;

/**
* The function that will be used to convert binary data to a base64-encoded string
*/
base64Encoder?: __Encoder;

/**
* The function that will be used to convert a UTF8-encoded string to a byte array
*/
utf8Decoder?: __Decoder;

/**
* The function that will be used to convert binary data to a UTF-8 encoded string
*/
utf8Encoder?: __Encoder;

/**
* The string that will be used to populate default value in 'User-Agent' header
*/
defaultUserAgent?: string;

/**
* The runtime environment
*/
runtime?: string;

/**
* The service name with which to sign requests.
*/
signingName?: string;

/**
* Default credentials provider; Not available in browser runtime
*/
credentialDefaultProvider?: (input: any) => __Provider<__Credentials>;

/**
* Provider function that return promise of a region string
*/
regionDefaultProvider?: (input: any) => __Provider<string>;

/**
* Fetch related hostname, signing name or signing region with given region.
*/
regionInfoProvider?: RegionInfoProvider;
}

export type EBSClientConfig = Partial<
__SmithyConfiguration<__HttpHandlerOptions>
> &
ClientDefaults &
RegionInputConfig &
EndpointsInputConfig &
AwsAuthInputConfig &
RetryInputConfig &
UserAgentInputConfig &
HostHeaderInputConfig;

export type EBSClientResolvedConfig = __SmithyResolvedConfiguration<
__HttpHandlerOptions
> &
Required<ClientDefaults> &
RegionResolvedConfig &
EndpointsResolvedConfig &
AwsAuthResolvedConfig &
RetryResolvedConfig &
UserAgentResolvedConfig &
HostHeaderResolvedConfig;

/**
*
* <p>You can use the Amazon Elastic Block Store (EBS) direct APIs to directly read the data on your EBS
* snapshots, and identify the difference between two snapshots. You can view the details
* of blocks in an EBS snapshot, compare the block difference between two snapshots, and
* directly access the data in a snapshot. If you’re an independent software vendor (ISV)
* who offers backup services for EBS, the EBS direct APIs makes it easier and more
* cost-effective to track incremental changes on your EBS volumes via EBS snapshots. This
* can be done without having to create new volumes from EBS snapshots, and then use EC2
* instances to compare the differences.</p>
*
*
* <p>This API reference provides detailed information about the actions, data types,
* parameters, and errors of the EBS direct APIs. For more information about the elements that
* make up the EBS direct APIs, and examples of how to use them effectively, see <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-accessing-snapshot.html">Accessing the Contents of an EBS Snapshot</a>. For more information about how
* to use the EBS direct APIs, see the <a href="https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ebs-accessing-snapshots.html">EBS direct APIs User Guide</a>. To view the currently supported AWS Regions and
* endpoints for the EBS direct APIs, see <a href="https://docs.aws.amazon.com/general/latest/gr/rande.html#ebs_region">AWS
* Service Endpoints</a> in the <i>AWS General
* Reference</i>.</p>
*
*/
export class EBSClient extends __Client<
__HttpHandlerOptions,
ServiceInputTypes,
ServiceOutputTypes,
EBSClientResolvedConfig
> {
readonly config: EBSClientResolvedConfig;

constructor(configuration: EBSClientConfig) {
let _config_0 = {
...__ClientDefaultValues,
...configuration
};
let _config_1 = resolveRegionConfig(_config_0);
let _config_2 = resolveEndpointsConfig(_config_1);
let _config_3 = resolveAwsAuthConfig(_config_2);
let _config_4 = resolveRetryConfig(_config_3);
let _config_5 = resolveUserAgentConfig(_config_4);
let _config_6 = resolveHostHeaderConfig(_config_5);
super(_config_6);
this.config = _config_6;
this.middlewareStack.use(getAwsAuthPlugin(this.config));
this.middlewareStack.use(getRetryPlugin(this.config));
this.middlewareStack.use(getUserAgentPlugin(this.config));
this.middlewareStack.use(getContentLengthPlugin(this.config));
this.middlewareStack.use(getHostHeaderPlugin(this.config));
}

destroy(): void {}
}

0 comments on commit 7b0957d

Please sign in to comment.