Share via


ConfidentialLedgerClient.GetLedgerEntryAsync Method

Definition

[Protocol Method] Gets the ledger entry at the specified transaction id. A collection id may optionally be specified to indicate the collection from which to fetch the value.

  • This protocol method allows explicit creation of the request and processing of the response for advanced scenarios.
public virtual System.Threading.Tasks.Task<Azure.Response> GetLedgerEntryAsync (string transactionId, string collectionId = default, Azure.RequestContext context = default);
abstract member GetLedgerEntryAsync : string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
override this.GetLedgerEntryAsync : string * string * Azure.RequestContext -> System.Threading.Tasks.Task<Azure.Response>
Public Overridable Function GetLedgerEntryAsync (transactionId As String, Optional collectionId As String = Nothing, Optional context As RequestContext = Nothing) As Task(Of Response)

Parameters

transactionId
String

Identifies a write transaction.

collectionId
String

The collection id.

context
RequestContext

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

Returns

The response returned from the service.

Exceptions

transactionId is null.

transactionId is an empty string, and was expected to be non-empty.

Service returned a non-success status code.

Examples

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

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

Response response = await client.GetLedgerEntryAsync("<transactionId>");

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("state").ToString());

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

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

Response response = await client.GetLedgerEntryAsync("<transactionId>", collectionId: "<collectionId>");

JsonElement result = JsonDocument.Parse(response.ContentStream).RootElement;
Console.WriteLine(result.GetProperty("state").ToString());
Console.WriteLine(result.GetProperty("entry").GetProperty("contents").ToString());
Console.WriteLine(result.GetProperty("entry").GetProperty("collectionId").ToString());
Console.WriteLine(result.GetProperty("entry").GetProperty("transactionId").ToString());

Remarks

To return older ledger entries, the relevant sections of the ledger must be read from disk and validated. To prevent blocking within the enclave, the response will indicate whether the entry is ready and part of the response, or if the loading is still ongoing.

Below is the JSON schema for the response payload.

Response Body:

Schema for LedgerQueryResult:

{
  state: "Loading" | "Ready", # Required. State of a ledger query.
  entry: {
    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.
  }, # Optional. The ledger entry found as a result of the query. This is only available if the query is in Ready state.
}

Applies to