A Golang SDK for interacting with the CacheFly CDN API v2.6.
v2.6 is the current target.
This SDK is designed to abstract the HTTP API layer and simplify working with CacheFly resources and can be used independently as golang package in your project or as the backend foundation for managing CacheFly resources.
🏷️ v1.1.0 latest
CacheFly CDN is the only CDN built for throughput, delivering rich-media content up to 158% more than other major CDNs.
-
Accounts
Manage your CacheFly account and child accounts, including 2FA settings. -
Services
Create, list, update, activate/deactivate services and control access/origin logging. -
Service Domains
Add, list, update, delete domains and signal readiness for validation. -
Service Rules
List and update routing/cache rules and fetch the JSON schema for custom rules. -
Service Options
View and save basic settings, manage legacy and ProtectServe API keys, and configure FTP. -
Image Optimization
Fetch, create, update and toggle image‐optimization configurations. -
Certificates
List, create, retrieve, and delete TLS certificates. -
Origins
Add, list, update, and remove origin servers. -
Users
Create, list, update, deactivate users and manage permissions + 2FA. -
Script Configs
Manage custom scripts: list, create, update, delete. -
TLS Profiles
Create and manage TLS profiles for your services. -
Delivery Regions
Discover available CDN delivery regions for service provisioning. -
Log Targets
Manage log target configurations and assign them to services for access/origin logging.
go get github.com/cachefly/cachefly-sdk-go@v1.1.0
Copy the snippet below into your project to get started:
client := cachefly.NewClient(cachefly.WithToken("YOUR_API_TOKEN"))
resp, _ := client.Accounts.List(ctx, api.ListAccountsOptions{Offset: 0, Limit: 5})
for _, a := range resp.Accounts {
fmt.Println(a.ID, a.CompanyName)
}Below is an example of how to use the CacheFly SDK in your Go project:
-
Create a
.envfile in your project root containing:CACHEFLY_API_TOKEN=your_real_api_token_here
-
Run with:
go run examples/<resource>/<example>.go
- List Accounts
- Get Current Account
- Get Account By ID
- Update Current Account
- Update Account By ID
- Create Child Account
- Activate Child Account
- Deactivate Child Account
- Get Child Account Auth Token
- Enable Two-Factor Authentication
- Disable Two-Factor Authentication
- List Services
- Get Service By ID
- Create Service
- Update Service By ID
- Activate Service
- Deactivate Service
- Enable Access Logging
- Disable Access Logging
- Enable Origin Logging
- Disable Origin Logging
- List Service Domains
- Get Service Domain By ID
- Create Service Domain
- Update Service Domain
- Delete Service Domain
- Signal Domain Validation Ready
- Get Service Options
- Save Service Options
- Get ProtectServe Key
- Regenerate ProtectServe Key
- Update ProtectServe Key Options
- Delete ProtectServe Key
- Get FTP Settings
- Regenerate FTP Password
- List Service Referer Rules
- Get Service Referer Rule By ID
- Create Service Referer Rule
- Update Service Referer Rule
- Delete Service Referer Rule
- Fetch Configuration
- Create Configuration
- Activate Configuration
- Deactivate Configuration
- Fetch Default Configuration
- Fetch Validation Schema
- List Users
- Get User By ID
- Create User
- Update User By ID
- Delete User By ID
- Get Current User
- Update Current User
- Activate User
- Deactivate User
- List Allowed Permissions
- List Script Configs
- Get Script Config By ID
- Create Script Config
- Update Script Config By ID
- Update Script Config Value As File
- Get Script Config Value As File
- Fetch Script Config JSON Schema
- Activate Script Config
- Deactivate Script Config
- List Account Script Config Definitions
- Get Script Config Definition By ID
- List Promo Script Config Definitions
The SDK includes unit tests at pkg/cachefly/api/v2_6.
go test -v -count=1 ./pkg/cachefly/api/v2_6This project is licensed under the MIT License - see the LICENSE file for details.