Share via


ConfidentialLedgerClient Class

The ConfidentialLedgerClient writes and retrieves ledger entries against the Confidential Ledger service.

Constructor

ConfidentialLedgerClient(endpoint: str, credential: ConfidentialLedgerCertificateCredential | AsyncTokenCredential, *, ledger_certificate_path: bytes | str | PathLike, **kwargs: Any)

Parameters

Name Description
endpoint
Required
str

The Confidential Ledger URL, for example https://contoso.confidentialledger.azure.com.

credential
Required

A credential object for authenticating with the Confidential Ledger.

Keyword-Only Parameters

Name Description
ledger_certificate_path

The path to the Confidential Ledger's TLS certificate. If this file does not exist yet, the Confidential Ledger's TLS certificate will be fetched and saved to this file.

api_version
str

Api Version. Default value is "2022-05-13". Note that overriding this default value may result in unsupported behavior.

Methods

begin_create_ledger_entry

Writes a ledger entry and returns a poller to wait for it to be durably committed. The poller returns the result for the initial call to create the ledger entry.

A collection id may optionally be specified.

begin_get_ledger_entry

Returns a poller to fetch 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.

begin_get_receipt

Returns a poller for getting a receipt certifying ledger contents at a particular transaction id.

begin_wait_for_commit

Creates a poller that queries the state of the specified transaction until it is Committed, a state that indicates the transaction is durably stored in the Confidential Ledger.

close
create_ledger_entry

Writes a ledger entry.

The result is the expected JSON response with an additional field 'transactionId' which represents the transaction identifier for this write operation.

A collection id may optionally be specified.

create_or_update_user

Adds a user or updates a user's fields.

A JSON merge patch is applied for existing users.

delete_user

Deletes a user from the Confidential Ledger.

Deletes a user from the Confidential Ledger.

get_constitution

Gets the constitution used for governance.

The constitution is a script that assesses and applies proposals from consortium members.

get_current_ledger_entry

Gets the current value available in the ledger.

A collection id may optionally be specified.

get_enclave_quotes

Gets quotes for all nodes of the Confidential Ledger.

A quote is an SGX enclave measurement that can be used to verify the validity of a node and its enclave.

get_ledger_entry

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.

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.

get_receipt

Gets a receipt certifying ledger contents at a particular transaction id.

Gets a receipt certifying ledger contents at a particular transaction id.

get_transaction_status

Gets the status of an entry identified by a transaction id.

Gets the status of an entry identified by a transaction id.

get_user

Gets a user.

Gets a user.

list_collections

Retrieves a list of collection ids present in the Confidential Ledger.

Collection ids are user-created collections of ledger entries.

list_consortium_members

Lists the consortium members.

Consortium members can manage the Confidential Ledger.

list_ledger_entries

Gets ledger entries from a collection corresponding to a range.

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

send_request

Runs the network request through the client's chained policies.


>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = await client.send_request(request)
<AsyncHttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request

begin_create_ledger_entry

Writes a ledger entry and returns a poller to wait for it to be durably committed. The poller returns the result for the initial call to create the ledger entry.

A collection id may optionally be specified.

async begin_create_ledger_entry(entry: MutableMapping[str, Any] | IO, *, collection_id: str | None = None, **kwargs: Any) -> AsyncLROPoller[MutableMapping[str, Any]]

Parameters

Name Description
entry
Required
Union[<xref:JSON>, IO]

Ledger entry.

Keyword-Only Parameters

Name Description
collection_id
str

The collection id. Default value is None.

Default value: None

Returns

Type Description
LROPoller[<xref:JSON>]

An instance of LROPoller that returns a JSON object

Exceptions

Type Description

begin_get_ledger_entry

Returns a poller to fetch 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.

async begin_get_ledger_entry(transaction_id: str, *, collection_id: str | None = None, **kwargs: Any) -> AsyncLROPoller[MutableMapping[str, Any]]

Parameters

Name Description
transaction_id
Required
str

Identifies a write transaction. Required.

Keyword-Only Parameters

Name Description
collection_id
str

The collection id. Default value is None.

Default value: None

Returns

Type Description
LROPoller[<xref:JSON>]

An instance of LROPoller that returns a JSON object for the ledger entry.

Exceptions

Type Description

begin_get_receipt

Returns a poller for getting a receipt certifying ledger contents at a particular transaction id.

async begin_get_receipt(transaction_id: str, **kwargs: Any) -> AsyncLROPoller[MutableMapping[str, Any]]

Parameters

Name Description
transaction_id
Required
str

Identifies a write transaction. Required.

Returns

Type Description
LROPoller[<xref:JSON>]

An instance of LROPoller that returns a JSON object for the receipt.

Exceptions

Type Description

begin_wait_for_commit

Creates a poller that queries the state of the specified transaction until it is Committed, a state that indicates the transaction is durably stored in the Confidential Ledger.

async begin_wait_for_commit(transaction_id, **kwargs) -> AsyncLROPoller[MutableMapping[str, Any]]

Parameters

Name Description
transaction_id
Required
str

Identifies a write transaction. Required.

Returns

Type Description
LROPoller[<xref:JSON>]

An instance of LROPoller returning a JSON object describing the transaction status.

Exceptions

Type Description

close

async close() -> None

create_ledger_entry

Writes a ledger entry.

The result is the expected JSON response with an additional field 'transactionId' which represents the transaction identifier for this write operation.

A collection id may optionally be specified.

async create_ledger_entry(entry: MutableMapping[str, Any] | IO, *, collection_id: str | None = None, **kwargs: Any) -> MutableMapping[str, Any]

Parameters

Name Description
entry
Required
Union[<xref:JSON>, IO]

Ledger entry.

Keyword-Only Parameters

Name Description
collection_id
str

The collection id. Default value is None.

Default value: None

Returns

Type Description
<xref:JSON>

JSON object

Exceptions

Type Description

Examples


   # JSON input template you can fill out and use as your body input.
   entry = {
       "collectionId": {
           "collectionId": "str"  # Required.
       },
       "contents": "str",  # Required. Contents of the ledger entry.
       "transactionId": "str"  # 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.
   }

create_or_update_user

Adds a user or updates a user's fields.

A JSON merge patch is applied for existing users.

async create_or_update_user(user_id: str, user_details: MutableMapping[str, Any] | IO, **kwargs: Any) -> MutableMapping[str, Any]

Parameters

Name Description
user_id
Required
str

The user id, either an AAD object ID or certificate fingerprint. Required.

user_details
Required
<xref:JSON> or IO

Details about a Confidential Ledger user. Is either a model type or a IO type. Required.

Keyword-Only Parameters

Name Description
content_type
str

Body Parameter content-type. Known values are: 'application/merge-patch+json'. Default value is None.

Returns

Type Description
<xref:JSON>

JSON object

Exceptions

Type Description

Examples


   # response body for status code(s): 200
   response == {
       "assignedRole": "str",  # Represents an assignable role. Required. Known
         values are: "Administrator", "Contributor", and "Reader".
       "userId": "str"  # Optional. Identifier for the user. This must either be an
         AAD object id or a certificate fingerprint.
   }

delete_user

Deletes a user from the Confidential Ledger.

Deletes a user from the Confidential Ledger.

async delete_user(user_id: str, **kwargs: Any) -> None

Parameters

Name Description
user_id
Required
str

The user id, either an AAD object ID or certificate fingerprint. Required.

Returns

Type Description

None

Exceptions

Type Description

get_constitution

Gets the constitution used for governance.

The constitution is a script that assesses and applies proposals from consortium members.

async get_constitution(**kwargs: Any) -> MutableMapping[str, Any]

Returns

Type Description
<xref:JSON>

JSON object

Exceptions

Type Description

Examples


   # response body for status code(s): 200
   response == {
       "digest": "str",  # SHA256 digest of the constitution script. Required.
       "script": "str"  # Contents of the constitution. Required.
   }

get_current_ledger_entry

Gets the current value available in the ledger.

A collection id may optionally be specified.

async get_current_ledger_entry(*, collection_id: str | None = None, **kwargs: Any) -> MutableMapping[str, Any]

Keyword-Only Parameters

Name Description
collection_id
str

The collection id. Default value is None.

Default value: None

Returns

Type Description
<xref:JSON>

JSON object

Exceptions

Type Description

Examples


   # response body for status code(s): 200
   response == {
       "collectionId": "str",  # Optional.
       "contents": "str",  # Contents of the ledger entry. Required.
       "transactionId": "str"  # 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.
   }

get_enclave_quotes

Gets quotes for all nodes of the Confidential Ledger.

A quote is an SGX enclave measurement that can be used to verify the validity of a node and its enclave.

async get_enclave_quotes(**kwargs: Any) -> MutableMapping[str, Any]

Returns

Type Description
<xref:JSON>

JSON object

Exceptions

Type Description

Examples


   # response body for status code(s): 200
   response == {
       "currentNodeId": "str",  # Id of the Confidential Ledger node responding to
         the request. Required.
       "enclaveQuotes": {
           "str": {
               "mrenclave": "str",  # Optional. MRENCLAVE value of the code
                 running in the enclave.
               "nodeId": "str",  # ID assigned to this node. Required.
               "quoteVersion": "str",  # Version of the quote presented.
                 Required.
               "raw": "str"  # Raw SGX quote, parsable by tools like Open
                 Enclave's oeverify. Required.
           }
       }
   }

get_ledger_entry

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.

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.

async get_ledger_entry(transaction_id: str, *, collection_id: str | None = None, **kwargs: Any) -> MutableMapping[str, Any]

Parameters

Name Description
transaction_id
Required
str

Identifies a write transaction. Required.

Keyword-Only Parameters

Name Description
collection_id
str

The collection id. Default value is None.

Default value: None

Returns

Type Description
<xref:JSON>

JSON object

Exceptions

Type Description

Examples


   # response body for status code(s): 200
   response == {
       "entry": {
           "collectionId": "str",  # Optional. The ledger entry found as a
             result of the query. This is only available if the query is in Ready state.
           "contents": "str",  # Contents of the ledger entry. Required.
           "transactionId": "str"  # 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.
       },
       "state": "str"  # State of a ledger query. Required. Known values are:
         "Loading" and "Ready".
   }

get_receipt

Gets a receipt certifying ledger contents at a particular transaction id.

Gets a receipt certifying ledger contents at a particular transaction id.

async get_receipt(transaction_id: str, **kwargs: Any) -> MutableMapping[str, Any]

Parameters

Name Description
transaction_id
Required
str

Identifies a write transaction. Required.

Returns

Type Description
<xref:JSON>

JSON object

Exceptions

Type Description

Examples


   # response body for status code(s): 200
   response == {
       "receipt": {
           "cert": "str",  # Optional.
           "leaf": "str",  # Optional.
           "leafComponents": {
               "claimsDigest": "str",  # Optional.
               "commitEvidence": "str",  # Optional.
               "writeSetDigest": "str"  # Optional.
           },
           "nodeId": "str",  # Required.
           "proof": [
               {
                   "left": "str",  # Optional. Required.
                   "right": "str"  # Optional. Required.
               }
           ],
           "root": "str",  # Optional.
           "serviceEndorsements": [
               "str"  # Optional.
           ],
           "signature": "str"  # Required.
       },
       "state": "str",  # State of a ledger query. Required. Known values are:
         "Loading" and "Ready".
       "transactionId": "str"  # 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. Required.
   }

get_transaction_status

Gets the status of an entry identified by a transaction id.

Gets the status of an entry identified by a transaction id.

async get_transaction_status(transaction_id: str, **kwargs: Any) -> MutableMapping[str, Any]

Parameters

Name Description
transaction_id
Required
str

Identifies a write transaction. Required.

Returns

Type Description
<xref:JSON>

JSON object

Exceptions

Type Description

Examples


   # response body for status code(s): 200
   response == {
       "state": "str",  # Represents the state of the transaction. Required. Known
         values are: "Committed" and "Pending".
       "transactionId": "str"  # 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. Required.
   }

get_user

Gets a user.

Gets a user.

async get_user(user_id: str, **kwargs: Any) -> MutableMapping[str, Any]

Parameters

Name Description
user_id
Required
str

The user id, either an AAD object ID or certificate fingerprint. Required.

Returns

Type Description
<xref:JSON>

JSON object

Exceptions

Type Description

Examples


   # response body for status code(s): 200
   response == {
       "assignedRole": "str",  # Represents an assignable role. Required. Known
         values are: "Administrator", "Contributor", and "Reader".
       "userId": "str"  # Optional. Identifier for the user. This must either be an
         AAD object id or a certificate fingerprint.
   }

list_collections

Retrieves a list of collection ids present in the Confidential Ledger.

Collection ids are user-created collections of ledger entries.

list_collections(**kwargs: Any) -> AsyncIterable[MutableMapping[str, Any]]

Returns

Type Description
AsyncItemPaged[<xref:JSON>]

An iterator like instance of JSON object

Exceptions

Type Description

Examples


   # response body for status code(s): 200
   response == {
       "collectionId": "str"  # Required.
   }

list_consortium_members

Lists the consortium members.

Consortium members can manage the Confidential Ledger.

list_consortium_members(**kwargs: Any) -> AsyncIterable[MutableMapping[str, Any]]

Returns

Type Description
AsyncItemPaged[<xref:JSON>]

An iterator like instance of JSON object

Exceptions

Type Description

Examples


   # response body for status code(s): 200
   response == {
       "certificate": "str",  # PEM-encoded certificate associated with the member.
         Required.
       "id": "str"  # Identifier assigned to the member. Required.
   }

list_ledger_entries

Gets ledger entries from a collection corresponding to a range.

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

list_ledger_entries(*, collection_id: str | None = None, from_transaction_id: str | None = None, to_transaction_id: str | None = None, **kwargs: Any) -> AsyncIterable[MutableMapping[str, Any]]

Keyword-Only Parameters

Name Description
collection_id
str

The collection id. Default value is None.

Default value: None
from_transaction_id
str

Specify the first transaction ID in a range. Default value is None.

Default value: None
to_transaction_id
str

Specify the last transaction ID in a range. Default value is None.

Default value: None

Returns

Type Description
AsyncItemPaged[<xref:JSON>]

An iterator like instance of JSON object

Exceptions

Type Description

Examples


   # response body for status code(s): 200
   response == {
       "collectionId": "str",  # Optional.
       "contents": "str",  # Contents of the ledger entry. Required.
       "transactionId": "str"  # 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.
   }

send_request

Runs the network request through the client's chained policies.


>>> from azure.core.rest import HttpRequest
>>> request = HttpRequest("GET", "https://www.example.org/")
<HttpRequest [GET], url: 'https://www.example.org/'>
>>> response = await client.send_request(request)
<AsyncHttpResponse: 200 OK>

For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request

send_request(request: HttpRequest, **kwargs: Any) -> Awaitable[AsyncHttpResponse]

Parameters

Name Description
request
Required

The network request you want to make. Required.

Keyword-Only Parameters

Name Description
stream

Whether the response payload will be streamed. Defaults to False.

Returns

Type Description

The response of your network call. Does not do error handling on your response.