A package to interact with StackPath
Project description
PyStackpath
Python library interact with StackPath API (https://developer.stackpath.com/en/)
It uses a custom OAuth2 requests.session
Install
pip install pystackpath
Examples
Set up a new Stackpath instance
from pystackpack import Stackpath
sp = Stackpath(
os.getenv("STACKPATH_CLIENTID"),
os.getenv("STACKPATH_APISECRET")
)
Search for stacks
stacks = sp.stacks().index(filter="name='my-awesome-stack' and status='ACTIVE'")
print(stacks)
Get one stack
stackid = "afcdaf14-47cb-40dd-9c13-3b20e6caf74a
onestack = sd.stacks().get(stackid)
Create a new stack
accountid = "081af5ee-38f8-44e9-b08a-881ea5de66f9"
newstack = sp.stacks().create(accountid, "my-second-stack")
Create a cdn site
stackid = "afcdaf14-47cb-40dd-9c13-3b20e6caf74a
cdnsite = sd.stacks().get(stackid).cdnsites().create("cdn.johndoe.com", "www.johndoe.com")
Search for cdn sites
cdnsite = sd.stacks().get(stackid).cdnsites().index(
filter="label='www.johndoe.com' and status='ACTIVE'"
)
Delete a cdn site
cdnsiteid = "19e1a7b2-068f-491c-a95f-b64eae66dd34"
cdnsite = sd.stacks().get(stackid).cdnsites().get(cdnsiteid).delete()
Purge a cdn resource and check the purge status.
purge_result1 = sd.stacks().get(stackid).cdnsites().purge(
url="https://example.com/resource/",
)
## Function accepts the arguments shown below with their respective
## default values. See API Doc for more information on options:
## https://developer.stackpath.com/en/api/cdn/#operation/PurgeContent
purge_result2 = sd.stacks().get(stackid).cdnsites().purge(
url="https://example.com/",
recursive = True,
invalidateOnly = False,
purgeAllDynamic = False,
headers = [],
purgeSelector = []
## purge_status can be used to check the status of the requested purge.
## Progress is represented as a decimal between 0 and 1, correlating to a
## percentage.
purge_status_response1 = sd.stacks().get(stackid).cdnsites().purge_status(purge_result1.id)
print(purge_status_response1.progress)
##>> 1
)
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
pystackpath-0.0.3.tar.gz
(4.2 kB
view hashes)
Built Distribution
Close
Hashes for pystackpath-0.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8577338101513d3af1f8688559fd65b681fb0cbd32b07468dda3eacf032e9467 |
|
MD5 | b52fbba2563fc7576810085b3f6e6a44 |
|
BLAKE2b-256 | a427a97b60efd5f765369adcd0e8e8d1945f734b7a9c55fe7d8a240a8af3f40b |