Package: bunnyhop
bunnyhopPython library for BunnyCDNStatusDocumentation only phaseInstallpipinstallbunnyhopGetting StartedfrombunnyhopimportBunnyb=Bunny('<api_key>')Pull ZonesGet a Pull Zonezone=b.Zone.get(id='myzone')#Returns: <Zone: myzone >Create a Pull Zoneb.Zone.create(Name='myzone',Type=0,# 0 = Standard and 1 = High VolumeOriginUrl='https://example.org',StorageZoneId='storage-zone-id')List Pull Zonesb.Zone.list()Update a Pull Zoneb.Zone.update(id='zone-id',#Positional ArgumentOriginUrl='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 objectzone.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-levelb.Zone.delete(id='myzone')#From Zone objectzone.delete()Purge File From Pull Zone# From top-levelb.Purge.create(url='https://myzone.b-cdn.net/css/style.css')# From Zone Objectzone.purge_file('css/style.css')Purge Esntire Pull Zone# From top-levelb.Zone.purge(id='myzone')# From Zone objectzone.purge()Add Edge Rule to Pull Zoneb.Zone.create_edge_rule(id='myzone',Guid="6a2e94df-8aa9-4cd2-b89d-16752102ef9f",# GUID of the edge ruleActionParameter1="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 = EnableTokenAuthenticationTriggerMatchingType=1Triggers=[])StorageStorage ZonesCreate 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 RegionsDE - Europe (Falkenstein)NY - North America (New York)SG - Asia (Singapore)SYD - Oceania (Sydney)List Storage Zonesb.Storage.all()# Returns: [<StorageZone: example-a (id: 1234)>, <StorageZone: example-b (id: 12345)>]Delete a Storage Zoneb.Storage.delete(1234)# Returns: NoneGet a Storage Zonezone=b.Storage.get(1234)# Returns: <StorageZone: example-a (id: 1234)>Storage Files# Get a Storage Zonezone=b.StorageZone.get(1234)# Returns: <StorageZone: example-a (id: 1234)># Lists files in the zoneobj_list=zone.all()# Returns [<StorageFile: index.html>, <StorageFile: base.css>]# Get a fileobj=zone.get('index.html')#Returns <StorageFile: index.html># Download that Fileobj.download()# Delete a filezone.delete('index.html')# Upload a Filezone.upload_file(dest_path='folder/path/error.html',local_path='/home/mj/work/error.html')# Returns: <StorageFile: error.html># Create a file from a stringzone.create_file('base.css',"body {background-color: powderblue;}")# Returns: <StorageFile: base.css>Storage JSON Files# Create a json filemj=zone.create_json('23.json',{'first_name':'Michael','last_name':'Jordan'})# Returns <StorageJSONFile: 23.json># Get information from filemj['first_name']# Returns: 'Michael'PurgeCreate a Purge# Purge a zone or fileb.Purge.create(url='https://myzone.b-cdn.net/style.css')Statsb.Stats.get(dateFrom='2018-12-01',dateTo='2020-01-01',pullZone='example-zone',serverZoneId='serverZoneID')BillingGet Billing Summaryb.Billing.get()ApplyCodeb.Billing.applycode(couponCode='somecode123')