Skip to content

Commit 89ddd7e

Browse files
committed
fmt example file and update build number
1 parent 32eb5bf commit 89ddd7e

File tree

2 files changed

+44
-12
lines changed

2 files changed

+44
-12
lines changed

example/example.py

Lines changed: 43 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@
44

55
# [developer-docs.sdk.python.sdk-import]-start
66
from onepassword import *
7+
78
# [developer-docs.sdk.python.sdk-import]-end
89
from cryptography.hazmat.primitives.asymmetric import rsa
910
from cryptography.hazmat.primitives import serialization
1011

12+
1113
async def main():
1214
# [developer-docs.sdk.python.client-initialization]-start
1315
# Gets your service account token from the OP_SERVICE_ACCOUNT_TOKEN environment variable.
@@ -225,8 +227,9 @@ async def share_item(client: Client, vault_id: str, item_id: str):
225227
print(share_link)
226228
# [developer-docs.sdk.python.item-share-create-share]-end
227229

230+
228231
async def create_ssh_key_item(client: Client):
229-
# Generate a 2048-bit RSA private key
232+
# Generate a 2048-bit RSA private key
230233
private_key = rsa.generate_private_key(
231234
public_exponent=65537,
232235
key_size=4096,
@@ -236,9 +239,9 @@ async def create_ssh_key_item(client: Client):
236239
ssh_key_pkcs8_pem = private_key.private_bytes(
237240
encoding=serialization.Encoding.PEM,
238241
format=serialization.PrivateFormat.PKCS8,
239-
encryption_algorithm=serialization.NoEncryption()
242+
encryption_algorithm=serialization.NoEncryption(),
240243
)
241-
244+
242245
# [developer-docs.sdk.python.create-sshkey-item]-start
243246
# Create an Item containing SSH Key and add it to your vault.
244247
to_create = ItemCreateParams(
@@ -278,22 +281,31 @@ async def create_and_replace_document_item(client: Client):
278281
sections=[
279282
ItemSection(id="", title=""),
280283
],
281-
document=DocumentCreateParams(name="file.txt",content=Path("./example/file.txt").read_bytes())
284+
document=DocumentCreateParams(
285+
name="file.txt", content=Path("./example/file.txt").read_bytes()
286+
),
282287
)
283288
created_item = await client.items.create(to_create)
284289
# [developer-docs.sdk.python.create-document-item]-end
285290

286291
# [developer-docs.sdk.python.replace-document-item]-start
287292
# Replace the document in the item
288-
replaced_item = await client.items.files.replace_document(created_item,DocumentCreateParams(name="file2.txt",content=Path("./example/file2.txt").read_bytes()))
293+
replaced_item = await client.items.files.replace_document(
294+
created_item,
295+
DocumentCreateParams(
296+
name="file2.txt", content=Path("./example/file2.txt").read_bytes()
297+
),
298+
)
289299
# [developer-docs.sdk.python.replace-document-item]-end
290300

291301
# [developer-docs.sdk.python.read-document-item]-start
292302
# Read the document in the item
293-
content = await client.items.files.read(replaced_item.vault_id,replaced_item.id,replaced_item.document)
303+
content = await client.items.files.read(
304+
replaced_item.vault_id, replaced_item.id, replaced_item.document
305+
)
294306
# [developer-docs.sdk.python.read-document-item]-end
295-
296-
print(content)
307+
308+
print(str(content))
297309

298310
await client.items.delete(replaced_item.vault_id, replaced_item.id)
299311

@@ -322,25 +334,45 @@ async def create_attach_and_delete_file_field_item(client: Client):
322334
sections=[
323335
ItemSection(id="", title=""),
324336
],
325-
files=[FileCreateParams(name="file.txt",content=Path("./example/file.txt").read_bytes(),sectionId="",fieldId="file_field")]
337+
files=[
338+
FileCreateParams(
339+
name="file.txt",
340+
content=Path("./example/file.txt").read_bytes(),
341+
sectionId="",
342+
fieldId="file_field",
343+
)
344+
],
326345
)
327346

328347
created_item = await client.items.create(to_create)
329348
# [developer-docs.sdk.python.create-item-with-file-field]-end
330349

331350
# [developer-docs.sdk.python.attach-file-field-item]-start
332351
# Attach a file field to the item
333-
attached_item = await client.items.files.attach(created_item,FileCreateParams(name="file2.txt",content=Path("./example/file2.txt").read_bytes(),sectionId="",fieldId="new_file_field"))
352+
attached_item = await client.items.files.attach(
353+
created_item,
354+
FileCreateParams(
355+
name="file2.txt",
356+
content=Path("./example/file2.txt").read_bytes(),
357+
sectionId="",
358+
fieldId="new_file_field",
359+
),
360+
)
334361
# [developer-docs.sdk.python.attach-file-field-item]-end
335362

336363
# [developer-docs.sdk.python.delete-file-field-item]-start
337364
# Delete a file field from an item
338-
deleted_file_item = await client.items.files.delete(attached_item, attached_item.files[0].section_id, attached_item.files[0].field_id)
365+
deleted_file_item = await client.items.files.delete(
366+
attached_item,
367+
attached_item.files[1].section_id,
368+
attached_item.files[1].field_id,
369+
)
339370
# [developer-docs.sdk.python.delete-file-field-item]-end
340371

341372
print(len(deleted_file_item.files))
342373

343374
await client.items.delete(deleted_file_item.vault_id, deleted_file_item.id)
344375

376+
345377
if __name__ == "__main__":
346378
asyncio.run(main())

src/onepassword/build_number.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
SDK_BUILD_NUMBER = "0020000"
1+
SDK_BUILD_NUMBER = "0020001"

0 commit comments

Comments
 (0)