Currently it's possible to get a credentials object with filled-out values like this:
from txaws.credentials import AWSCredentials
credentials = AWSCredentials()
This will check the environment:
for AWS_ACCESS_KEY_ID and use it if found
for AWS_SECRET_ACCESS_KEY and use it if found
for AWS_SHARED_CREDENTIALS_FILE and read it if either of the above two are missing
for AWS_PROFILE and use it instead of the "default" section of the credentials file
read the key id or secret key (if either or both were not found in the environment) from the profile in the credentials file
This is a lot of behavior to get from just instantiating the class with no arguments.
I suggest the following APIs instead:
AWSCredentials.from_environment(required_environ_dict) - does the searching that __init__ currently does
AWSCredentials.from_profile(profile_name, optional_credentials_contents) - just looks up the named profile in the given credentials data (read from a credentials file) and initialize from values found there.
AWSCredentials(access_key=..., secret_key=...) - just sets attributes
Most application code will probably want to use the first form.
Special-purpose applications (such as the txaws integration test suite) will probably want the second form (eg `AWSCredentials.from_profile("txaws-integration-tests", ...).
And the last one is a necessary building block for the first two. It's also just good form to have an object behave this way. And it may even be directly useful to some applications that store credentials somewhere other than in the environment or a credentials file.
Currently it's possible to get a credentials object with filled-out values like this:
This will check the environment:
This is a lot of behavior to get from just instantiating the class with no arguments.
I suggest the following APIs instead:
AWSCredentials.from_environment(required_environ_dict)
- does the searching that__init__
currently doesAWSCredentials.from_profile(profile_name, optional_credentials_contents)
- just looks up the named profile in the given credentials data (read from a credentials file) and initialize from values found there.AWSCredentials(access_key=..., secret_key=...)
- just sets attributesMost application code will probably want to use the first form.
Special-purpose applications (such as the txaws integration test suite) will probably want the second form (eg `AWSCredentials.from_profile("txaws-integration-tests", ...).
And the last one is a necessary building block for the first two. It's also just good form to have an object behave this way. And it may even be directly useful to some applications that store credentials somewhere other than in the environment or a credentials file.