An SDK for AWS Pricing
Project description
# awspricing
A Python library for working with the [AWS Price List API](http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/price-changes.html).
Features:
* Simple boto3-like interface
* Service-specific helper functions (only EC2 thus far)
* Local caching support
## Installation
```sh
$ pip install awspricing
```
## Usage
```python
import awspricing
ec2_offer = awspricing.offer('AmazonEC2')
ec2_offer.search_skus(
instance_type='c4.large',
location='US East (N. Virginia)',
operating_system='Linux',
) # {'4C7N4APU9GEUZ6H6', 'MBQPYDJSY3BY84BH', 'MDKVAJXMJGZFDJUE'}
ec2_offer.reserved_hourly(
'c4.xlarge',
operating_system='Linux',
lease_contract_length='3yr',
offering_class='convertible',
purchase_option='Partial Upfront',
region='us-east-1'
) # 0.10845205479452055
```
## Configuration
### Cache
Cache can be configured via the following environment variables:
`AWSPRICING_USE_CACHE`: Whether to use a simple file-based cache. Valid values are `0|1`. Defaults to `0` (false).
`AWSPRICING_CACHE_PATH`: Prefix to write cache files. Defaults to `/tmp/awspricing`.
`AWSPRICING_CACHE_MINUTES`: Number of minutes to keep cache for. Defaults to `1440` (1 day).
## Developing
### Environment setup
Run the following commands (preferably in a virtualenv) to setup your environment:
```sh
python setup.py develop
pip install -r test-requirements.txt
```
### Running unit tests
Simply run `make test` after environment setup to run unit tests.
### Running mypy (type checker)
The following commands can be used to run type checks. Note that a `python3`
interpreter is required for mypy.
```sh
pip install mypy
make test_mypy
```
A Python library for working with the [AWS Price List API](http://docs.aws.amazon.com/awsaccountbilling/latest/aboutv2/price-changes.html).
Features:
* Simple boto3-like interface
* Service-specific helper functions (only EC2 thus far)
* Local caching support
## Installation
```sh
$ pip install awspricing
```
## Usage
```python
import awspricing
ec2_offer = awspricing.offer('AmazonEC2')
ec2_offer.search_skus(
instance_type='c4.large',
location='US East (N. Virginia)',
operating_system='Linux',
) # {'4C7N4APU9GEUZ6H6', 'MBQPYDJSY3BY84BH', 'MDKVAJXMJGZFDJUE'}
ec2_offer.reserved_hourly(
'c4.xlarge',
operating_system='Linux',
lease_contract_length='3yr',
offering_class='convertible',
purchase_option='Partial Upfront',
region='us-east-1'
) # 0.10845205479452055
```
## Configuration
### Cache
Cache can be configured via the following environment variables:
`AWSPRICING_USE_CACHE`: Whether to use a simple file-based cache. Valid values are `0|1`. Defaults to `0` (false).
`AWSPRICING_CACHE_PATH`: Prefix to write cache files. Defaults to `/tmp/awspricing`.
`AWSPRICING_CACHE_MINUTES`: Number of minutes to keep cache for. Defaults to `1440` (1 day).
## Developing
### Environment setup
Run the following commands (preferably in a virtualenv) to setup your environment:
```sh
python setup.py develop
pip install -r test-requirements.txt
```
### Running unit tests
Simply run `make test` after environment setup to run unit tests.
### Running mypy (type checker)
The following commands can be used to run type checks. Note that a `python3`
interpreter is required for mypy.
```sh
pip install mypy
make test_mypy
```
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
awspricing-1.0.0.tar.gz
(6.9 kB
view details)
Built Distribution
File details
Details for the file awspricing-1.0.0.tar.gz
.
File metadata
- Download URL: awspricing-1.0.0.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | bbf310747769cd648e47742c79d35801a1909e9d1be924309a39c52b6766ea0f |
|
MD5 | 569cdcc87ca94c88de2177e7d4766b36 |
|
BLAKE2b-256 | 6a6a6ce7bddf693208618a0b3261a1e7a7976e539cec10c098a2f347d19bee9a |
File details
Details for the file awspricing-1.0.0-py2.py3-none-any.whl
.
File metadata
- Download URL: awspricing-1.0.0-py2.py3-none-any.whl
- Upload date:
- Size: 9.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 643e61e1587cd0579554c2981493fbf90876b46c8d93aa1daf391c96a32c57e3 |
|
MD5 | 78edb81e73dcc67ccddc51926a58d973 |
|
BLAKE2b-256 | 02721e8872b9fba34ebb6772de7d2c8b6d11ebd305235bcaec240f27da856835 |