pullzone_get.go raw
1 package bunny
2
3 import (
4 "context"
5 "fmt"
6 )
7
8 // Constants for the Type fields of a Pull Zone.
9 const (
10 PullZoneTypeStandard int = 1
11 PullZoneTypeVolume int = 2
12 )
13
14 // Constants for the values of the PatternMatchingType of EdgeRuleTrigger and
15 // TriggerMatchingType of an EdgeRule.
16 const (
17 MatchingTypeAny int = iota
18 MatchingTypeAll
19 MatchingTypeNone
20 )
21
22 // PullZone represents the response of the List and Get Pull Zone API endpoint.
23 //
24 // Bunny.net API docs: https://docs.bunny.net/reference/pullzonepublic_index2 https://docs.bunny.net/reference/pullzonepublic_index
25 type PullZone struct {
26 ID *int64 `json:"Id,omitempty"`
27
28 AccessControlOriginHeaderExtensions []string `json:"AccessControlOriginHeaderExtensions,omitempty"`
29 AddCanonicalHeader *bool `json:"AddCanonicalHeader,omitempty"`
30 AddHostHeader *bool `json:"AddHostHeader,omitempty"`
31 AllowedReferrers []string `json:"AllowedReferrers,omitempty"`
32 AWSSigningEnabled *bool `json:"AWSSigningEnabled,omitempty"`
33 AWSSigningKey *string `json:"AWSSigningKey,omitempty"`
34 AWSSigningRegionName *string `json:"AWSSigningRegionName,omitempty"`
35 AWSSigningSecret *string `json:"AWSSigningSecret,omitempty"`
36 BlockedCountries []string `json:"BlockedCountries,omitempty"`
37 BlockedIPs []string `json:"BlockedIps,omitempty"`
38 BlockedReferrers []string `json:"BlockedReferrers,omitempty"`
39 BlockPostRequests *bool `json:"BlockPostRequests,omitempty"`
40 BlockRootPathAccess *bool `json:"BlockRootPathAccess,omitempty"`
41 BudgetRedirectedCountries []string `json:"BudgetRedirectedCountries,omitempty"`
42 BurstSize *int32 `json:"BurstSize,omitempty"`
43 // CacheControlBrowserMaxAgeOverride is called
44 // CacheControlPublicMaxAgeOverride in the API. Both names refer to the
45 // same setting.
46 CacheControlBrowserMaxAgeOverride *int64 `json:"CacheControlPublicMaxAgeOverride,omitempty"`
47 CacheControlMaxAgeOverride *int64 `json:"CacheControlMaxAgeOverride,omitempty"`
48 CacheErrorResponses *bool `json:"CacheErrorResponses,omitempty"`
49 CnameDomain *string `json:"CnameDomain,omitempty"`
50 ConnectionLimitPerIPCount *int32 `json:"ConnectionLimitPerIPCount,omitempty"`
51 CookieVaryParameters []string `json:"CookieVaryParameters,omitempty"`
52 DisableCookies *bool `json:"DisableCookies,omitempty"`
53 DNSRecordID *int64 `json:"DnsRecordId,omitempty"`
54 DNSRecordValue *string `json:"DnsRecordValue,omitempty"`
55 DNSZoneID *int64 `json:"DnsZoneId,omitempty"`
56 EdgeRules []*EdgeRule `json:"EdgeRules,omitempty"`
57 EnableAccessControlOriginHeader *bool `json:"EnableAccessControlOriginHeader,omitempty"`
58 EnableAutoSSL *bool `json:"EnableAutoSSL,omitempty"`
59 EnableAvifVary *bool `json:"EnableAvifVary,omitempty"`
60 EnableCacheSlice *bool `json:"EnableCacheSlice,omitempty"`
61 EnableCookieVary *bool `json:"EnableCookieVary,omitempty"`
62 EnableCountryCodeVary *bool `json:"EnableCountryCodeVary,omitempty"`
63 Enabled *bool `json:"Enabled,omitempty"`
64 EnableGeoZoneAF *bool `json:"EnableGeoZoneAF,omitempty"`
65 EnableGeoZoneAsia *bool `json:"EnableGeoZoneASIA,omitempty"`
66 EnableGeoZoneEU *bool `json:"EnableGeoZoneEU,omitempty"`
67 EnableGeoZoneSA *bool `json:"EnableGeoZoneSA,omitempty"`
68 EnableGeoZoneUS *bool `json:"EnableGeoZoneUS,omitempty"`
69 EnableHostnameVary *bool `json:"EnableHostnameVary,omitempty"`
70 EnableLogging *bool `json:"EnableLogging,omitempty"`
71 EnableMobileVary *bool `json:"EnableMobileVary,omitempty"`
72 EnableOriginShield *bool `json:"EnableOriginShield,omitempty"`
73 EnableSafeHop *bool `json:"EnableSafeHop,omitempty"`
74 EnableSmartCache *bool `json:"EnableSmartCache,omitempty"`
75 EnableTLS1 *bool `json:"EnableTLS1,omitempty"`
76 EnableTLS11 *bool `json:"EnableTLS1_1,omitempty"`
77 EnableWebPVary *bool `json:"EnableWebPVary,omitempty"`
78 ErrorPageCustomCode *string `json:"ErrorPageCustomCode,omitempty"`
79 ErrorPageEnableCustomCode *bool `json:"ErrorPageEnableCustomCode,omitempty"`
80 ErrorPageEnableStatuspageWidget *bool `json:"ErrorPageEnableStatuspageWidget,omitempty"`
81 ErrorPageStatuspageCode *string `json:"ErrorPageStatuspageCode,omitempty"`
82 ErrorPageWhitelabel *bool `json:"ErrorPageWhitelabel,omitempty"`
83 FollowRedirects *bool `json:"FollowRedirects,omitempty"`
84 Hostnames []*Hostname `json:"Hostnames,omitempty"`
85 IgnoreQueryStrings *bool `json:"IgnoreQueryStrings,omitempty"`
86 LimitRateAfter *float64 `json:"LimitRateAfter,omitempty"`
87 LimitRatePerSecond *float64 `json:"LimitRatePerSecond,omitempty"`
88 LogAnonymizationType *int `json:"LogAnonymizationType,omitempty"`
89 LogFormat *int32 `json:"LogFormat,omitempty"`
90 LogForwardingEnabled *bool `json:"LogForwardingEnabled,omitempty"`
91 LogForwardingFormat *int `json:"LogForwardingFormat,omitempty"`
92 LogForwardingHostname *string `json:"LogForwardingHostname,omitempty"`
93 LogForwardingPort *int32 `json:"LogForwardingPort,omitempty"`
94 LogForwardingProtocol *int `json:"LogForwardingProtocol,omitempty"`
95 LogForwardingToken *string `json:"LogForwardingToken,omitempty"`
96 LoggingIPAnonymizationEnabled *bool `json:"LoggingIPAnonymizationEnabled,omitempty"`
97 LoggingSaveToStorage *bool `json:"LoggingSaveToStorage,omitempty"`
98 LoggingStorageZoneID *int64 `json:"LoggingStorageZoneId,omitempty"`
99 MonthlyBandwidthLimit *int64 `json:"MonthlyBandwidthLimit,omitempty"`
100 MonthlyBandwidthUsed *int64 `json:"MonthlyBandwidthUsed,omitempty"`
101 MonthlyCharges *float64 `json:"MonthlyCharges,omitempty"`
102 Name *string `json:"Name,omitempty"`
103 OptimizerAutomaticOptimizationEnabled *bool `json:"OptimizerAutomaticOptimizationEnabled,omitempty"`
104 OptimizerDesktopMaxWidth *int32 `json:"OptimizerDesktopMaxWidth,omitempty"`
105 OptimizerEnabled *bool `json:"OptimizerEnabled,omitempty"`
106 OptimizerEnableManipulationEngine *bool `json:"OptimizerEnableManipulationEngine,omitempty"`
107 OptimizerEnableWebP *bool `json:"OptimizerEnableWebP,omitempty"`
108 OptimizerForceClasses *bool `json:"OptimizerForceClasses,omitempty"`
109 OptimizerImageQuality *int32 `json:"OptimizerImageQuality,omitempty"`
110 OptimizerMinifyCSS *bool `json:"OptimizerMinifyCSS,omitempty"`
111 OptimizerMinifyJavaScript *bool `json:"OptimizerMinifyJavaScript,omitempty"`
112 OptimizerMobileImageQuality *int32 `json:"OptimizerMobileImageQuality,omitempty"`
113 OptimizerMobileMaxWidth *int32 `json:"OptimizerMobileMaxWidth,omitempty"`
114 OptimizerWatermarkEnabled *bool `json:"OptimizerWatermarkEnabled,omitempty"`
115 OptimizerWatermarkMinImageSize *int32 `json:"OptimizerWatermarkMinImageSize,omitempty"`
116 OptimizerWatermarkOffset *float64 `json:"OptimizerWatermarkOffset,omitempty"`
117 OptimizerWatermarkPosition *int `json:"OptimizerWatermarkPosition,omitempty"`
118 OptimizerWatermarkURL *string `json:"OptimizerWatermarkUrl,omitempty"`
119 OriginConnectTimeout *int32 `json:"OriginConnectTimeout,omitempty"`
120 OriginHostHeader *string `json:"OriginHostHeader,omitempty"`
121 OriginResponseTimeout *int32 `json:"OriginResponseTimeout,omitempty"`
122 OriginRetries *int32 `json:"OriginRetries,omitempty"`
123 OriginRetry5xxResponses *bool `json:"OriginRetry5xxResponses,omitempty"`
124 OriginRetryConnectionTimeout *bool `json:"OriginRetryConnectionTimeout,omitempty"`
125 OriginRetryDelay *int32 `json:"OriginRetryDelay,omitempty"`
126 OriginRetryResponseTimeout *bool `json:"OriginRetryResponseTimeout,omitempty"`
127 OriginShieldEnableConcurrencyLimit *bool `json:"OriginShieldEnableConcurrencyLimit,omitempty"`
128 OriginShieldMaxConcurrentRequests *int32 `json:"OriginShieldMaxConcurrentRequests,omitempty"`
129 OriginShieldMaxQueuedRequests *int32 `json:"OriginShieldMaxQueuedRequests,omitempty"`
130 OriginShieldQueueMaxWaitTime *int32 `json:"OriginShieldQueueMaxWaitTime,omitempty"`
131 OriginShieldZoneCode *string `json:"OriginShieldZoneCode,omitempty"`
132 OriginType *int32 `json:"OriginType,omitempty"`
133 OriginURL *string `json:"OriginUrl,omitempty"`
134 PermaCacheStorageZoneID *int64 `json:"PermaCacheStorageZoneId,omitempty"`
135 PriceOverride *float64 `json:"PriceOverride,omitempty"`
136 QueryStringVaryParameters []string `json:"QueryStringVaryParameters,omitempty"`
137 RequestLimit *int32 `json:"RequestLimit,omitempty"`
138 ShieldDDosProtectionEnabled *bool `json:"ShieldDDosProtectionEnabled,omitempty"`
139 ShieldDDosProtectionType *int `json:"ShieldDDosProtectionType,omitempty"`
140 StorageZoneID *int64 `json:"StorageZoneId,omitempty"`
141 Type *int `json:"Type,omitempty"`
142 UseBackgroundUpdate *bool `json:"UseBackgroundUpdate,omitempty"`
143 UseStaleWhileOffline *bool `json:"UseStaleWhileOffline,omitempty"`
144 UseStaleWhileUpdating *bool `json:"UseStaleWhileUpdating,omitempty"`
145 VerifyOriginSSL *bool `json:"VerifyOriginSSL,omitempty"`
146 VideoLibraryID *int64 `json:"VideoLibraryId,omitempty"`
147 ZoneSecurityEnabled *bool `json:"ZoneSecurityEnabled,omitempty"`
148 ZoneSecurityIncludeHashRemoteIP *bool `json:"ZoneSecurityIncludeHashRemoteIP,omitempty"`
149 ZoneSecurityKey *string `json:"ZoneSecurityKey,omitempty"`
150 }
151
152 // Hostname represents a Hostname returned from the Get and List Pull Zone API Endpoints.
153 type Hostname struct {
154 ID *int64 `json:"Id,omitempty"`
155 Value *string `json:"Value,omitempty"`
156 ForceSSL *bool `json:"ForceSSL,omitempty"`
157 IsSystemHostname *bool `json:"IsSystemHostname,omitempty"`
158 HasCertificate *bool `json:"HasCertificate,omitempty"`
159 }
160
161 // EdgeRule represents an EdgeRule.
162 // It is returned from the Get and List Pull Zone and passed to the AddorUpdateEdgeRule API Endpoints.
163 type EdgeRule struct {
164 GUID *string `json:"Guid,omitempty"`
165 ActionType *int `json:"ActionType,omitempty"`
166 ActionParameter1 *string `json:"ActionParameter1,omitempty"`
167 ActionParameter2 *string `json:"ActionParameter2,omitempty"`
168 Triggers []*EdgeRuleTrigger `json:"Triggers,omitempty"`
169 TriggerMatchingType *int `json:"TriggerMatchingType,omitempty"`
170 Description *string `json:"Description,omitempty"`
171 Enabled *bool `json:"Enabled,omitempty"`
172 }
173
174 // Get retrieves the Pull Zone with the given id.
175 //
176 // Bunny.net API docs: https://docs.bunny.net/reference/pullzonepublic_index2
177 func (s *PullZoneService) Get(ctx context.Context, id int64) (*PullZone, error) {
178 path := fmt.Sprintf("pullzone/%d", id)
179 return resourceGet[PullZone](ctx, s.client, path, nil)
180 }
181