Skip to content

Commit

Permalink
feat(client-managedblockchain): Adding new Accessor APIs for Amazon M…
Browse files Browse the repository at this point in the history
…anaged Blockchain
  • Loading branch information
awstools committed Oct 19, 2022
1 parent 4ceb486 commit db0e989
Show file tree
Hide file tree
Showing 42 changed files with 3,628 additions and 611 deletions.
16 changes: 8 additions & 8 deletions clients/client-managedblockchain/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ AWS SDK for JavaScript ManagedBlockchain Client for Node.js, Browser and React N

<p></p>
<p>Amazon Managed Blockchain is a fully managed service for creating and managing blockchain networks using open-source frameworks. Blockchain allows you to build applications where multiple parties can securely and transparently run transactions and share data without the need for a trusted, central authority.</p>
<p>Managed Blockchain supports the Hyperledger Fabric and Ethereum open-source frameworks. Because of fundamental differences between the frameworks, some API actions or data types may only apply in the context of one framework and not the other. For example, actions related to Hyperledger Fabric network members such as <code>CreateMember</code> and <code>DeleteMember</code> do not apply to Ethereum.</p>
<p>Managed Blockchain supports the Hyperledger Fabric and Ethereum open-source frameworks. Because of fundamental differences between the frameworks, some API actions or data types may only apply in the context of one framework and not the other. For example, actions related to Hyperledger Fabric network members such as <code>CreateMember</code> and <code>DeleteMember</code> don't apply to Ethereum.</p>
<p>The description for each action indicates the framework or frameworks to which it applies. Data types and properties that apply only in the context of a particular framework are similarly indicated.</p>

## Installing
Expand All @@ -29,16 +29,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 `ManagedBlockchainClient` and
the commands you need, for example `CreateMemberCommand`:
the commands you need, for example `CreateAccessorCommand`:

```js
// ES5 example
const { ManagedBlockchainClient, CreateMemberCommand } = require("@aws-sdk/client-managedblockchain");
const { ManagedBlockchainClient, CreateAccessorCommand } = require("@aws-sdk/client-managedblockchain");
```

```ts
// ES6+ example
import { ManagedBlockchainClient, CreateMemberCommand } from "@aws-sdk/client-managedblockchain";
import { ManagedBlockchainClient, CreateAccessorCommand } from "@aws-sdk/client-managedblockchain";
```

### Usage
Expand All @@ -57,7 +57,7 @@ const client = new ManagedBlockchainClient({ region: "REGION" });
const params = {
/** input parameters */
};
const command = new CreateMemberCommand(params);
const command = new CreateAccessorCommand(params);
```

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

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

// Promises.
client
.createMember(params)
.createAccessor(params)
.then((data) => {
// process data.
})
Expand All @@ -153,7 +153,7 @@ client
});

// callbacks.
client.createMember(params, (err, data) => {
client.createAccessor(params, (err, data) => {
// process err and data.
});
```
Expand Down
1 change: 1 addition & 0 deletions clients/client-managedblockchain/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
"@aws-sdk/hash-node": "*",
"@aws-sdk/invalid-dependency": "*",
"@aws-sdk/middleware-content-length": "*",
"@aws-sdk/middleware-endpoint": "*",
"@aws-sdk/middleware-host-header": "*",
"@aws-sdk/middleware-logger": "*",
"@aws-sdk/middleware-recursion-detection": "*",
Expand Down
181 changes: 174 additions & 7 deletions clients/client-managedblockchain/src/ManagedBlockchain.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 {
CreateAccessorCommand,
CreateAccessorCommandInput,
CreateAccessorCommandOutput,
} from "./commands/CreateAccessorCommand";
import {
CreateMemberCommand,
CreateMemberCommandInput,
Expand All @@ -17,16 +22,27 @@ import {
CreateProposalCommandInput,
CreateProposalCommandOutput,
} from "./commands/CreateProposalCommand";
import {
DeleteAccessorCommand,
DeleteAccessorCommandInput,
DeleteAccessorCommandOutput,
} from "./commands/DeleteAccessorCommand";
import {
DeleteMemberCommand,
DeleteMemberCommandInput,
DeleteMemberCommandOutput,
} from "./commands/DeleteMemberCommand";
import { DeleteNodeCommand, DeleteNodeCommandInput, DeleteNodeCommandOutput } from "./commands/DeleteNodeCommand";
import { GetAccessorCommand, GetAccessorCommandInput, GetAccessorCommandOutput } from "./commands/GetAccessorCommand";
import { GetMemberCommand, GetMemberCommandInput, GetMemberCommandOutput } from "./commands/GetMemberCommand";
import { GetNetworkCommand, GetNetworkCommandInput, GetNetworkCommandOutput } from "./commands/GetNetworkCommand";
import { GetNodeCommand, GetNodeCommandInput, GetNodeCommandOutput } from "./commands/GetNodeCommand";
import { GetProposalCommand, GetProposalCommandInput, GetProposalCommandOutput } from "./commands/GetProposalCommand";
import {
ListAccessorsCommand,
ListAccessorsCommandInput,
ListAccessorsCommandOutput,
} from "./commands/ListAccessorsCommand";
import {
ListInvitationsCommand,
ListInvitationsCommandInput,
Expand Down Expand Up @@ -81,10 +97,48 @@ import { ManagedBlockchainClient } from "./ManagedBlockchainClient";
/**
* <p></p>
* <p>Amazon Managed Blockchain is a fully managed service for creating and managing blockchain networks using open-source frameworks. Blockchain allows you to build applications where multiple parties can securely and transparently run transactions and share data without the need for a trusted, central authority.</p>
* <p>Managed Blockchain supports the Hyperledger Fabric and Ethereum open-source frameworks. Because of fundamental differences between the frameworks, some API actions or data types may only apply in the context of one framework and not the other. For example, actions related to Hyperledger Fabric network members such as <code>CreateMember</code> and <code>DeleteMember</code> do not apply to Ethereum.</p>
* <p>Managed Blockchain supports the Hyperledger Fabric and Ethereum open-source frameworks. Because of fundamental differences between the frameworks, some API actions or data types may only apply in the context of one framework and not the other. For example, actions related to Hyperledger Fabric network members such as <code>CreateMember</code> and <code>DeleteMember</code> don't apply to Ethereum.</p>
* <p>The description for each action indicates the framework or frameworks to which it applies. Data types and properties that apply only in the context of a particular framework are similarly indicated.</p>
*/
export class ManagedBlockchain extends ManagedBlockchainClient {
/**
* <important>
* <p>The token based access feature is in preview release for Ethereum on Amazon Managed Blockchain and is
* subject to change. We recommend that you use this feature only with
* test scenarios, and not in production environments.</p>
* </important>
* <p>Creates a new accessor for use with Managed Blockchain Ethereum nodes. An accessor object is a container that has the information
* required for token based access to your Ethereum nodes.</p>
*/
public createAccessor(
args: CreateAccessorCommandInput,
options?: __HttpHandlerOptions
): Promise<CreateAccessorCommandOutput>;
public createAccessor(
args: CreateAccessorCommandInput,
cb: (err: any, data?: CreateAccessorCommandOutput) => void
): void;
public createAccessor(
args: CreateAccessorCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: CreateAccessorCommandOutput) => void
): void;
public createAccessor(
args: CreateAccessorCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: CreateAccessorCommandOutput) => void),
cb?: (err: any, data?: CreateAccessorCommandOutput) => void
): Promise<CreateAccessorCommandOutput> | void {
const command = new CreateAccessorCommand(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 a member within a Managed Blockchain network.</p>
* <p>Applies only to Hyperledger Fabric.</p>
Expand Down Expand Up @@ -209,7 +263,50 @@ export class ManagedBlockchain extends ManagedBlockchainClient {
}

/**
* <p>Deletes a member. Deleting a member removes the member and all associated resources from the network. <code>DeleteMember</code> can only be called for a specified <code>MemberId</code> if the principal performing the action is associated with the AWS account that owns the member. In all other cases, the <code>DeleteMember</code> action is carried out as the result of an approved proposal to remove a member. If <code>MemberId</code> is the last member in a network specified by the last AWS account, the network is deleted also.</p>
* <important>
* <p>The token based access feature is in preview release for Ethereum on Amazon Managed Blockchain and is
* subject to change. We recommend that you use this feature only with
* test scenarios, and not in production environments.</p>
* </important>
* <p>Deletes an accessor that your Amazon Web Services account owns. An accessor object is a container that has the
* information required for token based access to your Ethereum nodes including, the
* <code>BILLING_TOKEN</code>. After an accessor is deleted, the status of the accessor changes
* from <code>AVAILABLE</code> to <code>PENDING_DELETION</code>. An accessor in the
* <code>PENDING_DELETION</code> state can’t be used for new WebSocket requests or
* HTTP requests. However, WebSocket connections that are initiated while the accessor was in the
* <code>AVAILABLE</code> state remain open until they expire (up to 2 hours).</p>
*/
public deleteAccessor(
args: DeleteAccessorCommandInput,
options?: __HttpHandlerOptions
): Promise<DeleteAccessorCommandOutput>;
public deleteAccessor(
args: DeleteAccessorCommandInput,
cb: (err: any, data?: DeleteAccessorCommandOutput) => void
): void;
public deleteAccessor(
args: DeleteAccessorCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: DeleteAccessorCommandOutput) => void
): void;
public deleteAccessor(
args: DeleteAccessorCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: DeleteAccessorCommandOutput) => void),
cb?: (err: any, data?: DeleteAccessorCommandOutput) => void
): Promise<DeleteAccessorCommandOutput> | void {
const command = new DeleteAccessorCommand(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>Deletes a member. Deleting a member removes the member and all associated resources from the network. <code>DeleteMember</code> can only be called for a specified <code>MemberId</code> if the principal performing the action is associated with the Amazon Web Services account that owns the member. In all other cases, the <code>DeleteMember</code> action is carried out as the result of an approved proposal to remove a member. If <code>MemberId</code> is the last member in a network specified by the last Amazon Web Services account, the network is deleted also.</p>
* <p>Applies only to Hyperledger Fabric.</p>
*/
public deleteMember(
Expand Down Expand Up @@ -239,7 +336,7 @@ export class ManagedBlockchain extends ManagedBlockchainClient {
}

/**
* <p>Deletes a node that your AWS account owns. All data on the node is lost and cannot be recovered.</p>
* <p>Deletes a node that your Amazon Web Services account owns. All data on the node is lost and cannot be recovered.</p>
* <p>Applies to Hyperledger Fabric and Ethereum.</p>
*/
public deleteNode(args: DeleteNodeCommandInput, options?: __HttpHandlerOptions): Promise<DeleteNodeCommandOutput>;
Expand All @@ -265,6 +362,38 @@ export class ManagedBlockchain extends ManagedBlockchainClient {
}
}

/**
* <important>
* <p>The token based access feature is in preview release for Ethereum on Amazon Managed Blockchain and is
* subject to change. We recommend that you use this feature only with
* test scenarios, and not in production environments.</p>
* </important>
* <p>Returns detailed information about an accessor. An accessor object is a container that has the
* information required for token based access to your Ethereum nodes.</p>
*/
public getAccessor(args: GetAccessorCommandInput, options?: __HttpHandlerOptions): Promise<GetAccessorCommandOutput>;
public getAccessor(args: GetAccessorCommandInput, cb: (err: any, data?: GetAccessorCommandOutput) => void): void;
public getAccessor(
args: GetAccessorCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: GetAccessorCommandOutput) => void
): void;
public getAccessor(
args: GetAccessorCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: GetAccessorCommandOutput) => void),
cb?: (err: any, data?: GetAccessorCommandOutput) => void
): Promise<GetAccessorCommandOutput> | void {
const command = new GetAccessorCommand(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 detailed information about a member.</p>
* <p>Applies only to Hyperledger Fabric.</p>
Expand Down Expand Up @@ -374,7 +503,45 @@ export class ManagedBlockchain extends ManagedBlockchainClient {
}

/**
* <p>Returns a list of all invitations for the current AWS account.</p>
* <important>
* <p>The token based access feature is in preview release for Ethereum on Amazon Managed Blockchain and is
* subject to change. We recommend that you use this feature only with
* test scenarios, and not in production environments.</p>
* </important>
* <p>Returns a list of the accessors and their properties. Accessor objects are containers that have the
* information required for token based access to your Ethereum nodes.</p>
*/
public listAccessors(
args: ListAccessorsCommandInput,
options?: __HttpHandlerOptions
): Promise<ListAccessorsCommandOutput>;
public listAccessors(
args: ListAccessorsCommandInput,
cb: (err: any, data?: ListAccessorsCommandOutput) => void
): void;
public listAccessors(
args: ListAccessorsCommandInput,
options: __HttpHandlerOptions,
cb: (err: any, data?: ListAccessorsCommandOutput) => void
): void;
public listAccessors(
args: ListAccessorsCommandInput,
optionsOrCb?: __HttpHandlerOptions | ((err: any, data?: ListAccessorsCommandOutput) => void),
cb?: (err: any, data?: ListAccessorsCommandOutput) => void
): Promise<ListAccessorsCommandOutput> | void {
const command = new ListAccessorsCommand(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 a list of all invitations for the current Amazon Web Services account.</p>
* <p>Applies only to Hyperledger Fabric.</p>
*/
public listInvitations(
Expand Down Expand Up @@ -434,7 +601,7 @@ export class ManagedBlockchain extends ManagedBlockchainClient {
}

/**
* <p>Returns information about the networks in which the current AWS account participates.</p>
* <p>Returns information about the networks in which the current Amazon Web Services account participates.</p>
* <p>Applies to Hyperledger Fabric and Ethereum.</p>
*/
public listNetworks(
Expand Down Expand Up @@ -590,7 +757,7 @@ export class ManagedBlockchain extends ManagedBlockchainClient {
}

/**
* <p>Rejects an invitation to join a network. This action can be called by a principal in an AWS account that has received an invitation to create a member and join a network.</p>
* <p>Rejects an invitation to join a network. This action can be called by a principal in an Amazon Web Services account that has received an invitation to create a member and join a network.</p>
* <p>Applies only to Hyperledger Fabric.</p>
*/
public rejectInvitation(
Expand Down Expand Up @@ -742,7 +909,7 @@ export class ManagedBlockchain extends ManagedBlockchainClient {
}

/**
* <p>Casts a vote for a specified <code>ProposalId</code> on behalf of a member. The member to vote as, specified by <code>VoterMemberId</code>, must be in the same AWS account as the principal that calls the action.</p>
* <p>Casts a vote for a specified <code>ProposalId</code> on behalf of a member. The member to vote as, specified by <code>VoterMemberId</code>, must be in the same Amazon Web Services account as the principal that calls the action.</p>
* <p>Applies only to Hyperledger Fabric.</p>
*/
public voteOnProposal(
Expand Down
Loading

0 comments on commit db0e989

Please sign in to comment.