次の方法で共有


ConfidentialLedgerClient.GetLedgerEntry メソッド

定義

[プロトコルメソッド]指定したトランザクション ID にある台帳エントリを取得します。必要に応じて、値のフェッチ元のコレクションを示すコレクション ID を指定できます。

  • この プロトコル メソッド を使用すると、高度なシナリオで応答の要求と処理を明示的に作成できます。
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

パラメーター

transactionId
String

書き込みトランザクションを識別します。

collectionId
String

コレクション ID。

context
RequestContext

要求コンテキスト。これは、クライアント パイプラインの既定の動作を呼び出しごとにオーバーライドできます。

戻り値

サービスから返された応答。

例外

transactionId が null です。

transactionId は空の文字列であり、空でないと予想されていました。

サービスから成功以外の状態コードが返されました。

このサンプルでは、必要なパラメーターを使用して GetLedgerEntry を呼び出し、結果を解析する方法を示します。

var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new ConfidentialLedgerClient(endpoint, credential);

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

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

このサンプルでは、すべてのパラメーターを使用して GetLedgerEntry を呼び出す方法と、結果を解析する方法を示します。

var credential = new DefaultAzureCredential();
var endpoint = new Uri("<https://my-service.azure.com>");
var client = new ConfidentialLedgerClient(endpoint, credential);

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

注釈

古い台帳エントリを返すには、台帳の関連セクションをディスクから読み取り、検証する必要があります。 エンクレーブ内でのブロックを防ぐために、応答はエントリの準備ができているか、応答の一部なのか、読み込みがまだ進行中であるかを示します。

応答ペイロードの JSON スキーマを次に示します。

応答本文:

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.
}

適用対象