Unverified Commit 1501c174 authored by Doug's avatar Doug Committed by GitHub
Browse files

Moved QLDB code examples into qldb directory; added create-ledger code example (#485)



* Moved QLDB code examples into qldb directory; added create-ledger code example

* Removed some leftover qldb files

* Renamed QLDB helloword.rs as qldb-helloworld.rs

* Updated create-ledger code example based on feedback

* Added readme with descriptions of all three QLDB code examples; slightly modified the description of the ledger in the hello world code example

* Update QLDB readme

Small language tweak suggesting the high level driver

Co-authored-by: default avatarRussell Cohen <rcoh@amazon.com>
parent 05eace6b
Loading
Loading
Loading
Loading
+0 −20
Original line number Diff line number Diff line
[package]
name = "qldb-helloworld"
version = "0.1.0"
authors = ["Russell Cohen <rcoh@amazon.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
qldb = { package = "aws-sdk-qldb", path = "../../build/aws-sdk/qldb" }
### To use native TLS:
# dynamodb = { package = "aws-sdk-qldb", path = "../../build/aws-sdk/qldb", default-features = false, features = ["native-tls"] }

tokio = { version = "1", features = ["full"] }

# used only for static endpoint configuration:
http = "0.2.3"

# used only to enable basic logging:
env_logger = "0.8.2"
+0 −2
Original line number Diff line number Diff line
# Qldb List Ledgers World Example
This example show how to use the SDK to list existing ledgers.
+0 −22
Original line number Diff line number Diff line
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * SPDX-License-Identifier: Apache-2.0.
 */

#[tokio::main]
async fn main() -> Result<(), qldb::Error> {
    let client = qldb::Client::from_env();
    let result = client.list_ledgers().send().await?;

    if let Some(ledgers) = result.ledgers {
        for ledger in ledgers {
            println!("* {:?}", ledger);
        }

        if result.next_token.is_some() {
            todo!("pagination is not yet demonstrated")
        }
    }

    Ok(())
}
+9 −4
Original line number Diff line number Diff line
[package]
name = "qldbsession-helloworld"
name = "qldb-code-examples"
version = "0.1.0"
authors = ["Russell Cohen <rcoh@amazon.com>"]
authors = ["Russell Cohen <rcoh@amazon.com>", "Doug Schwartz <dougsch@amazon.com>"]
edition = "2018"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
qldb = { package = "aws-sdk-qldb", path = "../../build/aws-sdk/qldb" }
qldbsession = { package = "aws-sdk-qldbsession", path = "../../build/aws-sdk/qldbsession" }
### To use native TLS:
# qldbsession = { package = "aws-sdk-qldbsession", path = "../../build/aws-sdk/qldbsession", default-features = false, features = ["native-tls"] }
aws-types = { path = "../../build/aws-sdk/aws-types" }

tokio = { version = "1", features = ["full"] }

# For command-line arguments
structopt = { version = "0.3", default-features = false }

tracing-subscriber = { version = "0.2.16", features = ["fmt"] }

# used only for static endpoint configuration:
http = "0.2.3"

+54 −0
Original line number Diff line number Diff line
# AWS SDK for Rust code examples for Amazon QLDB

Amazon Quantum Ledger Database (Amazon QLDB) is a fully managed ledger database that provides a transparent, immutable, and cryptographically verifiable transaction log owned by a central trusted authority.

## create-ledger

This code example creates an Amazon QLDB ledger.

### Usage

```cargo run --bin create-ledger -l LEDGER [-r REGION] [-v]```

where:

- _LEDGER_ is the name of the ledger to create.
- _REGION_ is the region in which the client is created.
  If not supplied, uses the value of the **AWS_DEFAULT_REGION** environment variable.
  If the environment variable is not set, defaults to **us-west-2**.
- __-v__ enables displaying additional information.

## list-ledgers

This code example lists your Amazon QLDB ledgers.

### Usage

```cargo run --bin list-ledgers [-r REGION] [-v]```

where:

- _REGION_ is the region in which the client is created.
  If not supplied, uses the value of the **AWS_DEFAULT_REGION** environment variable.
  If the environment variable is not set, defaults to **us-west-2**.
- __-v__ enables displaying additional information.

## qldb-helloworld

This code example creates a low-level Amazon QLDB session against a ledger.

The QldbSession API is not intended to be used directly. Instead, we recommend using a higher-level driver, such as the Amazon QLDB Driver for Rust.

### Usage

cargo run --bin qldb-helloworld -l LEDGER [-r REGION] [-v]

where:

- _LEDGER_ is the name of the ledger to create the session against.
- _REGION_ is the region in which the client is created.
  If not supplied, uses the value of the **AWS_DEFAULT_REGION** environment variable.
  If the environment variable is not set, defaults to **us-west-2**.
- __-v__ enables displaying additional information.

## 
Loading