ConfidentialLedgerClient.GetLedgerEntry 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 Azure.Response GetLedgerEntry (string transactionId, string collectionId = default, Azure.RequestContext context = default);
abstract member GetLedgerEntry : string * string * Azure.RequestContext -> Azure.Response
override this.GetLedgerEntry : string * string * Azure.RequestContext -> Azure.Response
Public Overridable Function GetLedgerEntry (transactionId As String, Optional collectionId As String = Nothing, Optional context As RequestContext = Nothing) As 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 GetLedgerEntry and parse the result.

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

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

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

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

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

Response response = client.GetLedgerEntry("<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