An API client for the Pureport ReST API
Project description
Pureport Python Client
A thin Python 2/3 client for the Pureport ReST API, backed by requests.
Install
pip install pureport-client
Usage
from pureport.api.client import Client
from pureport.exception.api import ClientHttpException, NotFoundException
### Create the Client and login with your API Key
client = Client()
client.login("MY_API_KEY", "MY_API_SECRET")
### List Accounts
accounts = client.accounts.list()
first_account = accounts[0]
### List all Networks for the first Account
networks = client.accounts.networks(first_account).list()
### Create a Network for the Account
new_network = client.accounts.networks(first_account).create({
'name': 'My First Network'
})
### Obtain a Pureport location link for a new Connection
location = client.locations.list()[0]
location_link = Client.to_link(location, location['name'])
### Create an AWS Connection
new_connection_data = {
'name': 'My First AWS Connection',
'type': 'AWS_DIRECT_CONNECT',
'speed': 50,
'highAvailability': True,
'peering': {
'type': 'PRIVATE'
},
'location': location_link,
'billingTerm': 'HOURLY',
'awsAccountId': 'YOUR_AWS_ACCOUNT_ID',
'awsRegion': 'YOUR_AWS_REGION' # e.g. 'us-west-2'
}
new_connection = None
try:
new_connection = client.networks.connections(new_network).create(new_connection_data)
except ClientHttpException as e:
print(e.response.text)
### Retrieve the new AWS Connection by the returned object
client.connections.get(new_connection)
### Retrieve the new AWS Connection by it's 'id'
client.connections.get_by_id(new_connection['id'])
### Delete the new AWS Connection
client.connections.delete(new_connection)
### Expect a 404 error for the deleted connection
try:
client.connections.get(new_connection)
except NotFoundException as e:
print(e.response.text)
### Delete the Network
client.networks.delete(new_network)
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
pureport-client-0.0.5.tar.gz
(10.0 kB
view hashes)
Built Distribution
Close
Hashes for pureport_client-0.0.5-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c2873d98a4fc8b93e5deb34a6dfe6c22710e2d0041f734eafd1186d1448751b4 |
|
MD5 | b9052c3c02d48805664028cac2e112d9 |
|
BLAKE2b-256 | 4891c517c510d6a0c12dcb2ea285fab2c611b61619baaa90c5a579a754d76217 |