Skip to content

Commit

Permalink
style: apply f-string
Browse files Browse the repository at this point in the history
  • Loading branch information
wonhyeongseo authored and wonder6845 committed Aug 23, 2022
1 parent 6ae9223 commit 96a8adf
Showing 1 changed file with 6 additions and 14 deletions.
20 changes: 6 additions & 14 deletions sdk/keyvault/azure-keyvault-keys/samples/hello_world_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,20 @@ async def run_sample():
key_ops = ["encrypt", "decrypt", "sign", "verify", "wrapKey", "unwrapKey"]
key_name = "rsaKeyNameAsync"
rsa_key = await client.create_rsa_key(key_name, size=key_size, key_operations=key_ops)
print("RSA Key with name '{0}' created of type '{1}'.".format(rsa_key.name, rsa_key.key_type))
print(f"RSA Key with name '{rsa_key.name}' created of type '{rsa_key.key_type}'.")

# Let's create an Elliptic Curve key with algorithm curve type P-256.
# if the key already exists in the Key Vault, then a new version of the key is created.
print("\n.. Create an EC Key")
key_curve = "P-256"
key_name = "ECKeyNameAsync"
ec_key = await client.create_ec_key(key_name, curve=key_curve)
print("EC Key with name '{0}' created of type {1}.".format(ec_key.name, ec_key.key_type))
print(f"EC Key with name '{ec_key.name}' created of type {ec_key.key_type}.")

# Let's get the rsa key details using its name
print("\n.. Get a Key using it's name")
rsa_key = await client.get_key(rsa_key.name)
print("Key with name '{0}' was found.".format(rsa_key.name))
print(f"Key with name '{rsa_key.name}' was found.")

# Let's say we want to update the expiration time for the EC key and disable the key to be usable
# for cryptographic operations. The update method allows the user to modify the metadata (key attributes)
Expand All @@ -72,22 +72,14 @@ async def run_sample():
updated_ec_key = await client.update_key_properties(
ec_key.name, version=ec_key.properties.version, expires_on=expires_on, enabled=False
)
print(
"Key with name '{0}' was updated on date '{1}'".format(
updated_ec_key.name, updated_ec_key.properties.updated_on
)
)
print(
"Key with name '{0}' was updated to expire on '{1}'".format(
updated_ec_key.name, updated_ec_key.properties.expires_on
)
)
print(f"Key with name '{updated_ec_key.name}' was updated on date '{updated_ec_key.properties.updated_on}'")
print(f"Key with name '{updated_ec_key.name}' was updated to expire on '{updated_ec_key.properties.expires_on}'")

# The keys are no longer used, let's delete them
print("\n.. Deleting keys")
for key_name in (ec_key.name, rsa_key.name):
deleted_key = await client.delete_key(key_name)
print("\nDeleted '{}'".format(deleted_key.name))
print(f"\nDeleted '{deleted_key.name}'")

print("\nrun_sample done")
await credential.close()
Expand Down

0 comments on commit 96a8adf

Please sign in to comment.