Skip to content

Commit e1210a9

Browse files
authored
Merge pull request #205286 from msmbaldwin/acl-net
Updated python quickstart
2 parents 1e45c7f + 66ed460 commit e1210a9

File tree

1 file changed

+12
-23
lines changed

1 file changed

+12
-23
lines changed

articles/confidential-ledger/quickstart-python.md

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ from azure.mgmt.confidentialledger.models import ConfidentialLedger
8282
# import the data plane sdk
8383

8484
from azure.confidentialledger import ConfidentialLedgerClient
85-
from azure.confidentialledger.identity_service import ConfidentialLedgerIdentityServiceClient
85+
from azure.confidentialledger.certificate import ConfidentialLedgerCertificateClient
8686
```
8787

8888
Next, we'll use the [DefaultAzureCredential Class](/python/api/azure-identity/azure.identity.defaultazurecredential) to authenticate the app.
@@ -159,7 +159,7 @@ Now that we have a ledger, we'll interact with it using the data plane client li
159159
First, we will generate and save a confidential ledger certificate.
160160

161161
```python
162-
identity_client = ConfidentialLedgerIdentityServiceClient(identity_url)
162+
identity_client = ConfidentialLedgerCertificateClient(identity_url)
163163
network_identity = identity_client.get_ledger_identity(
164164
ledger_id=ledger_name
165165
)
@@ -179,18 +179,18 @@ ledger_client = ConfidentialLedgerClient(
179179
)
180180
```
181181

182-
We are prepared to write to the ledger. We will do so using the `append_to_ledger` function.
182+
We are prepared to write to the ledger. We will do so using the `create_ledger_entry` function.
183183

184184
```python
185-
append_result = ledger_client.append_to_ledger(entry_contents="Hello world!")
185+
append_result = ledger_client.create_ledger_entry(entry_contents="Hello world!")
186186
print(append_result.transaction_id)
187187
```
188188

189189
The print function will return the transaction ID of your write to the ledger, which can be used to retrieve the message you wrote to the ledger.
190190

191191
```python
192-
entry = ledger_client.get_ledger_entry(transaction_id=append_result.transaction_id)
193-
print(entry.contents)
192+
latest_entry = ledger_client.get_current_ledger_entry(transaction_id=append_result.transaction_id)
193+
print(f"Current entry (transaction id = {latest_entry['transactionId']}) in collection {latest_entry['collectionId']}: {latest_entry['contents']}")
194194
```
195195

196196
The print function will return "Hello world!", as that is the message in the ledger that that corresponds to the transaction ID.
@@ -209,7 +209,7 @@ from azure.mgmt.confidentialledger.models import ConfidentialLedger
209209
# import data plane sdk
210210

211211
from azure.confidentialledger import ConfidentialLedgerClient
212-
from azure.confidentialledger.identity_service import ConfidentialLedgerIdentityServiceClient
212+
from azure.confidentialledger.certificate import ConfidentialLedgerCertificateClient
213213
from azure.confidentialledger import TransactionState
214214

215215
# Set variables
@@ -250,10 +250,7 @@ ledger_properties = ConfidentialLedger(**properties)
250250

251251
# Create a ledger
252252

253-
foo = confidential_ledger_mgmt.ledger.begin_create(rg, ledger_name, ledger_properties)
254-
255-
# wait until ledger is created
256-
foo.wait()
253+
confidential_ledger_mgmt.ledger.begin_create(rg, ledger_name, ledger_properties)
257254

258255
# Get the details of the ledger you just created
259256

@@ -270,7 +267,7 @@ print (f"- ID: {myledger.id}")
270267
#
271268
# Create a CL client
272269

273-
identity_client = ConfidentialLedgerIdentityServiceClient(identity_url)
270+
identity_client = ConfidentialLedgerCertificateClient(identity_url)
274271
network_identity = identity_client.get_ledger_identity(
275272
ledger_id=ledger_name
276273
)
@@ -287,20 +284,12 @@ ledger_client = ConfidentialLedgerClient(
287284
)
288285

289286
# Write to the ledger
290-
append_result = ledger_client.append_to_ledger(entry_contents="Hello world!")
287+
append_result = ledger_client.create_ledger_entry(entry_contents="Hello world!")
291288
print(append_result.transaction_id)
292289

293-
# Wait until transaction is committed on the ledger
294-
while True:
295-
commit_result = ledger_client.get_transaction_status(append_result.transaction_id)
296-
print(commit_result.state)
297-
if (commit_result.state == TransactionState.COMMITTED):
298-
break
299-
time.sleep(1)
300-
301290
# Read from the ledger
302-
entry = ledger_client.get_ledger_entry(transaction_id=append_result.transaction_id)
303-
print(entry.contents)
291+
entry = ledger_client.get_current_ledger_entry(transaction_id=append_result.transaction_id)
292+
print(f"Current entry (transaction id = {latest_entry['transactionId']}) in collection {latest_entry['collectionId']}: {latest_entry['contents']}")
304293
```
305294

306295
## Clean up resources

0 commit comments

Comments
 (0)