controld

package module
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2024 License: MIT Imports: 20 Imported by: 0

README

controld-go

controld-go allows you to interact with Control D's API in Go. (obviously)
Report bug · Request feature

GitHub Tag Go Reference Go Report Card

Quick start

go get github.com/baptistecdr/controld-go
package main

import (
	"context"
	"fmt"
	"log"
	"os"

	"github.com/baptistecdr/controld-go"
)

func main() {
	// Construct a new API object using an API token
	api, err := controld.New(os.Getenv("CONTROLD_API_TOKEN"))
	if err != nil {
		log.Fatal(err)
	}

	// Most API calls require a Context
	ctx := context.Background()

	// Fetch details of the account
	u, err := api.ListUser(ctx)
	if err != nil {
		log.Fatal(err)
	}
	// Print user details
	fmt.Println(u)
}

Bugs and feature requests

Have a bug or a feature request? Please first search for existing and closed issues. If your problem or idea is not addressed yet, please open a new issue.

Contributing

Contributions are welcome!

Thanks to

Documentation

Index

Constants

View Source
const (
	Pending      = 0
	Active       = 1
	SoftDisabled = 2
	HardDisabled = 3
)
View Source
const (
	Block    = 0
	Bypass   = 1
	Spoof    = 2
	Redirect = 3
)

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	APIToken  string
	BaseURL   string
	UserAgent string

	Debug bool
	// contains filtered or unexported fields
}

API holds the configuration for the current API client. A client should not be modified concurrently.

func New

func New(token string, opts ...Option) (*API, error)

func (*API) CreateDevice

func (api *API) CreateDevice(ctx context.Context, params CreateDeviceParams) (Device, error)

func (*API) CreateProfile

func (api *API) CreateProfile(ctx context.Context, params CreateProfileParams) ([]Profile, error)

func (*API) CreateProfileCustomRule

func (api *API) CreateProfileCustomRule(ctx context.Context, params CreateProfileCustomRuleParams) ([]CustomRule, error)

func (*API) CreateProfileRuleFolder

func (api *API) CreateProfileRuleFolder(ctx context.Context, params CreateProfileRuleFolderParams) ([]Group, error)

func (*API) DeleteDevice

func (api *API) DeleteDevice(ctx context.Context, params DeleteDeviceParams) ([]any, error)

func (*API) DeleteLearnedIPs

func (api *API) DeleteLearnedIPs(ctx context.Context, params DeleteLearnedIPsParams) ([]any, error)

func (*API) DeleteProfile

func (api *API) DeleteProfile(ctx context.Context, params DeleteProfileParams) ([]any, error)

func (*API) DeleteProfileCustomRule

func (api *API) DeleteProfileCustomRule(ctx context.Context, params DeleteProfileCustomRuleParams) (any, error)

func (*API) DeleteProfileRuleFolder

func (api *API) DeleteProfileRuleFolder(ctx context.Context, params DeleteProfileRuleFolderParams) (any, error)

func (*API) LearnNewIPs

func (api *API) LearnNewIPs(ctx context.Context, params LearnNewIPsParams) ([]any, error)

func (*API) ListDeviceType

func (api *API) ListDeviceType(ctx context.Context) (DeviceTypes, error)

func (*API) ListDevices

func (api *API) ListDevices(ctx context.Context) ([]Device, error)

func (*API) ListIP

func (api *API) ListIP(ctx context.Context) (IP, error)

func (*API) ListKnownIPs

func (api *API) ListKnownIPs(ctx context.Context, params ListKnownIPsParams) ([]KnownIP, error)

func (*API) ListLogLevels

func (api *API) ListLogLevels(ctx context.Context) ([]LogLevel, error)

func (*API) ListNetwork

func (api *API) ListNetwork(ctx context.Context) ([]Network, error)

func (*API) ListProfileCustomRules

func (api *API) ListProfileCustomRules(ctx context.Context, params ListProfileCustomRulesParams) ([]Rule, error)

func (*API) ListProfileDefaultRule

func (api *API) ListProfileDefaultRule(ctx context.Context, params ListProfileDefaultRuleParams) (DefaultRule, error)

func (*API) ListProfileExternalFilters

func (api *API) ListProfileExternalFilters(ctx context.Context, params ListProfileFiltersParams) ([]Filter, error)

func (*API) ListProfileNativeFilters

func (api *API) ListProfileNativeFilters(ctx context.Context, params ListProfileFiltersParams) ([]Filter, error)

func (*API) ListProfileRuleFolders

func (api *API) ListProfileRuleFolders(ctx context.Context, params ListProfileRuleFoldersParams) ([]Group, error)

func (*API) ListProfileServices

func (api *API) ListProfileServices(ctx context.Context, params ListProfileServicesParams) ([]ProfileService, error)

func (*API) ListProfiles

func (api *API) ListProfiles(ctx context.Context) ([]Profile, error)

func (*API) ListProfilesOptions

func (api *API) ListProfilesOptions(ctx context.Context) ([]ProfilesOption, error)

func (*API) ListServiceCategories

func (api *API) ListServiceCategories(ctx context.Context) ([]Category, error)

func (*API) ListServices

func (api *API) ListServices(ctx context.Context, params ListServicesParams) ([]Service, error)

func (*API) ListStorageRegions

func (api *API) ListStorageRegions(ctx context.Context) ([]Endpoint, error)

func (*API) ListUser

func (api *API) ListUser(ctx context.Context) (User, error)

func (*API) Raw

func (api *API) Raw(ctx context.Context, method, endpoint string, data interface{}, headers http.Header) (RawResponse, error)

Raw makes an HTTP request with user provided params and returns the result as a RawResponse, which contains the untouched JSON result.

func (*API) UpdateDevice

func (api *API) UpdateDevice(ctx context.Context, params UpdateDeviceParams) (Device, error)

func (*API) UpdateProfile

func (api *API) UpdateProfile(ctx context.Context, params UpdateProfileParams) ([]Profile, error)

func (*API) UpdateProfileCustomRule

func (api *API) UpdateProfileCustomRule(ctx context.Context, params UpdateProfileCustomRuleParams) ([]CustomRule, error)

func (*API) UpdateProfileDefaultRule

func (api *API) UpdateProfileDefaultRule(ctx context.Context, params UpdateProfileDefaultRuleParams) (DefaultRule, error)

func (*API) UpdateProfileFilter

func (api *API) UpdateProfileFilter(ctx context.Context, params UpdateProfileFilterParams) (any, error)

func (*API) UpdateProfileRuleFolder

func (api *API) UpdateProfileRuleFolder(ctx context.Context, params UpdateProfileRuleFolderParams) ([]Group, error)

func (*API) UpdateProfileService

func (api *API) UpdateProfileService(ctx context.Context, params UpdateProfileServiceParams) ([]Action, error)

func (*API) UpdateProfilesOption

func (api *API) UpdateProfilesOption(ctx context.Context, params UpdateProfilesOption) (any, error)

type APIResponse

type APIResponse struct {
	Body       []byte
	Status     string
	StatusCode int
	Headers    http.Header
}

APIResponse holds the structure for a response from the API. It looks alot like `http.Response` however, uses a `[]byte` for the `Body` instead of a `io.ReadCloser`.

This may go away in the experimental client in favour of `http.Response`.

type Action

type Action struct {
	Do     DoType  `json:"do"`
	Status IntBool `json:"status"`
	Via    *string `json:"via,omitempty"`
	ViaV6  *string `json:"via_v6,omitempty"`
	Group  *int    `json:"group,omitempty"`
	Order  *int    `json:"order,omitempty"`
}

type AnalyticsLevel

type AnalyticsLevel int
const (
	Off   AnalyticsLevel = 0
	Basic AnalyticsLevel = 1
	Full  AnalyticsLevel = 2
)

type AuthenticationError

type AuthenticationError struct {
	// contains filtered or unexported fields
}

AuthenticationError is for HTTP 401 responses.

func NewAuthenticationError

func NewAuthenticationError(e *Error) AuthenticationError

func (AuthenticationError) Error

func (e AuthenticationError) Error() string

func (AuthenticationError) InternalErrorCodeIs

func (e AuthenticationError) InternalErrorCodeIs(code int) bool

func (AuthenticationError) Type

func (e AuthenticationError) Type() ErrorType

type AuthorizationError

type AuthorizationError struct {
	// contains filtered or unexported fields
}

AuthorizationError is for HTTP 403 responses.

func NewAuthorizationError

func NewAuthorizationError(e *Error) AuthorizationError

func (AuthorizationError) Error

func (e AuthorizationError) Error() string

func (AuthorizationError) InternalErrorCodeIs

func (e AuthorizationError) InternalErrorCodeIs(code int) bool

func (AuthorizationError) Type

func (e AuthorizationError) Type() ErrorType

type Browser

type Browser struct {
	Name  string  `json:"name"`
	Icons OSIcons `json:"icons"`
}

type BrowserIcons

type BrowserIcons struct {
	BrowserChrome  Icon `json:"browser-chrome"`
	BrowserFirefox Icon `json:"browser-firefox"`
	BrowserEdge    Icon `json:"browser-edge"`
	BrowserBrave   Icon `json:"browser-brave"`
	BrowserOther   Icon `json:"browser-other"`
}

type Category

type Category struct {
	PK          string `json:"PK"`
	Name        string `json:"name"`
	Description string `json:"description"`
	Count       int    `json:"count"`
}

type CreateDeviceParams

type CreateDeviceParams struct {
	Name             string          `json:"name"`
	ProfileID        string          `json:"profile_id"`
	ProfileID2       *string         `json:"profile_id2,omitempty"`
	Icon             IconName        `json:"icon"`
	Stats            *AnalyticsLevel `json:"stats,omitempty"`
	LegacyIPv4Status *IntBool        `json:"legacy_ipv4_status,omitempty"`
	LearnIP          *IntBool        `json:"learn_ip,omitempty"`
	Restricted       *IntBool        `json:"restricted,omitempty"`
	Desc             *string         `json:"desc,omitempty"`
	DDNSStatus       *IntBool        `json:"ddns_status,omitempty"`
	DDNSSubdomain    *string         `json:"ddns_subdomain,omitempty"`
	DDNSExtStatus    *IntBool        `json:"ddns_ext_host,omitempty"`
	DDNSExtHost      *string         `json:"ddns_ext_status,omitempty"`
	RemapDeviceID    *string         `json:"remap_device_id,omitempty"`
	RemapClientID    *string         `json:"remap_client_id,omitempty"`
}

type CreateDeviceResponse

type CreateDeviceResponse struct {
	Body Device `json:"body"`
	Response
}

type CreateProfileBody

type CreateProfileBody struct {
	Profiles []Profile `json:"profiles"`
}

type CreateProfileCustomRuleBody

type CreateProfileCustomRuleBody struct {
	Rules []CustomRule `json:"rules"`
}

type CreateProfileCustomRuleParams

type CreateProfileCustomRuleParams struct {
	ProfileID string   `json:"profile_id"`
	Do        DoType   `json:"do"`
	Status    IntBool  `json:"status"`
	Via       *string  `json:"via,omitempty"`
	ViaV6     *string  `json:"via_v6,omitempty"`
	Group     *int     `json:"group,omitempty"`
	Hostnames []string `json:"hostnames"`
}

type CreateProfileCustomRuleResponse

type CreateProfileCustomRuleResponse struct {
	Body CreateProfileCustomRuleBody `json:"body"`
	Response
}

type CreateProfileParams

type CreateProfileParams struct {
	Name           string  `json:"name"`
	CloneProfileID *string `json:"clone_profile_id"`
}

type CreateProfileResponse

type CreateProfileResponse struct {
	Body ListProfilesBody `json:"body"`
	Response
}

type CreateProfileRuleFolderBody

type CreateProfileRuleFolderBody struct {
	Groups []Group `json:"groups"`
}

type CreateProfileRuleFolderParams

type CreateProfileRuleFolderParams struct {
	ProfileID string   `json:"profile_id"`
	Name      string   `json:"name"`
	Do        *DoType  `json:"do,omitempty"`
	Via       *string  `json:"via,omitempty"`
	Status    *IntBool `json:"status,omitempty"`
}

type CreateProfileRuleFolderResponse

type CreateProfileRuleFolderResponse struct {
	Body CreateProfileRuleFolderBody `json:"body"`
	Response
}

type CustomRule

type CustomRule Action

type DDNS

type DDNS struct {
	Status    int    `json:"status"`
	Subdomain string `json:"subdomain"`
	Hostname  string `json:"hostname"`
	Record    string `json:"record"`
}

type DDNSExt

type DDNSExt struct {
	Status int    `json:"status"`
	Host   string `json:"host"`
}

type Date

type Date struct {
	time.Time
}

func (Date) MarshalJSON

func (s Date) MarshalJSON() ([]byte, error)

func (*Date) UnmarshalJSON

func (s *Date) UnmarshalJSON(data []byte) error

type DateTime

type DateTime struct {
	time.Time
}

func (DateTime) MarshalJSON

func (dt DateTime) MarshalJSON() ([]byte, error)

func (*DateTime) UnmarshalJSON

func (dt *DateTime) UnmarshalJSON(data []byte) error

type DefaultRule

type DefaultRule Action

type DeleteDeviceParams

type DeleteDeviceParams struct {
	DeviceID string `json:"device-id"`
}

type DeleteDeviceResponse

type DeleteDeviceResponse struct {
	Body    []any  `json:"body"`
	Message string `json:"message"`
	Response
}

type DeleteLearnedIPsParams

type DeleteLearnedIPsParams struct {
	DeviceID string   `json:"device_id"`
	IPs      []net.IP `json:"ips"`
}

type DeleteLearnedIPsResponse

type DeleteLearnedIPsResponse struct {
	Body []any `json:"body"`
	Response
	Message string `json:"message"`
}

type DeleteProfileCustomRuleParams

type DeleteProfileCustomRuleParams struct {
	ProfileID string `json:"profile_id"`
	Hostname  string `json:"hostname"`
}

type DeleteProfileCustomRuleResponse

type DeleteProfileCustomRuleResponse struct {
	Body any `json:"body"`
	Response
}

type DeleteProfileParams

type DeleteProfileParams struct {
	ProfileID string `json:"profile_id"`
}

type DeleteProfileResponse

type DeleteProfileResponse struct {
	Body    []any  `json:"body"`
	Message string `json:"message"`
	Response
}

type DeleteProfileRuleFolderParams

type DeleteProfileRuleFolderParams struct {
	ProfileID string `json:"profile_id"`
	FolderID  string `json:"folder"`
}

type DeleteProfileRuleFolderResponse

type DeleteProfileRuleFolderResponse struct {
	Body any `json:"body"`
	Response
}

type DeleteProfileServiceBody

type DeleteProfileServiceBody struct {
	Services []Action `json:"services"`
}

type DeleteProfileServiceParams

type DeleteProfileServiceParams struct {
	ProfileID string `json:"profile_id"`
	Hostname  string `json:"hostname"`
}

type DeleteProfileServiceResponse

type DeleteProfileServiceResponse struct {
	Body DeleteProfileServiceBody `json:"body"`
	Response
}

type Device

type Device struct {
	PK         string          `json:"PK"`
	Ts         UnixTime        `json:"ts"`
	Name       string          `json:"name"`
	User       string          `json:"user"`
	Stats      *AnalyticsLevel `json:"stats,omitempty"`
	DeviceID   string          `json:"device_id"`
	Status     DeviceStatus    `json:"status"`
	Restricted *IntBool        `json:"restricted,omitempty"`
	LearnIP    IntBool         `json:"learn_ip"`
	Desc       string          `json:"desc"`
	DDNS       *DDNS           `json:"ddns,omitempty"`
	Resolvers  Resolvers       `json:"resolvers"`
	LegacyIPv4 LegacyIPv4      `json:"legacy_ipv4"`
	Profile    Profile         `json:"profile"`
	Icon       *IconName       `json:"icon"`
}

type DeviceStatus

type DeviceStatus int

type DeviceTypes

type DeviceTypes struct {
	OS      OS      `json:"os"`
	Browser Browser `json:"browser"`
	TV      TV      `json:"tv"`
	Router  Router  `json:"router"`
}

type DoType

type DoType int

type Endpoint

type Endpoint struct {
	PK          string `json:"PK"`
	Title       string `json:"title"`
	CountryCode string `json:"country_code"`
}

type Error

type Error struct {
	// The classification of error encountered.
	Type ErrorType

	// StatusCode is the HTTP status code from the response.
	StatusCode int

	// Errors is all of the error messages and codes, combined.
	Error ResponseInfo
}

func (*Error) ClientError

func (e *Error) ClientError() bool

ClientError returns a boolean whether or not the raised error was caused by something client side.

func (*Error) ClientRateLimited

func (e *Error) ClientRateLimited() bool

ClientRateLimited returns a boolean whether or not the raised error was caused by too many requests from the client.

func (*Error) InternalErrorCodeIs

func (e *Error) InternalErrorCodeIs(code int) bool

InternalErrorCodeIs returns a boolean whether or not the desired internal error code is present in `e.InternalErrorCodes`.

type ErrorType

type ErrorType string
const (
	ErrorTypeRequest        ErrorType = "request"
	ErrorTypeAuthentication ErrorType = "authentication"
	ErrorTypeAuthorization  ErrorType = "authorization"
	ErrorTypeNotFound       ErrorType = "not_found"
	ErrorTypeRateLimit      ErrorType = "rate_limit"
)

type Filter

type Filter struct {
	PK          string           `json:"PK"`
	Name        string           `json:"name"`
	Description string           `json:"description"`
	Additional  *string          `json:"additional,omitempty"`
	Sources     []string         `json:"sources"`
	Levels      []FilterLevel    `json:"levels,omitempty"`
	Status      IntBool          `json:"status"`
	Resolvers   *FilterResolvers `json:"resolvers,omitempty"`
}

type FilterLevel

type FilterLevel struct {
	Title  string  `json:"title"`
	Type   string  `json:"type"`
	Name   string  `json:"name"`
	Status IntBool `json:"status"`
	Opt    []Opt   `json:"opt,omitempty"`
}

type FilterResolvers

type FilterResolvers struct {
	V4 []net.IP `json:"v4"`
	V6 []net.IP `json:"v6"`
}

type Group

type Group struct {
	PK     int         `json:"PK"`
	Group  string      `json:"group"`
	Action GroupAction `json:"action"`
	Count  int         `json:"count"`
}

type GroupAction

type GroupAction struct {
	Status IntBool `json:"status"`
	Do     *DoType `json:"do,omitempty"`
}

type IP

type IP struct {
	IP      net.IP `json:"ip"`
	Type    string `json:"type"`
	Org     string `json:"org"`
	Country string `json:"country"`
	Handler string `json:"handler"`
	Pop     string `json:"pop"`
}

type Icon

type Icon struct {
	Name string `json:"name"`
}

type IconName

type IconName string
const (
	DesktopWindows    IconName = "desktop-windows"
	DesktopMac        IconName = "desktop-mac"
	DesktopLinux      IconName = "desktop-linux"
	MobileIOS         IconName = "mobile-ios"
	MobileAndroid     IconName = "mobile-android"
	BrowserChrome     IconName = "browser-chrome"
	BrowserFirefox    IconName = "browser-firefox"
	BrowserEdge       IconName = "browser-edge"
	BrowserBrave      IconName = "browser-brave"
	BrowserOther      IconName = "browser-other"
	TVApple           IconName = "tv-apple"
	TVAndroid         IconName = "tv-android"
	TVFireTV          IconName = "tv-firetv"
	TVSamsung         IconName = "tv-samsung"
	TVOther           IconName = "tv"
	RouterAsus        IconName = "router-asus"
	RouterDDWRT       IconName = "router-ddwrt"
	RouterFirewalla   IconName = "router-firewalla"
	RouterFreshTomato IconName = "router-freshtomato"
	RouterGLiNET      IconName = "router-glinet"
	RouterOpenWRT     IconName = "router-openwrt"
	RouterOPNsense    IconName = "router-opnsense"
	RouterPfSense     IconName = "router-pfsense"
	RouterSynology    IconName = "router-synology"
	RouterUbiquiti    IconName = "router-ubiquiti"
	RouterWindows     IconName = "router-windows"
	RouterLinux       IconName = "router-linux"
	RouterOther       IconName = "router"
)

type IntBool

type IntBool struct {
	// contains filtered or unexported fields
}

func (IntBool) MarshalJSON

func (s IntBool) MarshalJSON() ([]byte, error)

func (*IntBool) UnmarshalJSON

func (s *IntBool) UnmarshalJSON(data []byte) error

type KnownIP

type KnownIP struct {
	IP      net.IP   `json:"ip"`
	Ts      UnixTime `json:"ts"`
	Country string   `json:"country"`
	City    string   `json:"city"`
	ISP     string   `json:"isp"`
	Asn     int      `json:"asn"`
	AsName  string   `json:"as_name"`
}

type LearnNewIPsParams

type LearnNewIPsParams struct {
	DeviceID string   `json:"device_id"`
	IPs      []net.IP `json:"ips"`
}

type LearnNewIPsResponse

type LearnNewIPsResponse struct {
	Body []any `json:"body"`
	Response
	Message string `json:"message"`
}

type LegacyIPv4

type LegacyIPv4 struct {
	Resolver string  `json:"resolver"`
	Status   IntBool `json:"status"`
}

type ListDeviceTypesBody

type ListDeviceTypesBody struct {
	Types DeviceTypes `json:"types"`
}

type ListDeviceTypesResponse

type ListDeviceTypesResponse struct {
	Body ListDeviceTypesBody `json:"body"`
	Response
}

type ListDevicesBody

type ListDevicesBody struct {
	Devices []Device `json:"devices"`
}

type ListDevicesResponse

type ListDevicesResponse struct {
	Body ListDevicesBody `json:"body"`
	Response
}

type ListIPResponse

type ListIPResponse struct {
	Body IP `json:"body"`
	Response
}

type ListKnownIPsBody

type ListKnownIPsBody struct {
	IPs []KnownIP `json:"ips"`
}

type ListKnownIPsParams

type ListKnownIPsParams struct {
	DeviceID string `json:"device_id"`
}

type ListKnownIPsResponse

type ListKnownIPsResponse struct {
	Body ListKnownIPsBody `json:"body"`
	Response
}

type ListLogLevelsBody

type ListLogLevelsBody struct {
	Levels []LogLevel `json:"levels"`
}

type ListLogLevelsResponse

type ListLogLevelsResponse struct {
	Body ListLogLevelsBody `json:"body"`
	Response
}

type ListNetworkBody

type ListNetworkBody struct {
	Network    []Network `json:"network"`
	Time       UnixTime  `json:"time"`
	CurrentPop string    `json:"current_pop"`
}

type ListNetworkResponse

type ListNetworkResponse struct {
	Body ListNetworkBody `json:"body"`
	Response
}

type ListProfileCustomRulesBody

type ListProfileCustomRulesBody struct {
	Rules []Rule `json:"rules"`
}

type ListProfileCustomRulesParams

type ListProfileCustomRulesParams struct {
	ProfileID string `json:"profile_id"`
	FolderID  string `json:"folder_id"`
}

type ListProfileCustomRulesResponse

type ListProfileCustomRulesResponse struct {
	Body ListProfileCustomRulesBody `json:"body"`
	Response
}

type ListProfileDefaultRuleBody

type ListProfileDefaultRuleBody struct {
	Default any `json:"default"`
}

type ListProfileDefaultRuleParams

type ListProfileDefaultRuleParams struct {
	ProfileID string `json:"profile_id"`
}

type ListProfileDefaultRuleResponse

type ListProfileDefaultRuleResponse struct {
	Body ListProfileDefaultRuleBody `json:"body"`
	Response
}

type ListProfileFiltersBody

type ListProfileFiltersBody struct {
	Filters []Filter `json:"filters"`
}

type ListProfileFiltersParams

type ListProfileFiltersParams struct {
	ProfileID string `json:"profile_id"`
}

type ListProfileFiltersResponse

type ListProfileFiltersResponse struct {
	Body ListProfileFiltersBody `json:"body"`
	Response
}

type ListProfileRuleFoldersBody

type ListProfileRuleFoldersBody struct {
	Groups []Group `json:"groups"`
}

type ListProfileRuleFoldersParams

type ListProfileRuleFoldersParams struct {
	ProfileID string `json:"profile_id"`
}

type ListProfileRuleFoldersResponse

type ListProfileRuleFoldersResponse struct {
	Body ListProfileRuleFoldersBody `json:"body"`
	Response
}

type ListProfileServicesBody

type ListProfileServicesBody struct {
	Services []ProfileService `json:"services"`
}

type ListProfileServicesParams

type ListProfileServicesParams struct {
	ProfileID string `json:"profile_id"`
}

type ListProfileServicesResponse

type ListProfileServicesResponse struct {
	Body ListProfileServicesBody `json:"body"`
	Response
}

type ListProfilesBody

type ListProfilesBody struct {
	Profiles []Profile `json:"profiles"`
}

type ListProfilesOptionsBody

type ListProfilesOptionsBody struct {
	Options []ProfilesOption `json:"options"`
}

type ListProfilesOptionsResponse

type ListProfilesOptionsResponse struct {
	Body ListProfilesOptionsBody `json:"body"`
	Response
}

type ListProfilesResponse

type ListProfilesResponse struct {
	Body ListProfilesBody `json:"body"`
	Response
}

type ListServiceCategoriesBody

type ListServiceCategoriesBody struct {
	Categories []Category `json:"categories"`
}

type ListServiceCategoriesResponse

type ListServiceCategoriesResponse struct {
	Body ListServiceCategoriesBody `json:"body"`
	Response
}

type ListServicesBody

type ListServicesBody struct {
	Services []Service `json:"services"`
}

type ListServicesParams

type ListServicesParams struct {
	Category string `json:"category"`
}

type ListServicesResponse

type ListServicesResponse struct {
	Body ListServicesBody `json:"body"`
	Response
}

type ListStorageRegionsBody

type ListStorageRegionsBody struct {
	Endpoint []Endpoint `json:"endpoints"`
}

type ListStorageRegionsResponse

type ListStorageRegionsResponse struct {
	Body ListStorageRegionsBody `json:"body"`
	Response
}

type ListUserResponse

type ListUserResponse struct {
	Body User `json:"body"`
	Response
}

type Location

type Location struct {
	Lat  float64 `json:"lat"`
	Long float64 `json:"long"`
}

type LogLevel

type LogLevel struct {
	PK    AnalyticsLevel `json:"PK"`
	Title string         `json:"title"`
}

type Logger

type Logger interface {
	Printf(format string, v ...interface{})
}

Logger defines the interface this library needs to use logging This is a subset of the methods implemented in the log package.

type Network

type Network struct {
	IataCode    string   `json:"iata_code"`
	CityName    string   `json:"city_name"`
	CountryName string   `json:"country_name"`
	Location    Location `json:"location"`
	Status      Status   `json:"status"`
}

type NotFoundError

type NotFoundError struct {
	// contains filtered or unexported fields
}

NotFoundError is for HTTP 404 responses.

func NewNotFoundError

func NewNotFoundError(e *Error) NotFoundError

func (NotFoundError) Error

func (e NotFoundError) Error() string

func (NotFoundError) InternalErrorCodeIs

func (e NotFoundError) InternalErrorCodeIs(code int) bool

func (NotFoundError) Type

func (e NotFoundError) Type() ErrorType

type OS

type OS struct {
	Name  string  `json:"name"`
	Icons OSIcons `json:"icons"`
}

type OSIcons

type OSIcons struct {
	MobileIos      Icon `json:"mobile-ios"`
	MobileAndroid  Icon `json:"mobile-android"`
	DesktopWindows Icon `json:"desktop-windows"`
	DesktopMac     Icon `json:"desktop-mac"`
	DesktopLinux   Icon `json:"desktop-linux"`
}

type Opt

type Opt struct {
	PK    string `json:"PK"`
	Value any    `json:"value"`
}

type Option

type Option func(*API) error

Option is a functional option for configuring the API client.

func BaseURL

func BaseURL(baseURL string) Option

BaseURL allows you to override the default HTTP base URL used for API calls.

func Debug

func Debug(debug bool) Option

func HTTPClient

func HTTPClient(client *http.Client) Option

HTTPClient accepts a custom *http.Client for making API calls.

func Headers

func Headers(headers http.Header) Option

Headers allows you to set custom HTTP headers when making API calls (e.g. for satisfying HTTP proxies, or for debugging).

func UserAgent

func UserAgent(userAgent string) Option

UserAgent can be set if you want to send a software name and version for HTTP access logs. It is recommended to set it in order to help future Customer Support diagnostics and prevent collateral damage by sharing generic User-Agent string with abusive users. E.g. "my-software/1.2.3". By default generic Go User-Agent is used.

func UsingLogger

func UsingLogger(logger Logger) Option

UsingLogger can be set if you want to get log output from this API instance By default no log output is emitted.

func UsingRateLimit

func UsingRateLimit(rps float64) Option

UsingRateLimit applies a non-default rate limit to client API requests If not specified the default of 4rps will be applied.

func UsingRetryPolicy

func UsingRetryPolicy(maxRetries int, minRetryDelaySecs int, maxRetryDelaySecs int) Option

UsingRetryPolicy applies a non-default number of retries and min/max retry delays This will be used when the client exponentially backs off after errored requests.

type Profile

type Profile struct {
	PK      string   `json:"PK"`
	Updated UnixTime `json:"updated"`
	Name    string   `json:"name"`
}

type ProfileOptionType

type ProfileOptionType string
const (
	Dropdown ProfileOptionType = "dropdown"
	Field    ProfileOptionType = "field"
	Toggle   ProfileOptionType = "toggle"
)

type ProfileService

type ProfileService struct {
	PK             string   `json:"PK"`
	Name           string   `json:"name"`
	Category       string   `json:"category"`
	UnlockLocation string   `json:"unlock_location"`
	Locations      []string `json:"locations,omitempty"`
	Action         Action   `json:"action"`
	Warning        *string  `json:"warning,omitempty"`
}

type ProfilesOption

type ProfilesOption struct {
	PK           string            `json:"PK"`
	Title        string            `json:"title"`
	Description  string            `json:"description"`
	Type         ProfileOptionType `json:"type"`
	DefaultValue any               `json:"default_value"`
	InfoURL      string            `json:"info_url"`
}

type RatelimitError

type RatelimitError struct {
	// contains filtered or unexported fields
}

RatelimitError is for HTTP 429s where the service is telling the client to slow down.

func NewRatelimitError

func NewRatelimitError(e *Error) RatelimitError

func (RatelimitError) Error

func (e RatelimitError) Error() string

func (RatelimitError) InternalErrorCodeIs

func (e RatelimitError) InternalErrorCodeIs(code int) bool

func (RatelimitError) Type

func (e RatelimitError) Type() ErrorType

type RawResponse

type RawResponse struct {
	Response
	Body json.RawMessage `json:"body"`
}

RawResponse keeps the result as JSON form.

type ReqOption

type ReqOption func(opt *reqOption)

ReqOption is a functional option for configuring API requests.

type RequestError

type RequestError struct {
	// contains filtered or unexported fields
}

RequestError is for 4xx errors that we encounter not covered elsewhere (generally bad payloads).

func NewRequestError

func NewRequestError(e *Error) RequestError

func (RequestError) Error

func (e RequestError) Error() string

func (RequestError) InternalErrorCodeIs

func (e RequestError) InternalErrorCodeIs(code int) bool

func (RequestError) Type

func (e RequestError) Type() ErrorType

type Resolvers

type Resolvers struct {
	Uid string    `json:"uid"`
	DoH string    `json:"doh"`
	DoT string    `json:"dot"`
	V4  *[]net.IP `json:"v4,omitempty"`
	V6  *[]net.IP `json:"v6,omitempty"`
}

type Response

type Response struct {
	Success bool         `json:"success"`
	Error   ResponseInfo `json:"error"`
}

Response is a template. There will also be a result struct. There will be a unique response type for each response, which will include this type.

type ResponseInfo

type ResponseInfo struct {
	Date    DateTime `json:"date"`
	Message string   `json:"message"`
	Code    int      `json:"code"`
}

ResponseInfo contains a code and message returned by the API as errors or informational messages inside the response.

type RetryPolicy

type RetryPolicy struct {
	MaxRetries    int
	MinRetryDelay time.Duration
	MaxRetryDelay time.Duration
}

RetryPolicy specifies number of retries and min/max retry delays This config is used when the client exponentially backs off after errored requests.

type Router

type Router struct {
	Name     string      `json:"name"`
	Icons    RouterIcons `json:"icons"`
	SetupURL string      `json:"setup_url"`
}

type RouterIcons

type RouterIcons struct {
	Router         Icon `json:"router"`
	RouterOpenWRT  Icon `json:"router-openwrt"`
	RouterUbiquiti Icon `json:"router-ubiquiti"`
	RouterAsus     Icon `json:"router-asus"`
	RouterDDWRT    Icon `json:"router-ddwrt"`
}

type Rule

type Rule struct {
	PK     string `json:"PK"`
	Order  int    `json:"order"`
	Group  int    `json:"group"`
	Action Action `json:"action"`
}

type Service

type Service struct {
	PK             string  `json:"PK"`
	Name           string  `json:"name"`
	Category       string  `json:"category"`
	UnlockLocation string  `json:"unlock_location"`
	Warning        *string `json:"warning,omitempty"`
}

type ServiceError

type ServiceError struct {
	// contains filtered or unexported fields
}

ServiceError is a handler for 5xx errors returned to the client.

func NewServiceError

func NewServiceError(e *Error) ServiceError

func (ServiceError) Error

func (e ServiceError) Error() string

func (ServiceError) InternalErrorCodeIs

func (e ServiceError) InternalErrorCodeIs(code int) bool

func (ServiceError) Type

func (e ServiceError) Type() ErrorType

type Status

type Status struct {
	API int `json:"api"`
	DNS int `json:"dns"`
	Pxy int `json:"pxy"`
}

type TV

type TV struct {
	Name  string  `json:"name"`
	Icons TVIcons `json:"icons"`
}

type TVIcons

type TVIcons struct {
	TV        Icon `json:"tv"`
	TVApple   Icon `json:"tv-apple"`
	TVAndroid Icon `json:"tv-android"`
	TVFireTV  Icon `json:"tv-firetv"`
	TVSamsung Icon `json:"tv-samsung"`
}

type UnixTime

type UnixTime struct {
	time.Time
}

func (UnixTime) MarshalJSON

func (s UnixTime) MarshalJSON() ([]byte, error)

func (*UnixTime) UnmarshalJSON

func (s *UnixTime) UnmarshalJSON(data []byte) error

type UpdateDeviceParams

type UpdateDeviceParams struct {
	DeviceID          string          `json:"id"`
	Name              *string         `json:"name,omitempty"`
	ProfileID         *string         `json:"profile_id,omitempty"`
	ProfileID2        *string         `json:"profile_id2,omitempty"`
	Stats             *AnalyticsLevel `json:"stats,omitempty"`
	LegacyIPv4Status  *IntBool        `json:"legacy_ipv4_status,omitempty"`
	LearnIP           *IntBool        `json:"learn_ip,omitempty"`
	Restricted        *IntBool        `json:"restricted,omitempty"`
	BumpTLS           *IntBool        `json:"bump_tls,omitempty"`
	Desc              *string         `json:"desc,omitempty"`
	DDNSStatus        *IntBool        `json:"ddns_status,omitempty"`
	DDNSSubdomain     *string         `json:"ddns_subdomain,omitempty"`
	DDNSExtHost       *string         `json:"ddns_ext_host,omitempty"`
	DDNSExtStatus     *IntBool        `json:"ddns_ext_status,omitempty"`
	Status            *DeviceStatus   `json:"status,omitempty"`
	CtrldCustomConfig *string         `json:"ctrld_custom_config,omitempty"`
}

type UpdateDeviceResponse

type UpdateDeviceResponse struct {
	Body    Device `json:"body"`
	Message string `json:"message"`
	Response
}

type UpdateProfileBody

type UpdateProfileBody struct {
	Profiles []Profile `json:"profiles"`
}

type UpdateProfileCustomRuleBody

type UpdateProfileCustomRuleBody struct {
	Rules []CustomRule `json:"rules"`
}

type UpdateProfileCustomRuleParams

type UpdateProfileCustomRuleParams struct {
	ProfileID string   `json:"profile_id"`
	Do        DoType   `json:"do"`
	Status    IntBool  `json:"status"`
	Via       *string  `json:"via,omitempty"`
	ViaV6     *string  `json:"via_v6,omitempty"`
	Group     *int     `json:"group,omitempty"`
	Hostnames []string `json:"hostnames"`
}

type UpdateProfileCustomRuleResponse

type UpdateProfileCustomRuleResponse struct {
	Body UpdateProfileCustomRuleBody `json:"body"`
	Response
}

type UpdateProfileDefaultRuleBody

type UpdateProfileDefaultRuleBody struct {
	Default DefaultRule `json:"default"`
}

type UpdateProfileDefaultRuleParams

type UpdateProfileDefaultRuleParams struct {
	ProfileID string  `json:"profile_id"`
	Do        DoType  `json:"do"`
	Status    IntBool `json:"status"`
	Via       *string `json:"via,omitempty"`
}

type UpdateProfileDefaultRuleResponse

type UpdateProfileDefaultRuleResponse struct {
	Body UpdateProfileDefaultRuleBody `json:"body"`
	Response
}

type UpdateProfileFilterBody

type UpdateProfileFilterBody struct {
	Filters any `json:"filters"`
}

type UpdateProfileFilterParams

type UpdateProfileFilterParams struct {
	ProfileID string  `json:"profile_id"`
	Filter    string  `json:"filter"`
	Status    IntBool `json:"status"`
}

type UpdateProfileFilterResponse

type UpdateProfileFilterResponse struct {
	Body UpdateProfileFilterBody `json:"body"`
	Response
}

type UpdateProfileParams

type UpdateProfileParams struct {
	ProfileID   string   `json:"profile_id"`
	Name        *string  `json:"name"`
	DisableTTL  *int     `json:"disable_ttl"`
	LockStatus  *IntBool `json:"lock_status"`
	LockMessage *string  `json:"lock_message"`
	Password    *string  `json:"password"`
}

type UpdateProfileResponse

type UpdateProfileResponse struct {
	Body ListProfilesBody `json:"body"`
	Response
}

type UpdateProfileRuleFolderBody

type UpdateProfileRuleFolderBody struct {
	Groups []Group `json:"groups"`
}

type UpdateProfileRuleFolderParams

type UpdateProfileRuleFolderParams struct {
	ProfileID string   `json:"profile_id"`
	FolderID  string   `json:"folder"`
	Do        *DoType  `json:"do,omitempty"`
	Via       *string  `json:"via,omitempty"`
	Status    *IntBool `json:"status,omitempty"`
}

type UpdateProfileRuleFolderResponse

type UpdateProfileRuleFolderResponse struct {
	Body CreateProfileRuleFolderBody `json:"body"`
	Response
}

type UpdateProfileServiceBody

type UpdateProfileServiceBody struct {
	Services []Action `json:"services"`
}

type UpdateProfileServiceParams

type UpdateProfileServiceParams struct {
	ProfileID string  `json:"profile_id"`
	Service   string  `json:"service"`
	Do        DoType  `json:"do"`
	Status    IntBool `json:"status"`
	Via       *string `json:"via"`
	ViaV6     *string `json:"via_v6"`
}

type UpdateProfileServiceResponse

type UpdateProfileServiceResponse struct {
	Body UpdateProfileServiceBody `json:"body"`
	Response
}

type UpdateProfilesOption

type UpdateProfilesOption struct {
	ProfileID string  `json:"profile_id"`
	Name      string  `json:"name"`
	Status    IntBool `json:"status"`
	Value     *string `json:"value"`
}

type UpdateProfilesOptionBody

type UpdateProfilesOptionBody struct {
	Options any `json:"options"`
	Response
}

type UpdateProfilesOptionResponse

type UpdateProfilesOptionResponse struct {
	Body UpdateProfilesOptionBody `json:"body"`
	Response
}

type User

type User struct {
	PK             string   `json:"PK"`
	ResolverIP     net.IP   `json:"resolver_ip"`
	EmailStatus    IntBool  `json:"email_status"`
	Tutorials      IntBool  `json:"tutorials"`
	V              int      `json:"v"`
	ResolverStatus IntBool  `json:"resolver_status"`
	RuleProfile    string   `json:"rule_profile"`
	Date           Date     `json:"date"`
	Status         IntBool  `json:"status"`
	Email          string   `json:"email"`
	ResolverUid    string   `json:"resolver_uid"`
	ProxyAccess    IntBool  `json:"proxy_access"`
	StatsEndpoint  string   `json:"stats_endpoint"`
	LastActive     UnixTime `json:"last_active"`
	Twofa          IntBool  `json:"twofa"`
	Debug          []any    `json:"debug"`
}

Jump to

Keyboard shortcuts

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