bunnyhop
Python library for BunnyCDN
Status
Documentation only phase
Install
pip install bunnyhop
Getting Started
from bunnyhop import Bunny
b = Bunny('<api_key>')
Pull Zones
Get a Pull Zone
zone = b.Zone.get(id='myzone')
#Returns: <Zone: myzone >
Create a Pull Zone
b.Zone.create(
Name='myzone',
Type=0, # 0 = Standard and 1 = High Volume
OriginUrl='https://example.org',
StorageZoneId='storage-zone-id'
)
List Pull Zones
b.Zone.list()
Update a Pull Zone
b.Zone.update(
id='zone-id', #Positional Argument
OriginUrl='http://example.org',
AllowedReferrers=['app.example.org', 'www.example.org'],
BlockedIps=['122.33.22.11'],
EnableCacheSlice=False,
EnableGeoZoneUS=True,
EnableGeoZoneEU=True,
EnableGeoZoneASIA=True,
EnableGeoZoneSA=True,
EnableGeoZoneAF=True,
ZoneSecurityEnabled=True,
ZoneSecurityIncludeHashRemoteIP=True,
IgnoreQueryStrings=True,
MonthlyBandwidthLimit=1073741824,
AccessControlOriginHeaderExtensions=['jpg', 'png'],
EnableAccessControlOriginHeader=True,
BlockRootPathAccess=True,
EnableWebpVary=True,
EnableLogging=True,
DisableCookies=False,
BudgetRedirectedCountries=['RU', 'BR'],
BlockedCountries=['RU', 'BR'],
EnableOriginShield=True,
OriginShieldZoneCode='FR',
AddCanonicalHeader=0,
CacheControlMaxAgeOverride=-1,
AddHostHeader=True,
AWSSigningEnabled=True,
AWSSigningKey='AK_EXAMPLEKEY',
AWSSigningRegionName='us-east-1',
AWSSigningSecret='SK_EXAMPLESECRETKET',
EnableTLS1=True,
EnableTLS1_1=True
)
# From Zone object
zone.update(
OriginUrl='http://example.org',
AllowedReferrers=['app.example.org', 'www.example.org'],
BlockedIps=['122.33.22.11'],
EnableCacheSlice=False,
EnableGeoZoneUS=True,
EnableGeoZoneEU=True,
EnableGeoZoneASIA=True,
EnableGeoZoneSA=True,
EnableGeoZoneAF=True,
ZoneSecurityEnabled=True,
ZoneSecurityIncludeHashRemoteIP=True,
IgnoreQueryStrings=True,
MonthlyBandwidthLimit=1073741824,
AccessControlOriginHeaderExtensions=['jpg', 'png'],
EnableAccessControlOriginHeader=True,
BlockRootPathAccess=True,
EnableWebpVary=True,
EnableLogging=True,
DisableCookies=False,
BudgetRedirectedCountries=['RU', 'BR'],
BlockedCountries=['RU', 'BR'],
EnableOriginShield=True,
OriginShieldZoneCode='FR',
AddCanonicalHeader=0,
CacheControlMaxAgeOverride=-1,
AddHostHeader=True,
AWSSigningEnabled=True,
AWSSigningKey='AK_EXAMPLEKEY',
AWSSigningRegionName='us-east-1',
AWSSigningSecret='SK_EXAMPLESECRETKET',
EnableTLS1=True,
EnableTLS1_1=True
)
Delete Pull Zone
#From top-level
b.Zone.delete(id='myzone')
#From Zone object
zone.delete()
Purge File From Pull Zone
# From top-level
b.Purge.create(url='https://myzone.b-cdn.net/css/style.css')
# From Zone Object
zone.purge_file('css/style.css')
Purge Esntire Pull Zone
# From top-level
b.Zone.purge(
id='myzone'
)
# From Zone object
zone.purge()
Add Edge Rule to Pull Zone
b.Zone.create_edge_rule(
id='myzone',
Guid="6a2e94df-8aa9-4cd2-b89d-16752102ef9f", # GUID of the edge rule
ActionParameter1 = "My-Header",
ActionParameter2 = "HeaderValue",
Enabled = True,
Description = "My header value",
ActionType = 0, # 0 = ForceSSL, 1 = Redirect, 2 = OriginUrl, 3 = OverrideCacheTime, 4 = BlockRequest, 5 = SetResponseHeader, 6 = SetRequestHeader, 7 = ForceDownload, 8 = DisableTokenAuthentication, 9 = EnableTokenAuthentication
TriggerMatchingType = 1
Triggers = []
)
Storage
Storage Zones
Create Storage Zone
# Create a Storage Zone (available regions are listed below)
b.Storage.create(name='example-a', main_storage_region='NY', replica_regions=['DE', 'SG', 'SYD'])
# Returns: <StorageZone: example-a (id: 1234)>
Storage Regions
- DE - Europe (Falkenstein)
- NY - North America (New York)
- SG - Asia (Singapore)
- SYD - Oceania (Sydney)
List Storage Zones
b.Storage.all()
# Returns: [<StorageZone: example-a (id: 1234)>, <StorageZone: example-b (id: 12345)>]
Delete a Storage Zone
b.Storage.delete(1234)
# Returns: None
Get a Storage Zone
zone = b.Storage.get(1234)
# Returns: <StorageZone: example-a (id: 1234)>
Storage Files
# Get a Storage Zone
zone = b.StorageZone.get(1234)
# Returns: <StorageZone: example-a (id: 1234)>
# Lists files in the zone
obj_list = zone.all()
# Returns [<StorageFile: index.html>, <StorageFile: base.css>]
# Get a file
obj = zone.get('index.html')
#Returns <StorageFile: index.html>
# Download that File
obj.download()
# Delete a file
zone.delete('index.html')
# Upload a File
zone.upload_file(dest_path='folder/path/error.html', local_path='/home/mj/work/error.html')
# Returns: <StorageFile: error.html>
# Create a file from a string
zone.create_file('base.css', "body {background-color: powderblue;}")
# Returns: <StorageFile: base.css>
Storage JSON Files
# Create a json file
mj = zone.create_json('23.json', {'first_name':'Michael', 'last_name': 'Jordan'})
# Returns <StorageJSONFile: 23.json>
# Get information from file
mj['first_name']
# Returns: 'Michael'
Purge
Create a Purge
# Purge a zone or file
b.Purge.create(url='https://myzone.b-cdn.net/style.css')
Stats
b.Stats.get(dateFrom='2018-12-01', dateTo='2020-01-01', pullZone='example-zone', serverZoneId='serverZoneID')
Billing
Get Billing Summary
b.Billing.get()
ApplyCode
b.Billing.applycode(couponCode='somecode123')
Metadata
Release files for bunnyhop 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bunnyhop-0.1.1.tar.gz | 13.9 kB | Without provenance | Details for bunnyhop-0.1.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bunnyhop-0.1.1-py3-none-any.whl | Python 3 | none | any | Details for bunnyhop-0.1.1-py3-none-any.whl |
Total release size: 27.6 kB
Release files / bunnyhop-0.1.1.tar.gz
| Download URL | bunnyhop-0.1.1.tar.gz |
|---|---|
| Size | 13.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1847acd744e8c6ff80a84b3fb0765407bde383ec8169b0899de3683c6f81397c
|
|
BLAKE2b-256 checksum How to use checksums |
fab52c625b20f16741d3fa844386d161dd064f26c8ddeb865112e2f6e4753b96
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.7.7 Linux/5.4.58-07649-ge120df5deade
|
Release files / bunnyhop-0.1.1-py3-none-any.whl
| Download URL | bunnyhop-0.1.1-py3-none-any.whl |
|---|---|
| Size | 13.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
763a2c64bae8feb19cd1ed6c61e303dad544540c850fcfee2b6343f0ba866888
|
|
BLAKE2b-256 checksum How to use checksums |
2583720397dbc6f7be43e9b44e5be0119321698350d094004553c84b786a4b54
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.0.5 CPython/3.7.7 Linux/5.4.58-07649-ge120df5deade
|
Security for bunnyhop 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.