66from onepassword import *
77
88# [developer-docs.sdk.python.sdk-import]-end
9- from cryptography .hazmat .primitives .asymmetric import rsa
9+ from cryptography .hazmat .primitives .asymmetric import rsa , ed25519
1010from cryptography .hazmat .primitives import serialization
1111
1212
@@ -384,3 +384,75 @@ async def create_attach_and_delete_file_field_item(client: Client):
384384
385385if __name__ == "__main__" :
386386 asyncio .run (main ())
387+
388+ def generate_special_item_fields ():
389+
390+ # Generate an Ed25519 private key
391+ private_key = ed25519 .Ed25519PrivateKey .generate ()
392+
393+ # Encode the private key into a PEM encoded string. This will be assigned to the item field
394+ private_pem = private_key .private_bytes (
395+ encoding = serialization .Encoding .PEM ,
396+ format = serialization .PrivateFormat .PKCS8 ,
397+ encryption_algorithm = serialization .NoEncryption ()
398+ )
399+
400+ fields = [
401+ # Address
402+ ItemField (
403+ id = "address" ,
404+ title = "Address" ,
405+ field_type = ItemFieldType .ADDRESS ,
406+ value = "" ,
407+ details = ItemFieldDetailsAddress (type = "Address" , content = AddressFieldDetails (street = "1234 Main St" , city = "San Francisco" , state = "CA" , zip = "94111" , country = "USA" )),
408+ sectionId = "" ,
409+ ),
410+ # Date
411+ ItemField (
412+ id = "date" ,
413+ title = "Date" ,
414+ field_type = ItemFieldType .DATE ,
415+ section_id = "mysection" ,
416+ value = "1998-03-15" ,
417+ ),
418+ # MonthYear
419+ ItemField (
420+ id = "month_year" ,
421+ title = "Month Year" ,
422+ field_type = ItemFieldType .MONTHYEAR ,
423+ section_id = "mysection" ,
424+ value = "03/1998" ,
425+ ),
426+ # Reference
427+ ItemField (
428+ id = "Reference" ,
429+ title = "Reference" ,
430+ field_type = ItemFieldType .REFERENCE ,
431+ value = "f43hnkatjllm5fsfsmgaqdhv7a" ,
432+ sectionId = "references"
433+ ),
434+ # TOTP from URL
435+ ItemField (
436+ id = "onetimepassword" ,
437+ title = "one-time-password" ,
438+ field_type = ItemFieldType .TOTP ,
439+ section_id = "totpsection" ,
440+ value = "otpauth://totp/my-example-otp?secret=jncrjgbdjnrncbjsr&issuer=1Password" ,
441+ ),
442+ # TOTP from Secret
443+ ItemField (
444+ id = "onetimepassword" ,
445+ title = "one-time-password" ,
446+ field_type = ItemFieldType .TOTP ,
447+ section_id = "totpsection" ,
448+ value = "jncrjgbdjnrncbjsr" ,
449+ ),
450+ # SSH key
451+ ItemField (
452+ id = "private_key" ,
453+ title = "private key" ,
454+ field_type = ItemFieldType .SSHKEY ,
455+ value = private_pem ,
456+ sectionId = "" ,
457+ ),
458+ ],
0 commit comments