cmd

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute()

Execute runs the root command.

func NewAppContext

func NewAppContext(ctx context.Context, app *App) context.Context

NewAppContext returns a new context that carries the given App.

func NewRootCmd

func NewRootCmd() *cobra.Command

NewRootCmd creates and returns the root command with all subcommands registered.

func RefreshSkillsIfVersionChanged

func RefreshSkillsIfVersionChanged()

RefreshSkillsIfVersionChanged silently re-installs SKILL.md when the CLI version has changed since the last install. It is best-effort: no output on success, no error on failure. It is a no-op if the skill was never installed or the build is a dev build.

Types

type AccountAPI

type AccountAPI interface {
	ListApiKeys(ctx context.Context, page, perPage int) (pagination.PageResponse[*client.ApiKey], error)
	GetAuditLog(ctx context.Context, date string, opts client.AuditLogOptions) (*client.AuditLogResponse, error)
}

AccountAPI abstracts the bunny.net account API methods, allowing tests to inject mocks without making real API calls.

type App

type App struct {
	NewPullZoneAPI     func(cmd *cobra.Command) (PullZoneAPI, error)
	NewStorageZoneAPI  func(cmd *cobra.Command) (StorageZoneAPI, error)
	NewStorageAPI      func(cmd *cobra.Command, password, hostname string) (StorageAPI, error)
	NewDnsZoneAPI      func(cmd *cobra.Command) (DnsZoneAPI, error)
	NewVideoLibraryAPI func(cmd *cobra.Command) (VideoLibraryAPI, error)
	NewStreamAPI       func(cmd *cobra.Command) (StreamAPI, error)
	NewEdgeScriptAPI   func(cmd *cobra.Command) (EdgeScriptAPI, error)
	NewShieldAPI       func(cmd *cobra.Command) (ShieldAPI, error)
	NewAccountAPI      func(cmd *cobra.Command) (AccountAPI, error)
	NewBillingAPI      func(cmd *cobra.Command) (BillingAPI, error)
	NewStatisticsAPI   func(cmd *cobra.Command) (StatisticsAPI, error)
	NewRegionAPI       func(cmd *cobra.Command) (RegionAPI, error)
	NewCountryAPI      func(cmd *cobra.Command) (CountryAPI, error)
}

App holds all API factory functions, allowing commands to obtain API clients without relying on package-level variables.

func AppFromContext

func AppFromContext(ctx context.Context) *App

AppFromContext returns the App stored in ctx. If no App is set, it returns a non-nil zero-value App to prevent nil panics.

func DefaultApp

func DefaultApp() *App

DefaultApp returns an App with all factory functions wired to the production implementations (viper config + real bunny.net client).

type BillingAPI

type BillingAPI interface {
	GetBillingDetails(ctx context.Context) (*client.BillingDetails, error)
	GetBillingSummary(ctx context.Context) ([]*client.BillingSummaryItem, error)
	DownloadInvoice(ctx context.Context, billingRecordId int64) ([]byte, error)
}

BillingAPI abstracts the bunny.net billing API methods, allowing tests to inject mocks without making real API calls.

type CountryAPI

type CountryAPI interface {
	ListCountries(ctx context.Context) ([]*client.Country, error)
}

CountryAPI abstracts the bunny.net country API methods, allowing tests to inject mocks without making real API calls.

type DnsZoneAPI

type DnsZoneAPI interface {
	ListDnsZones(ctx context.Context, page, perPage int, search string) (pagination.PageResponse[*client.DnsZone], error)
	GetDnsZone(ctx context.Context, id int64) (*client.DnsZone, error)
	CreateDnsZone(ctx context.Context, body *client.DnsZoneCreate) (*client.DnsZone, error)
	UpdateDnsZone(ctx context.Context, id int64, body *client.DnsZoneUpdate) (*client.DnsZone, error)
	DeleteDnsZone(ctx context.Context, id int64) error
	AddDnsRecord(ctx context.Context, zoneId int64, body *client.DnsRecordCreate) (*client.DnsRecord, error)
	UpdateDnsRecord(ctx context.Context, zoneId, recordId int64, body *client.DnsRecordUpdate) error
	DeleteDnsRecord(ctx context.Context, zoneId, recordId int64) error
	ImportDnsZone(ctx context.Context, zoneId int64, data io.Reader) (*client.DnsZoneImportResult, error)
	ExportDnsZone(ctx context.Context, zoneId int64) ([]byte, error)
	EnableDnsSec(ctx context.Context, zoneId int64) (*client.DnsSecInfo, error)
	DisableDnsSec(ctx context.Context, zoneId int64) (*client.DnsSecInfo, error)
}

DnsZoneAPI abstracts the bunny.net DNS zone API methods, allowing tests to inject mocks without making real API calls.

type EdgeScriptAPI

type EdgeScriptAPI interface {
	// Scripts
	ListEdgeScripts(ctx context.Context, page, perPage int, search string, scriptTypes []int) (pagination.PageResponse[*client.EdgeScript], error)
	GetEdgeScript(ctx context.Context, id int64) (*client.EdgeScript, error)
	CreateEdgeScript(ctx context.Context, body *client.EdgeScriptCreate) (*client.EdgeScript, error)
	UpdateEdgeScript(ctx context.Context, id int64, body *client.EdgeScriptUpdate) (*client.EdgeScript, error)
	DeleteEdgeScript(ctx context.Context, id int64, deleteLinkedPullZones bool) error
	GetEdgeScriptStatistics(ctx context.Context, id int64, dateFrom, dateTo string, loadLatest, hourly bool) (*client.EdgeScriptStatistics, error)
	RotateEdgeScriptDeploymentKey(ctx context.Context, id int64) error

	// Code
	GetEdgeScriptCode(ctx context.Context, id int64) (*client.EdgeScriptCode, error)
	SetEdgeScriptCode(ctx context.Context, id int64, code string) error

	// Variables
	AddEdgeScriptVariable(ctx context.Context, scriptId int64, body *client.EdgeScriptVariableCreate) (*client.EdgeScriptVariable, error)
	GetEdgeScriptVariable(ctx context.Context, scriptId, variableId int64) (*client.EdgeScriptVariable, error)
	UpdateEdgeScriptVariable(ctx context.Context, scriptId, variableId int64, body *client.EdgeScriptVariableUpdate) error
	DeleteEdgeScriptVariable(ctx context.Context, scriptId, variableId int64) error

	// Secrets
	AddEdgeScriptSecret(ctx context.Context, scriptId int64, body *client.EdgeScriptSecretCreate) (*client.EdgeScriptSecret, error)
	ListEdgeScriptSecrets(ctx context.Context, scriptId int64) ([]*client.EdgeScriptSecret, error)
	UpdateEdgeScriptSecret(ctx context.Context, scriptId, secretId int64, body *client.EdgeScriptSecretUpdate) error
	DeleteEdgeScriptSecret(ctx context.Context, scriptId, secretId int64) error

	// Releases
	ListEdgeScriptReleases(ctx context.Context, scriptId int64, page, perPage int) (pagination.PageResponse[*client.EdgeScriptRelease], error)
	GetActiveEdgeScriptRelease(ctx context.Context, scriptId int64) (*client.EdgeScriptRelease, error)

	// Publish
	PublishEdgeScript(ctx context.Context, scriptId int64, body *client.EdgeScriptPublish) error
	PublishEdgeScriptRelease(ctx context.Context, scriptId int64, uuid string) error
}

EdgeScriptAPI abstracts the bunny.net Edge Scripting (compute) API methods, allowing tests to inject mocks without making real API calls.

type PullZoneAPI

type PullZoneAPI interface {
	ListPullZones(ctx context.Context, page, perPage int, search string) (pagination.PageResponse[*client.PullZone], error)
	GetPullZone(ctx context.Context, id int64) (*client.PullZone, error)
	CreatePullZone(ctx context.Context, body *client.PullZoneCreate) (*client.PullZone, error)
	UpdatePullZone(ctx context.Context, id int64, body *client.PullZoneUpdate) (*client.PullZone, error)
	DeletePullZone(ctx context.Context, id int64) error
	AddPullZoneHostname(ctx context.Context, id int64, hostname string) error
	RemovePullZoneHostname(ctx context.Context, id int64, hostname string) error
	PurgePullZoneCache(ctx context.Context, id int64, cacheTag string) error
	AddOrUpdateEdgeRule(ctx context.Context, pullZoneId int64, rule *client.EdgeRule) error
	DeleteEdgeRule(ctx context.Context, pullZoneId int64, edgeRuleId string) error
	SetEdgeRuleEnabled(ctx context.Context, pullZoneId int64, edgeRuleId string, enabled bool) error
}

PullZoneAPI abstracts the bunny.net pull zone API methods, allowing tests to inject mocks without making real API calls.

type RegionAPI

type RegionAPI interface {
	ListRegions(ctx context.Context) ([]*client.Region, error)
}

RegionAPI abstracts the bunny.net region API methods, allowing tests to inject mocks without making real API calls.

type ShieldAPI

type ShieldAPI interface {
	// Shield Zones
	ListShieldZones(ctx context.Context, page, perPage int) (pagination.PageResponse[*client.ShieldZone], error)
	GetShieldZone(ctx context.Context, id int64) (*client.ShieldZone, error)
	GetShieldZoneByPullZone(ctx context.Context, pullZoneId int64) (*client.ShieldZone, error)
	CreateShieldZone(ctx context.Context, body *client.ShieldZoneCreate) (*client.ShieldZoneResponse, error)
	UpdateShieldZone(ctx context.Context, id int64, body *client.ShieldZoneUpdate) (*client.ShieldZoneResponse, error)

	// WAF
	ListWafRules(ctx context.Context, shieldZoneId int64) ([]*client.WafRuleMainGroup, error)
	ListCustomWafRules(ctx context.Context, shieldZoneId int64, page, perPage int) (pagination.PageResponse[*client.CustomWafRule], error)
	GetCustomWafRule(ctx context.Context, id int64) (*client.CustomWafRule, error)
	CreateCustomWafRule(ctx context.Context, body *client.CustomWafRuleCreate) (*client.CustomWafRule, error)
	UpdateCustomWafRule(ctx context.Context, id int64, body *client.CustomWafRuleUpdate) (*client.CustomWafRule, error)
	DeleteCustomWafRule(ctx context.Context, id int64) error
	ListWafProfiles(ctx context.Context) ([]*client.WafProfile, error)
	GetWafEngineConfig(ctx context.Context) ([]client.WafConfigVariable, error)
	ListTriggeredWafRules(ctx context.Context, shieldZoneId int64) ([]*client.TriggeredRule, error)
	UpdateTriggeredWafRule(ctx context.Context, shieldZoneId int64, body *client.TriggeredRuleUpdate) error

	// Rate Limits
	ListRateLimits(ctx context.Context, shieldZoneId int64, page, perPage int) (pagination.PageResponse[*client.RateLimitRule], error)
	GetRateLimit(ctx context.Context, id int64) (*client.RateLimitRule, error)
	CreateRateLimit(ctx context.Context, body *client.RateLimitRuleCreate) (*client.RateLimitRule, error)
	UpdateRateLimit(ctx context.Context, id int64, body *client.RateLimitRuleUpdate) (*client.RateLimitRule, error)
	DeleteRateLimit(ctx context.Context, id int64) error

	// Access Lists
	ListAccessLists(ctx context.Context, shieldZoneId int64) (*client.AccessListsResponse, error)
	GetCustomAccessList(ctx context.Context, shieldZoneId, id int64) (*client.CustomAccessList, error)
	CreateCustomAccessList(ctx context.Context, shieldZoneId int64, body *client.CustomAccessListCreate) (*client.CustomAccessList, error)
	UpdateCustomAccessList(ctx context.Context, shieldZoneId, id int64, body *client.CustomAccessListUpdate) (*client.CustomAccessList, error)
	DeleteCustomAccessList(ctx context.Context, shieldZoneId, id int64) error
	UpdateAccessListConfig(ctx context.Context, shieldZoneId, configId int64, body *client.AccessListConfigUpdate) error

	// Bot Detection
	GetBotDetection(ctx context.Context, shieldZoneId int64) (*client.BotDetectionConfig, error)
	UpdateBotDetection(ctx context.Context, shieldZoneId int64, body *client.BotDetectionUpdate) error

	// Upload Scanning
	GetUploadScanning(ctx context.Context, shieldZoneId int64) (*client.UploadScanningConfig, error)
	UpdateUploadScanning(ctx context.Context, shieldZoneId int64, body *client.UploadScanningUpdate) error

	// Metrics
	GetShieldMetricsOverview(ctx context.Context, shieldZoneId int64) (*client.ShieldZoneMetrics, error)
	GetShieldMetricsDetailed(ctx context.Context, shieldZoneId int64, startDate, endDate string, resolution int) (*client.ShieldOverviewMetricsData, error)
	GetShieldRateLimitMetrics(ctx context.Context, shieldZoneId int64) ([]*client.ShieldZoneRateLimitMetrics, error)
	GetShieldRateLimitMetric(ctx context.Context, id int64) (*client.RatelimitMetrics, error)
	GetShieldWafRuleMetrics(ctx context.Context, shieldZoneId int64, ruleId int) (*client.WafRuleMetrics, error)
	GetShieldBotDetectionMetrics(ctx context.Context, shieldZoneId int64) (*client.ShieldZoneBotDetectionMetrics, error)
	GetShieldUploadScanningMetrics(ctx context.Context, shieldZoneId int64) (*client.ShieldZoneUploadScanningMetrics, error)

	// Event Logs
	GetShieldEventLogs(ctx context.Context, shieldZoneId int64, date, continuationToken string) (*client.EventLogResponse, error)
}

ShieldAPI abstracts the bunny.net Shield (security) API methods, allowing tests to inject mocks without making real API calls.

type StatisticsAPI

type StatisticsAPI interface {
	GetStatistics(ctx context.Context, opts client.StatisticsOptions) (*client.Statistics, error)
}

StatisticsAPI abstracts the bunny.net statistics API methods, allowing tests to inject mocks without making real API calls.

type StorageAPI

type StorageAPI interface {
	ListFiles(ctx context.Context, zoneName, path string) ([]client.StorageObject, error)
	DownloadFile(ctx context.Context, zoneName, path string) (io.ReadCloser, int64, error)
	UploadFile(ctx context.Context, zoneName, path string, body io.Reader, size int64, checksum string) error
	DeleteFile(ctx context.Context, zoneName, path string) error
}

StorageAPI abstracts the bunny.net Edge Storage API methods, allowing tests to inject mocks without making real API calls.

type StorageZoneAPI

type StorageZoneAPI interface {
	ListStorageZones(ctx context.Context, page, perPage int, search string, includeDeleted bool) (pagination.PageResponse[*client.StorageZone], error)
	GetStorageZone(ctx context.Context, id int64) (*client.StorageZone, error)
	CreateStorageZone(ctx context.Context, body *client.StorageZoneCreate) (*client.StorageZone, error)
	UpdateStorageZone(ctx context.Context, id int64, body *client.StorageZoneUpdate) error
	DeleteStorageZone(ctx context.Context, id int64, deleteLinkedPullZones bool) error
	ResetStorageZonePassword(ctx context.Context, id int64) error
	ResetStorageZoneReadOnlyPassword(ctx context.Context, id int64) error
	FindStorageZoneByName(ctx context.Context, name string) (*client.StorageZone, error)
}

StorageZoneAPI abstracts the bunny.net storage zone API methods, allowing tests to inject mocks without making real API calls.

type StreamAPI

type StreamAPI interface {
	// Videos
	ListVideos(ctx context.Context, libraryId int64, page, itemsPerPage int, search, collection, orderBy string) (pagination.PageResponse[*client.Video], error)
	GetVideo(ctx context.Context, libraryId int64, videoId string) (*client.Video, error)
	CreateVideo(ctx context.Context, libraryId int64, body *client.VideoCreate) (*client.Video, error)
	UpdateVideo(ctx context.Context, libraryId int64, videoId string, body *client.VideoUpdate) error
	DeleteVideo(ctx context.Context, libraryId int64, videoId string) error
	UploadVideo(ctx context.Context, libraryId int64, videoId string, body io.Reader, size int64) error
	FetchVideo(ctx context.Context, libraryId int64, body *client.VideoFetch, collectionId string, thumbnailTime int) (*client.StatusModel, error)
	ReencodeVideo(ctx context.Context, libraryId int64, videoId string) (*client.Video, error)
	TranscribeVideo(ctx context.Context, libraryId int64, videoId string, settings *client.TranscribeSettings) error

	// Collections
	ListCollections(ctx context.Context, libraryId int64, page, itemsPerPage int, search, orderBy string) (pagination.PageResponse[*client.Collection], error)
	GetCollection(ctx context.Context, libraryId int64, collectionId string) (*client.Collection, error)
	CreateCollection(ctx context.Context, libraryId int64, body *client.CollectionCreate) (*client.Collection, error)
	UpdateCollection(ctx context.Context, libraryId int64, collectionId string, body *client.CollectionUpdate) error
	DeleteCollection(ctx context.Context, libraryId int64, collectionId string) error

	// Captions
	AddCaption(ctx context.Context, libraryId int64, videoId, srclang string, body *client.CaptionAdd) error
	DeleteCaption(ctx context.Context, libraryId int64, videoId, srclang string) error

	// Statistics
	GetVideoStatistics(ctx context.Context, libraryId int64, dateFrom, dateTo string, hourly bool, videoGuid string) (*client.VideoStatistics, error)
	GetVideoHeatmap(ctx context.Context, libraryId int64, videoId string) (*client.VideoHeatmap, error)
}

StreamAPI abstracts the bunny.net Stream (video) API methods, allowing tests to inject mocks without making real API calls.

type VideoLibraryAPI

type VideoLibraryAPI interface {
	ListVideoLibraries(ctx context.Context, page, perPage int, search string) (pagination.PageResponse[*client.VideoLibrary], error)
	GetVideoLibrary(ctx context.Context, id int64) (*client.VideoLibrary, error)
	CreateVideoLibrary(ctx context.Context, body *client.VideoLibraryCreate) (*client.VideoLibrary, error)
	UpdateVideoLibrary(ctx context.Context, id int64, body *client.VideoLibraryUpdate) (*client.VideoLibrary, error)
	DeleteVideoLibrary(ctx context.Context, id int64) error
	ResetVideoLibraryApiKey(ctx context.Context, id int64) error
	ListVideoLibraryLanguages(ctx context.Context) ([]client.VideoLibraryLanguage, error)
}

VideoLibraryAPI abstracts the bunny.net video library API methods, allowing tests to inject mocks without making real API calls.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL