Back to Aws Sdk Js V3

@aws-sdk/client-keyspaces

clients/client-keyspaces/README.md

3.1043.015.5 KB
Original Source
<!-- generated file, do not edit directly -->

@aws-sdk/client-keyspaces

Description

AWS SDK for JavaScript Keyspaces Client for Node.js, Browser and React Native.

<p>Amazon Keyspaces (for Apache Cassandra) is a scalable, highly available, and managed Apache Cassandra-compatible database service. Amazon Keyspaces makes it easy to migrate, run, and scale Cassandra workloads in the Amazon Web Services Cloud. With just a few clicks on the Amazon Web Services Management Console or a few lines of code, you can create keyspaces and tables in Amazon Keyspaces, without deploying any infrastructure or installing software. </p> <p>In addition to supporting Cassandra Query Language (CQL) requests via open-source Cassandra drivers, Amazon Keyspaces supports data definition language (DDL) operations to manage keyspaces and tables using the Amazon Web Services SDK and CLI, as well as infrastructure as code (IaC) services and tools such as CloudFormation and Terraform. This API reference describes the supported DDL operations in detail.</p> <p>For the list of all supported CQL APIs, see <a href="https://docs.aws.amazon.com/keyspaces/latest/devguide/cassandra-apis.html">Supported Cassandra APIs, operations, and data types in Amazon Keyspaces</a> in the <i>Amazon Keyspaces Developer Guide</i>.</p> <p>To learn how Amazon Keyspaces API actions are recorded with CloudTrail, see <a href="https://docs.aws.amazon.com/keyspaces/latest/devguide/logging-using-cloudtrail.html#service-name-info-in-cloudtrail">Amazon Keyspaces information in CloudTrail</a> in the <i>Amazon Keyspaces Developer Guide</i>.</p> <p>For more information about Amazon Web Services APIs, for example how to implement retry logic or how to sign Amazon Web Services API requests, see <a href="https://docs.aws.amazon.com/general/latest/gr/aws-apis.html">Amazon Web Services APIs</a> in the <i>General Reference</i>.</p>

Installing

To install this package, use the CLI of your favorite package manager:

  • npm install @aws-sdk/client-keyspaces
  • yarn add @aws-sdk/client-keyspaces
  • pnpm add @aws-sdk/client-keyspaces

Getting Started

Import

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

js
// ES5 example
const { KeyspacesClient, ListKeyspacesCommand } = require("@aws-sdk/client-keyspaces");
ts
// ES6+ example
import { KeyspacesClient, ListKeyspacesCommand } from "@aws-sdk/client-keyspaces";

Usage

To send a request:

  • Instantiate a client with configuration (e.g. credentials, region).
  • Instantiate a command with input parameters.
  • Call the send operation on the client, providing the command object as input.
js
const client = new KeyspacesClient({ region: "REGION" });

const params = { /** input parameters */ };
const command = new ListKeyspacesCommand(params);

Async/await

We recommend using the await operator to wait for the promise returned by send operation as follows:

js
// async/await.
try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  // error handling.
} finally {
  // finally.
}

Promises

You can also use Promise chaining.

js
client
  .send(command)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  })
  .finally(() => {
    // finally.
  });

Aggregated client

The aggregated client class is exported from the same package, but without the "Client" suffix.

Keyspaces extends KeyspacesClient and additionally supports all operations, waiters, and paginators as methods. This style may be familiar to you from the AWS SDK for JavaScript v2.

If you are bundling the AWS SDK, we recommend using only the bare-bones client (KeyspacesClient). More details are in the blog post on modular packages in AWS SDK for JavaScript.

ts
import { Keyspaces } from "@aws-sdk/client-keyspaces";

const client = new Keyspaces({ region: "REGION" });

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

// Promises.
client
  .listKeyspaces(params)
  .then((data) => {
    // process data.
  })
  .catch((error) => {
    // error handling.
  });

// callbacks (not recommended).
client.listKeyspaces(params, (err, data) => {
  // process err and data.
});

Troubleshooting

When the service returns an exception, the error will include the exception information, as well as response metadata (e.g. request id).

js
try {
  const data = await client.send(command);
  // process data.
} catch (error) {
  const { requestId, cfId, extendedRequestId } = error.$metadata;
  console.log({ requestId, cfId, extendedRequestId });
  /**
   * The keys within exceptions are also parsed.
   * You can access them by specifying exception names:
   * if (error.name === 'SomeServiceException') {
   *     const value = error.specialKeyInException;
   * }
   */
}

See also docs/ERROR_HANDLING.

Getting Help

Please use these community resources for getting help. We use GitHub issues for tracking bugs and feature requests, but have limited bandwidth to address them.

To test your universal JavaScript code in Node.js, browser and react-native environments, visit our code samples repo.

Contributing

This client code is generated automatically. Any modifications will be overwritten the next time the @aws-sdk/client-keyspaces package is updated. To contribute to client you can check our generate clients scripts.

License

This SDK is distributed under the Apache License, Version 2.0, see LICENSE for more information.

Client Commands (Operations List)

<details> <summary> CreateKeyspace </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateTable </summary>

Command API Reference / Input / Output

</details> <details> <summary> CreateType </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteKeyspace </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteTable </summary>

Command API Reference / Input / Output

</details> <details> <summary> DeleteType </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetKeyspace </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetTable </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetTableAutoScalingSettings </summary>

Command API Reference / Input / Output

</details> <details> <summary> GetType </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListKeyspaces </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListTables </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListTagsForResource </summary>

Command API Reference / Input / Output

</details> <details> <summary> ListTypes </summary>

Command API Reference / Input / Output

</details> <details> <summary> RestoreTable </summary>

Command API Reference / Input / Output

</details> <details> <summary> TagResource </summary>

Command API Reference / Input / Output

</details> <details> <summary> UntagResource </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateKeyspace </summary>

Command API Reference / Input / Output

</details> <details> <summary> UpdateTable </summary>

Command API Reference / Input / Output

</details>