Share via


ConfidentialLedgerClient.GetLedgerEntriesAsync Method

Definition

[Protocol Method] Gets ledger entries from a collection corresponding to a range.

  • This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
public virtual Azure.AsyncPageable<BinaryData> GetLedgerEntriesAsync (string collectionId = default, string fromTransactionId = default, string toTransactionId = default, Azure.RequestContext context = default);
abstract member GetLedgerEntriesAsync : string * string * string * Azure.RequestContext -> Azure.AsyncPageable<BinaryData>
override this.GetLedgerEntriesAsync : string * string * string * Azure.RequestContext -> Azure.AsyncPageable<BinaryData>
Public Overridable Function GetLedgerEntriesAsync (Optional collectionId As String = Nothing, Optional fromTransactionId As String = Nothing, Optional toTransactionId As String = Nothing, Optional context As RequestContext = Nothing) As AsyncPageable(Of BinaryData)

Parameters

collectionId
String

The collection id.

fromTransactionId
String

Specify the first transaction ID in a range.

toTransactionId
String

Specify the last transaction ID in a range.

context
RequestContext

The request context, which can override default behaviors of the client pipeline on a per-call basis.

Returns

The AsyncPageable<T> from the service containing a list of BinaryData objects. Details of the body schema for each item in the collection are in the Remarks section below.

Exceptions

Service returned a non-success status code.

Examples

This sample shows how to call GetLedgerEntriesAsync and parse the result.

TokenCredential credential = new DefaultAzureCredential();
ConfidentialLedgerClient client = new ConfidentialLedgerClient(new Uri("http://localhost:3000"), credential);

await foreach (BinaryData item in client.GetLedgerEntriesAsync())
{
    JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("contents").ToString());
}

This sample shows how to call GetLedgerEntriesAsync with all parameters and parse the result.

TokenCredential credential = new DefaultAzureCredential();
ConfidentialLedgerClient client = new ConfidentialLedgerClient(new Uri("http://localhost:3000"), credential);

await foreach (BinaryData item in client.GetLedgerEntriesAsync(collectionId: "<collectionId>", fromTransactionId: "<fromTransactionId>", toTransactionId: "<toTransactionId>"))
{
    JsonElement result = JsonDocument.Parse(item.ToStream()).RootElement;
    Console.WriteLine(result.GetProperty("contents").ToString());
    Console.WriteLine(result.GetProperty("collectionId").ToString());
    Console.WriteLine(result.GetProperty("transactionId").ToString());
}

Remarks

A collection id may optionally be specified. Only entries in the specified (or default) collection will be returned.

Below is the JSON schema for one item in the pageable response.

Response Body:

Schema for LedgerEntries:

{
  contents: string, # Required. Contents of the ledger entry.
  collectionId: string, # Optional.
  transactionId: string, # Optional. A unique identifier for the state of the ledger. If returned as part of a LedgerEntry, it indicates the state from which the entry was read.
}

Applies to