Skip to content

Commit

Permalink
[keyvault] style: format strings to f-string
Browse files Browse the repository at this point in the history
# Description
close Azure#3 
File changed: `azure-keyvault-keys/samples/hello_world_async.py`
I have added f-string formatting to `azure-keyvault-keys/samples/hello_world_async.py`.
It seems I have pulled additional changes from the main Azure repo. I will check to see if I can remove the commits by other contributors. Thank you.

# All SDK Contribution checklist:
- [x] **The pull request does not introduce [breaking changes]**
- [x] **CHANGELOG is updated for new features, bug fixes or other significant changes.**
- [x] **I have read the [contribution guidelines](https://github.com/Azure/azure-sdk-for-python/blob/main/CONTRIBUTING.md).**

## General Guidelines and Best Practices
- [x] Title of the pull request is clear and informative.
- [x] There are a small number of commits, each of which have an informative message. This means that previously merged commits do not appear in the history of the PR. For more information on cleaning up the commits in your PR, [see this page](https://github.com/Azure/azure-powershell/blob/master/documentation/development-docs/cleaning-up-commits.md).

### [Testing Guidelines](https://github.com/Azure/azure-sdk-for-python/blob/main/CONTRIBUTING.md##building-and-testing)
- [x] Pull request includes test coverage for the included changes.
  • Loading branch information
wonhyeongseo authored Jul 26, 2022
1 parent ea34c9c commit d530344
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 @@ -50,20 +50,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 @@ -73,22 +73,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 d530344

Please sign in to comment.