A Python library created make building with BunnyCDN easier
Project description
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')
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
bunnyhop-0.1.1.tar.gz
(13.9 kB
view details)
Built Distribution
bunnyhop-0.1.1-py3-none-any.whl
(13.7 kB
view details)
File details
Details for the file bunnyhop-0.1.1.tar.gz
.
File metadata
- Download URL: bunnyhop-0.1.1.tar.gz
- Upload date:
- Size: 13.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.7.7 Linux/5.4.58-07649-ge120df5deade
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1847acd744e8c6ff80a84b3fb0765407bde383ec8169b0899de3683c6f81397c |
|
MD5 | 415e3d10b2b049c03e86d8a6a919d840 |
|
BLAKE2b-256 | fab52c625b20f16741d3fa844386d161dd064f26c8ddeb865112e2f6e4753b96 |
File details
Details for the file bunnyhop-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: bunnyhop-0.1.1-py3-none-any.whl
- Upload date:
- Size: 13.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.0.5 CPython/3.7.7 Linux/5.4.58-07649-ge120df5deade
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 763a2c64bae8feb19cd1ed6c61e303dad544540c850fcfee2b6343f0ba866888 |
|
MD5 | 6ebb4730463912fdd8787a5a137f20f7 |
|
BLAKE2b-256 | 2583720397dbc6f7be43e9b44e5be0119321698350d094004553c84b786a4b54 |