azure.confidentialledger package

class azure.confidentialledger.ConfidentialLedgerCertificateCredential(certificate_path: Union[bytes, str, os.PathLike])[source]

A certificate-based credential for the ConfidentialLedgerClient.

Parameters

certificate_path (Union[bytes, str, os.PathLike]) – Path to the PEM certificate to use for authentication.

property certificate_path

The path to the certificate file for this credential.

Returns

The path to the certificate file for this credential.

Return type

Union[bytes, str, os.PathLike]

class azure.confidentialledger.ConfidentialLedgerClient(endpoint: str, credential: Union[azure.confidentialledger._patch.ConfidentialLedgerCertificateCredential, azure.core.credentials.TokenCredential], *, ledger_certificate_path: Union[bytes, str, os.PathLike], **kwargs: Any)[source]

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

Parameters
Keyword Arguments
  • ledger_certificate_path (Union[bytes, str, os.PathLike]) – 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.

begin_create_ledger_entry(entry: Union[collections.abc.MutableMapping[str, Any], IO], *, collection_id: Optional[str] = None, **kwargs: Any)azure.core.polling._poller.LROPoller[collections.abc.MutableMapping[str, Any]]

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.

Parameters

entry (Union[JSON, IO]) – Ledger entry.

Keyword Arguments

collection_id (str) – The collection id. Default value is None.

Returns

An instance of LROPoller that returns a JSON object

Return type

LROPoller[JSON]

Raises

~azure.core.exceptions.HttpResponseError

begin_get_ledger_entry(transaction_id: str, *, collection_id: Optional[str] = None, **kwargs: Any)azure.core.polling._poller.LROPoller[collections.abc.MutableMapping[str, Any]]

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.

Parameters

transaction_id (str) – Identifies a write transaction. Required.

Keyword Arguments

collection_id (str) – The collection id. Default value is None.

Returns

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

Return type

LROPoller[JSON]

Raises

HttpResponseError

begin_get_receipt(transaction_id: str, **kwargs: Any)azure.core.polling._poller.LROPoller[collections.abc.MutableMapping[str, Any]]

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

Parameters

transaction_id (str) – Identifies a write transaction. Required.

Returns

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

Return type

LROPoller[JSON]

Raises

HttpResponseError

begin_wait_for_commit(transaction_id, **kwargs)azure.core.polling._poller.LROPoller[collections.abc.MutableMapping[str, Any]]

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.

Parameters

transaction_id (str) – Identifies a write transaction. Required.

Returns

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

Return type

LROPoller[JSON]

Raises

HttpResponseError

close()None[source]
create_ledger_entry(entry: Union[collections.abc.MutableMapping[str, Any], IO], *, collection_id: Optional[str] = None, **kwargs: Any)collections.abc.MutableMapping[str, Any]

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.

Parameters

entry (Union[JSON, IO]) – Ledger entry.

Keyword Arguments

collection_id (str) – The collection id. Default value is None.

Returns

JSON object

Return type

JSON

Raises

~azure.core.exceptions.HttpResponseError

Example

# 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(user_id: str, user_details: Union[collections.abc.MutableMapping[str, Any], IO], **kwargs: Any)collections.abc.MutableMapping[str, Any]

Adds a user or updates a user’s fields.

A JSON merge patch is applied for existing users.

Parameters
  • user_id (str) – The user id, either an AAD object ID or certificate fingerprint. Required.

  • user_details (JSON or IO) – Details about a Confidential Ledger user. Is either a model type or a IO type. Required.

Keyword Arguments

content_type (str) – Body Parameter content-type. Known values are: ‘application/merge-patch+json’. Default value is None.

Returns

JSON object

Return type

JSON

Raises

HttpResponseError

Example

# 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(user_id: str, **kwargs: Any)None

Deletes a user from the Confidential Ledger.

Deletes a user from the Confidential Ledger.

Parameters

user_id (str) – The user id, either an AAD object ID or certificate fingerprint. Required.

Returns

None

Return type

None

Raises

HttpResponseError

get_constitution(**kwargs: Any)collections.abc.MutableMapping[str, Any]

Gets the constitution used for governance.

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

Returns

JSON object

Return type

JSON

Raises

HttpResponseError

Example

# 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(*, collection_id: Optional[str] = None, **kwargs: Any)collections.abc.MutableMapping[str, Any]

Gets the current value available in the ledger.

A collection id may optionally be specified.

Keyword Arguments

collection_id (str) – The collection id. Default value is None.

Returns

JSON object

Return type

JSON

Raises

HttpResponseError

Example

# 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(**kwargs: Any)collections.abc.MutableMapping[str, Any]

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.

Returns

JSON object

Return type

JSON

Raises

HttpResponseError

Example

# 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(transaction_id: str, *, collection_id: Optional[str] = None, **kwargs: Any)collections.abc.MutableMapping[str, Any]

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.

Parameters

transaction_id (str) – Identifies a write transaction. Required.

Keyword Arguments

collection_id (str) – The collection id. Default value is None.

Returns

JSON object

Return type

JSON

Raises

HttpResponseError

Example

# 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(transaction_id: str, **kwargs: Any)collections.abc.MutableMapping[str, Any]

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

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

Parameters

transaction_id (str) – Identifies a write transaction. Required.

Returns

JSON object

Return type

JSON

Raises

HttpResponseError

Example

# 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(transaction_id: str, **kwargs: Any)collections.abc.MutableMapping[str, Any]

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

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

Parameters

transaction_id (str) – Identifies a write transaction. Required.

Returns

JSON object

Return type

JSON

Raises

HttpResponseError

Example

# 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(user_id: str, **kwargs: Any)collections.abc.MutableMapping[str, Any]

Gets a user.

Gets a user.

Parameters

user_id (str) – The user id, either an AAD object ID or certificate fingerprint. Required.

Returns

JSON object

Return type

JSON

Raises

HttpResponseError

Example

# 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(**kwargs: Any)Iterable[collections.abc.MutableMapping[str, Any]]

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

Collection ids are user-created collections of ledger entries.

Returns

An iterator like instance of JSON object

Return type

ItemPaged[JSON]

Raises

HttpResponseError

Example

# response body for status code(s): 200
response == {
    "collectionId": "str"  # Required.
}
list_consortium_members(**kwargs: Any)Iterable[collections.abc.MutableMapping[str, Any]]

Lists the consortium members.

Consortium members can manage the Confidential Ledger.

Returns

An iterator like instance of JSON object

Return type

ItemPaged[JSON]

Raises

HttpResponseError

Example

# 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(*, collection_id: Optional[str] = None, from_transaction_id: Optional[str] = None, to_transaction_id: Optional[str] = None, **kwargs: Any)Iterable[collections.abc.MutableMapping[str, Any]]

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.

Keyword Arguments
  • collection_id (str) – The collection id. Default value is None.

  • from_transaction_id (str) – Specify the first transaction ID in a range. Default value is None.

  • to_transaction_id (str) – Specify the last transaction ID in a range. Default value is None.

Returns

An iterator like instance of JSON object

Return type

ItemPaged[JSON]

Raises

HttpResponseError

Example

# 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(request: azure.core.rest._rest_py3.HttpRequest, **kwargs: Any)azure.core.rest._rest_py3.HttpResponse[source]

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 = client.send_request(request)
<HttpResponse: 200 OK>

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

Parameters

request (HttpRequest) – The network request you want to make. Required.

Keyword Arguments

stream (bool) – Whether the response payload will be streamed. Defaults to False.

Returns

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

Return type

HttpResponse