proxyhat

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2026 License: MIT Imports: 11 Imported by: 0

README

ProxyHat Go SDK

Go Reference Go Version CI

The official Go client library for the ProxyHat API.

Installation

go get github.com/ProxyHatCom/go-sdk

Requirements: Go 1.21+

Quick Start

package main

import (
	"context"
	"fmt"
	"log"

	proxyhat "github.com/ProxyHatCom/go-sdk"
)

func main() {
	client := proxyhat.NewClient("your-api-key")

	user, err := client.Auth.User(context.Background())
	if err != nil {
		log.Fatal(err)
	}
	fmt.Printf("Hello, %s!\n", user.Name)
}

Usage

Client Configuration
// Default client
client := proxyhat.NewClient("your-api-key")

// With options
client := proxyhat.NewClient("your-api-key",
	proxyhat.WithBaseURL("https://custom-api.example.com/v1"),
	proxyhat.WithTimeout(60 * time.Second),
	proxyhat.WithHTTPClient(&http.Client{
		Transport: customTransport,
	}),
)
Authentication
// Register a new account
resp, err := client.Auth.Register(ctx, proxyhat.RegisterParams{
	Name:                 "John Doe",
	Email:                "john@example.com",
	Password:             "secure-password",
	PasswordConfirmation: "secure-password",
})

// Login
login, err := client.Auth.Login(ctx, proxyhat.LoginParams{
	Email:    "john@example.com",
	Password: "secure-password",
})

// Get current user
user, err := client.Auth.User(ctx)
Sub-Users
// List all sub-users
users, err := client.SubUsers.List(ctx)

// Create a sub-user
user, err := client.SubUsers.Create(ctx, proxyhat.CreateSubUserParams{
	ProxyPassword: "proxy-pass",
	Name:          proxyhat.String("My Sub-User"),
})

// Update a sub-user
updated, err := client.SubUsers.Update(ctx, "user-id", proxyhat.UpdateSubUserParams{
	Name: proxyhat.String("New Name"),
})

// Bulk delete
resp, err := client.SubUsers.BulkDelete(ctx, []string{"id-1", "id-2"})
Locations
// List countries with filters
countries, err := client.Locations.Countries(ctx, &proxyhat.LocationParams{
	Limit: proxyhat.Int(10),
	Name:  proxyhat.String("United"),
})

// List cities
cities, err := client.Locations.Cities(ctx, &proxyhat.CityParams{
	RegionParams: proxyhat.RegionParams{
		CountryCode: proxyhat.String("US"),
	},
})
Analytics
// Get traffic data
traffic, err := client.Analytics.Traffic(ctx, &proxyhat.AnalyticsParams{
	Period: "7d",
})

// Get total traffic
total, err := client.Analytics.TrafficTotal(ctx, nil) // defaults to 24h
Payments
// Create a payment
payment, err := client.Payments.Create(ctx, proxyhat.CreatePaymentParams{
	Type:               "regular",
	PlanID:             "plan-id",
	CryptocurrencyCode: "BTC",
})

// Download invoice
resp, err := client.Payments.Invoice(ctx, "payment-id", "pdf")
if err != nil {
	log.Fatal(err)
}
defer resp.Body.Close()
// Write resp.Body to file...
Error Handling
user, err := client.Auth.User(ctx)
if err != nil {
	if proxyhat.IsAuthenticationError(err) {
		log.Fatal("Invalid API key")
	}
	if proxyhat.IsRateLimitError(err) {
		if rle, ok := proxyhat.AsRateLimitError(err); ok {
			log.Printf("Rate limited. Retry after %d seconds", rle.RetryAfter)
		}
	}
	if proxyhat.IsNotFoundError(err) {
		log.Println("Resource not found")
	}
	log.Fatal(err)
}

Available Services

Service Description
client.Auth Authentication (register, login, logout, OAuth)
client.SubUsers Sub-user management (CRUD, bulk ops)
client.SubUserGroups Sub-user group management
client.Locations Proxy locations (countries, regions, cities, ISPs, zipcodes)
client.Analytics Traffic and request analytics
client.ProxyPresets Proxy preset management
client.Profile User preferences and API keys
client.TwoFactor Two-factor authentication
client.Email Email change management
client.Coupons Coupon validation and redemption
client.Plans Plan listing and pricing
client.Payments Payment processing and invoices

Documentation

Full API documentation is available at pkg.go.dev.

For the ProxyHat API reference, visit proxyhat.com/docs.

License

This project is licensed under the MIT License. See LICENSE for details.

Documentation

Overview

Package proxyhat provides a Go client for the ProxyHat API.

Usage:

client := proxyhat.NewClient("your-api-key")
user, err := client.Auth.User(context.Background())

Index

Constants

View Source
const (
	DefaultBaseURL = "https://api.proxyhat.com/v1"
	DefaultTimeout = 30 * time.Second
)

Variables

This section is empty.

Functions

func Bool

func Bool(v bool) *bool

Bool returns a pointer to the given bool value.

func Float64

func Float64(v float64) *float64

Float64 returns a pointer to the given float64 value.

func Int

func Int(v int) *int

Int returns a pointer to the given int value.

func IsAuthenticationError

func IsAuthenticationError(err error) bool

IsAuthenticationError returns true if the error is a 401 Unauthorized.

func IsNotFoundError

func IsNotFoundError(err error) bool

IsNotFoundError returns true if the error is a 404 Not Found.

func IsPermissionError

func IsPermissionError(err error) bool

IsPermissionError returns true if the error is a 403 Forbidden.

func IsRateLimitError

func IsRateLimitError(err error) bool

IsRateLimitError returns true if the error is a 429 Too Many Requests.

func IsValidationError

func IsValidationError(err error) bool

IsValidationError returns true if the error is a 422 Unprocessable Entity.

func String

func String(v string) *string

String returns a pointer to the given string value.

Types

type APIKey

type APIKey struct {
	ID             string  `json:"id"`
	Name           *string `json:"name"`
	PlainTextToken *string `json:"plain_text_token"`
	CreatedAt      *string `json:"created_at"`
}

type AnalyticsParams

type AnalyticsParams struct {
	Period    string  `json:"period"`
	StartDate *string `json:"start_date,omitempty"`
	EndDate   *string `json:"end_date,omitempty"`
}

AnalyticsParams are common parameters for analytics endpoints.

type AnalyticsService

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

AnalyticsService handles analytics endpoints.

func (*AnalyticsService) DomainBreakdown

func (s *AnalyticsService) DomainBreakdown(ctx context.Context, params *AnalyticsParams) (*DomainBreakdownResponse, error)

DomainBreakdown returns domain breakdown analytics.

func (*AnalyticsService) Requests

Requests returns request time series data.

func (*AnalyticsService) RequestsTotal

func (s *AnalyticsService) RequestsTotal(ctx context.Context, params *AnalyticsParams) (*TotalResponse, error)

RequestsTotal returns total requests for the period.

func (*AnalyticsService) Traffic

Traffic returns traffic time series data.

func (*AnalyticsService) TrafficTotal

func (s *AnalyticsService) TrafficTotal(ctx context.Context, params *AnalyticsParams) (*TotalResponse, error)

TrafficTotal returns total traffic for the period.

type AuthService

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

AuthService handles authentication endpoints.

func (*AuthService) DisconnectSocial

func (s *AuthService) DisconnectSocial(ctx context.Context, provider string) error

DisconnectSocial removes a connected social account.

func (*AuthService) Login

func (s *AuthService) Login(ctx context.Context, params LoginParams) (*LoginResponse, error)

Login authenticates a user.

func (*AuthService) Logout

func (s *AuthService) Logout(ctx context.Context) error

Logout invalidates the current session.

func (*AuthService) OAuthRedirect

func (s *AuthService) OAuthRedirect(ctx context.Context, provider string) (any, error)

OAuthRedirect returns the OAuth redirect URL for a provider.

func (*AuthService) Register

func (s *AuthService) Register(ctx context.Context, params RegisterParams) (*RegisterResponse, error)

Register creates a new account.

func (*AuthService) SocialAccounts

func (s *AuthService) SocialAccounts(ctx context.Context) ([]SocialAccount, error)

SocialAccounts returns the user's connected social accounts.

func (*AuthService) SupportedProviders

func (s *AuthService) SupportedProviders(ctx context.Context) ([]SupportedProvider, error)

SupportedProviders returns the list of supported OAuth providers.

func (*AuthService) User

func (s *AuthService) User(ctx context.Context) (*User, error)

User returns the authenticated user.

type BulkDeleteResponse

type BulkDeleteResponse struct {
	Requested int `json:"requested"`
	Deleted   int `json:"deleted"`
	Skipped   int `json:"skipped"`
	NotFound  int `json:"not_found"`
	Failed    int `json:"failed"`
}

type ChangePasswordParams

type ChangePasswordParams struct {
	CurrentPassword      string  `json:"current_password"`
	Password             string  `json:"password"`
	PasswordConfirmation string  `json:"password_confirmation"`
	TwofaCode            *string `json:"twofa_code,omitempty"`
}

type City

type City struct {
	Code           string  `json:"code"`
	Name           string  `json:"name"`
	CountryCode    string  `json:"country_code"`
	RegionCode     *string `json:"region_code"`
	Availability   *string `json:"availability"`
	ConnectionType *string `json:"connection_type"`
}

type CityParams

type CityParams struct {
	RegionParams
	RegionCode *string
}

CityParams extends RegionParams with a region code filter.

type Client

type Client struct {
	Auth          *AuthService
	SubUsers      *SubUsersService
	SubUserGroups *SubUserGroupsService
	Locations     *LocationsService
	Analytics     *AnalyticsService
	ProxyPresets  *ProxyPresetsService
	Profile       *ProfileService
	TwoFactor     *TwoFactorService
	Email         *EmailService
	Coupons       *CouponsService
	Plans         *PlansService
	Payments      *PaymentsService
	// contains filtered or unexported fields
}

Client manages communication with the ProxyHat API.

func NewClient

func NewClient(apiKey string, opts ...Option) *Client

NewClient creates a new ProxyHat API client.

type Country

type Country struct {
	Code           string `json:"code"`
	Name           string `json:"name"`
	Availability   string `json:"availability"`
	ConnectionType string `json:"connection_type"`
}

type Coupon

type Coupon struct {
	ID          string   `json:"id"`
	Code        string   `json:"code"`
	Type        string   `json:"type"`
	Data        any      `json:"data"`
	Discount    *float64 `json:"discount"`
	FinalAmount *float64 `json:"final_amount"`
}

type CouponParams

type CouponParams struct {
	Code     string   `json:"code"`
	PlanID   *string  `json:"plan_id,omitempty"`
	OrderSum *float64 `json:"order_sum,omitempty"`
	Currency *string  `json:"currency,omitempty"`
}

type CouponResponse

type CouponResponse struct {
	Success bool    `json:"success"`
	Coupon  *Coupon `json:"coupon"`
}

type CouponsService

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

CouponsService handles coupon endpoints.

func (*CouponsService) Apply

func (s *CouponsService) Apply(ctx context.Context, params CouponParams) (*CouponResponse, error)

Apply applies a coupon code.

func (*CouponsService) Redeem

func (s *CouponsService) Redeem(ctx context.Context, code string) (*CouponResponse, error)

Redeem redeems a coupon code.

func (*CouponsService) Validate

func (s *CouponsService) Validate(ctx context.Context, params CouponParams) (*CouponResponse, error)

Validate validates a coupon code.

type CreatePaymentParams

type CreatePaymentParams struct {
	Type               string  `json:"type"`
	PlanID             string  `json:"plan_id"`
	Gate               string  `json:"gate"`
	CryptocurrencyCode string  `json:"cryptocurrency_code"`
	CouponCode         *string `json:"coupon_code,omitempty"`
}

type CreateProxyPresetParams

type CreateProxyPresetParams struct {
	Name string         `json:"name"`
	Data map[string]any `json:"data"`
}

type CreateSubUserGroupParams

type CreateSubUserGroupParams struct {
	Name        string  `json:"name"`
	Description *string `json:"description,omitempty"`
}

type CreateSubUserParams

type CreateSubUserParams struct {
	ProxyPassword    string  `json:"proxy_password"`
	IsTrafficLimited bool    `json:"is_traffic_limited"`
	TrafficLimit     *string `json:"traffic_limit,omitempty"`
	Name             *string `json:"name,omitempty"`
	Notes            *string `json:"notes,omitempty"`
	SubUserGroupID   *string `json:"sub_user_group_id,omitempty"`
}

type CryptoInfo

type CryptoInfo struct {
	Code     string  `json:"code"`
	Currency string  `json:"currency"`
	Network  string  `json:"network"`
	Icon     *string `json:"icon"`
	Label    *string `json:"label"`
}

type Cryptocurrency

type Cryptocurrency struct {
	Code     string  `json:"code"`
	Currency string  `json:"currency"`
	Network  string  `json:"network"`
	Icon     *string `json:"icon"`
	Label    *string `json:"label"`
}

type DomainBreakdownItem

type DomainBreakdownItem struct {
	Domain    string `json:"domain"`
	Bandwidth int    `json:"bandwidth"`
	Requests  int    `json:"requests"`
}

type DomainBreakdownResponse

type DomainBreakdownResponse struct {
	Items []DomainBreakdownItem `json:"items"`
}

type EmailChangeResponse

type EmailChangeResponse struct {
	Message string `json:"message"`
}

type EmailService

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

EmailService handles email change endpoints.

func (*EmailService) CancelChange

func (s *EmailService) CancelChange(ctx context.Context) (*EmailChangeResponse, error)

CancelChange cancels a pending email change.

func (*EmailService) ConfirmChange

func (s *EmailService) ConfirmChange(ctx context.Context, token string) (*EmailChangeResponse, error)

ConfirmChange confirms an email change with a token.

func (*EmailService) RequestChange

RequestChange initiates an email change.

func (*EmailService) ResendVerification

func (s *EmailService) ResendVerification(ctx context.Context) (*EmailChangeResponse, error)

ResendVerification resends the email verification.

type Error

type Error struct {
	Message    string `json:"message"`
	StatusCode int    `json:"status_code"`
	Errors     any    `json:"errors,omitempty"`
}

Error represents an API error response.

func (*Error) Error

func (e *Error) Error() string

type ISP

type ISP struct {
	Code           string  `json:"code"`
	Name           string  `json:"name"`
	CountryCode    string  `json:"country_code"`
	Availability   *string `json:"availability"`
	ConnectionType *string `json:"connection_type"`
}

type LocationParams

type LocationParams struct {
	Limit          *int
	Offset         *int
	Name           *string
	ConnectionType *string
}

LocationParams are common query parameters for location endpoints.

type LocationsService

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

LocationsService handles location endpoints.

func (*LocationsService) Cities

func (s *LocationsService) Cities(ctx context.Context, params *CityParams) ([]City, error)

Cities returns the list of available cities.

func (*LocationsService) Countries

func (s *LocationsService) Countries(ctx context.Context, params *LocationParams) ([]Country, error)

Countries returns the list of available countries.

func (*LocationsService) ISPs

func (s *LocationsService) ISPs(ctx context.Context, params *RegionParams) ([]ISP, error)

ISPs returns the list of available ISPs.

func (*LocationsService) Regions

func (s *LocationsService) Regions(ctx context.Context, params *RegionParams) ([]Region, error)

Regions returns the list of available regions.

func (*LocationsService) Zipcodes

func (s *LocationsService) Zipcodes(ctx context.Context, params *ZipcodeParams) ([]Zipcode, error)

Zipcodes returns the list of available zipcodes.

type LoginParams

type LoginParams struct {
	Email     string  `json:"email"`
	Password  string  `json:"password"`
	TwofaCode *string `json:"twofa_code,omitempty"`
}

type LoginResponse

type LoginResponse struct {
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
	Requires2FA bool   `json:"requires_2fa"`
}

type Option

type Option func(*Client)

Option configures a Client.

func WithBaseURL

func WithBaseURL(url string) Option

WithBaseURL sets the API base URL.

func WithHTTPClient

func WithHTTPClient(hc *http.Client) Option

WithHTTPClient sets the underlying HTTP client.

func WithTimeout

func WithTimeout(d time.Duration) Option

WithTimeout sets the request timeout.

type Payment

type Payment struct {
	ID        string   `json:"id"`
	Type      string   `json:"type"`
	Status    string   `json:"status"`
	Amount    *float64 `json:"amount"`
	Currency  *string  `json:"currency"`
	CreatedAt *string  `json:"created_at"`
}

type PaymentCreateResponse

type PaymentCreateResponse struct {
	Success   bool   `json:"success"`
	PaymentID string `json:"payment_id"`
}

type PaymentDetails

type PaymentDetails struct {
	PayAddress   string     `json:"pay_address"`
	CryptoAmount float64    `json:"crypto_amount"`
	AmountUSD    float64    `json:"amount_usd"`
	Crypto       CryptoInfo `json:"crypto"`
	Status       string     `json:"status"`
	TxHash       *string    `json:"tx_hash"`
	ExpiresAt    *string    `json:"expires_at"`
	CompletedAt  *string    `json:"completed_at"`
}

type PaymentsService

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

PaymentsService handles payment endpoints.

func (*PaymentsService) Check

func (s *PaymentsService) Check(ctx context.Context, id string) (*PaymentDetails, error)

Check checks the status of a payment.

func (*PaymentsService) Create

Create creates a new payment.

func (*PaymentsService) Cryptocurrencies

func (s *PaymentsService) Cryptocurrencies(ctx context.Context) ([]Cryptocurrency, error)

Cryptocurrencies returns the list of supported cryptocurrencies.

func (*PaymentsService) Get

Get returns a payment by ID.

func (*PaymentsService) Invoice

func (s *PaymentsService) Invoice(ctx context.Context, id string, format string) (*http.Response, error)

Invoice downloads a payment invoice. The caller must close the response body.

func (*PaymentsService) List

func (s *PaymentsService) List(ctx context.Context) ([]Payment, error)

List returns all payments.

type PlansService

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

PlansService handles plan endpoints.

func (*PlansService) GetRegular

func (s *PlansService) GetRegular(ctx context.Context, name string) (*RegularPlan, error)

GetRegular returns a regular plan by name.

func (*PlansService) GetSubscription

func (s *PlansService) GetSubscription(ctx context.Context, name string) (*SubscriptionPlan, error)

GetSubscription returns a subscription plan by name.

func (*PlansService) ListRegular

func (s *PlansService) ListRegular(ctx context.Context) ([]RegularPlan, error)

ListRegular returns all regular (one-time) plans.

func (*PlansService) ListSubscriptions

func (s *PlansService) ListSubscriptions(ctx context.Context) ([]SubscriptionPlan, error)

ListSubscriptions returns all subscription plans.

func (*PlansService) PricingRegular

func (s *PlansService) PricingRegular(ctx context.Context) ([]any, error)

PricingRegular returns regular plan pricing.

func (*PlansService) PricingSubscriptions

func (s *PlansService) PricingSubscriptions(ctx context.Context) ([]any, error)

PricingSubscriptions returns subscription plan pricing.

type Preferences

type Preferences struct {
	Data map[string]any `json:"data"`
}

type ProfileService

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

ProfileService handles profile endpoints.

func (*ProfileService) CreateAPIKey

func (s *ProfileService) CreateAPIKey(ctx context.Context, name *string) (*APIKey, error)

CreateAPIKey creates a new API key.

func (*ProfileService) DeleteAPIKey

func (s *ProfileService) DeleteAPIKey(ctx context.Context, id string) error

DeleteAPIKey deletes an API key by ID.

func (*ProfileService) GetPreferences

func (s *ProfileService) GetPreferences(ctx context.Context) (*Preferences, error)

GetPreferences returns user preferences.

func (*ProfileService) ListAPIKeys

func (s *ProfileService) ListAPIKeys(ctx context.Context) ([]APIKey, error)

ListAPIKeys returns all API keys.

func (*ProfileService) RegenerateAPIKey

func (s *ProfileService) RegenerateAPIKey(ctx context.Context, id string) (*APIKey, error)

RegenerateAPIKey regenerates an API key.

func (*ProfileService) UpdatePreferences

func (s *ProfileService) UpdatePreferences(ctx context.Context, preferences map[string]any) (*Preferences, error)

UpdatePreferences updates user preferences.

type ProxyPreset

type ProxyPreset struct {
	ID        string         `json:"id"`
	Name      string         `json:"name"`
	Data      map[string]any `json:"data"`
	CreatedAt *string        `json:"created_at"`
}

type ProxyPresetsService

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

ProxyPresetsService handles proxy preset endpoints.

func (*ProxyPresetsService) Create

Create creates a new proxy preset.

func (*ProxyPresetsService) Delete

func (s *ProxyPresetsService) Delete(ctx context.Context, id string) error

Delete removes a proxy preset.

func (*ProxyPresetsService) Get

Get returns a proxy preset by ID.

func (*ProxyPresetsService) List

List returns all proxy presets.

func (*ProxyPresetsService) Update

Update modifies a proxy preset.

type RateLimitError

type RateLimitError struct {
	Message    string `json:"message"`
	StatusCode int    `json:"status_code"`
	Errors     any    `json:"errors,omitempty"`
	RetryAfter int    `json:"retry_after"`
}

RateLimitError is returned when the API rate limit is exceeded (HTTP 429).

func AsRateLimitError

func AsRateLimitError(err error) (*RateLimitError, bool)

AsRateLimitError extracts a RateLimitError from err if present.

func (*RateLimitError) Error

func (e *RateLimitError) Error() string

type RecoveryCodes

type RecoveryCodes struct {
	Codes []string `json:"codes"`
}

type Region

type Region struct {
	Code           string  `json:"code"`
	Name           string  `json:"name"`
	CountryCode    string  `json:"country_code"`
	Availability   *string `json:"availability"`
	ConnectionType *string `json:"connection_type"`
}

type RegionParams

type RegionParams struct {
	LocationParams
	CountryCode *string
}

RegionParams extends LocationParams with a country code filter.

type RegisterParams

type RegisterParams struct {
	Name                 string  `json:"name"`
	Email                string  `json:"email"`
	Password             string  `json:"password"`
	PasswordConfirmation string  `json:"password_confirmation"`
	ReferralCode         *string `json:"referral_code,omitempty"`
	UTMSource            *string `json:"utm_source,omitempty"`
	UTMMedium            *string `json:"utm_medium,omitempty"`
	UTMCampaign          *string `json:"utm_campaign,omitempty"`
}

type RegisterResponse

type RegisterResponse struct {
	Message     string `json:"message"`
	AccessToken string `json:"access_token"`
	TokenType   string `json:"token_type"`
}

type RegularPlan

type RegularPlan struct {
	ID         string  `json:"id"`
	Name       string  `json:"name"`
	GB         int     `json:"gb"`
	PricePerGB float64 `json:"price_per_gb"`
	PriceTotal float64 `json:"price_total"`
	Currency   string  `json:"currency"`
}

type RequestEmailChangeParams

type RequestEmailChangeParams struct {
	Email     string  `json:"email"`
	TwofaCode *string `json:"twofa_code,omitempty"`
}

type ResetUsageResponse

type ResetUsageResponse struct {
	Reset int `json:"reset"`
}

type SocialAccount

type SocialAccount struct {
	Provider    string  `json:"provider"`
	Email       *string `json:"email"`
	ConnectedAt *string `json:"connected_at"`
}

type SubUser

type SubUser struct {
	UUID             string  `json:"uuid"`
	ProxyUsername    string  `json:"proxy_username"`
	IsDefaultUser    bool    `json:"is_default_user"`
	IsTrafficLimited bool    `json:"is_traffic_limited"`
	UsedTraffic      int     `json:"used_traffic"`
	TrafficLimit     int     `json:"traffic_limit"`
	LifecycleStatus  string  `json:"lifecycle_status"`
	Name             *string `json:"name"`
	Notes            *string `json:"notes"`
	SubUserGroupID   *string `json:"sub_user_group_id"`
	CreatedAt        string  `json:"created_at"`
}

type SubUserGroup

type SubUserGroup struct {
	ID            string  `json:"id"`
	Name          string  `json:"name"`
	Description   *string `json:"description"`
	SubUsersCount int     `json:"sub_users_count"`
	CreatedAt     string  `json:"created_at"`
	SubUsers      []any   `json:"sub_users"`
}

type SubUserGroupsService

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

SubUserGroupsService handles sub-user group endpoints.

func (*SubUserGroupsService) Create

Create creates a new sub-user group.

func (*SubUserGroupsService) Delete

func (s *SubUserGroupsService) Delete(ctx context.Context, id string) error

Delete removes a sub-user group.

func (*SubUserGroupsService) Get

Get returns a sub-user group by ID.

func (*SubUserGroupsService) List

List returns all sub-user groups.

func (*SubUserGroupsService) Update

Update modifies a sub-user group.

type SubUsersService

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

SubUsersService handles sub-user endpoints.

func (*SubUsersService) BulkDelete

func (s *SubUsersService) BulkDelete(ctx context.Context, ids []string) (*BulkDeleteResponse, error)

BulkDelete deletes multiple sub-users.

func (*SubUsersService) BulkMoveToGroup

func (s *SubUsersService) BulkMoveToGroup(ctx context.Context, ids []string, groupID *string) (any, error)

BulkMoveToGroup moves multiple sub-users to a group.

func (*SubUsersService) Create

func (s *SubUsersService) Create(ctx context.Context, params CreateSubUserParams) (*SubUser, error)

Create creates a new sub-user.

func (*SubUsersService) Delete

func (s *SubUsersService) Delete(ctx context.Context, id string) error

Delete removes a sub-user.

func (*SubUsersService) Get

func (s *SubUsersService) Get(ctx context.Context, id string) (*SubUser, error)

Get returns a sub-user by ID.

func (*SubUsersService) List

func (s *SubUsersService) List(ctx context.Context) ([]SubUser, error)

List returns all sub-users.

func (*SubUsersService) ResetUsage

func (s *SubUsersService) ResetUsage(ctx context.Context, ids []string) (*ResetUsageResponse, error)

ResetUsage resets traffic usage for the given sub-user IDs.

func (*SubUsersService) Update

func (s *SubUsersService) Update(ctx context.Context, id string, params UpdateSubUserParams) (*SubUser, error)

Update modifies a sub-user.

type SubscriptionPlan

type SubscriptionPlan struct {
	ID              string  `json:"id"`
	Name            string  `json:"name"`
	GB              int     `json:"gb"`
	PricePerGB      float64 `json:"price_per_gb"`
	PriceTotal      float64 `json:"price_total"`
	Period          string  `json:"period"`
	RolloverEnabled bool    `json:"rollover_enabled"`
}

type SupportedProvider

type SupportedProvider struct {
	Name string `json:"name"`
	Slug string `json:"slug"`
}

type TimeSeriesResponse

type TimeSeriesResponse struct {
	Labels []string `json:"labels"`
	Data   []int    `json:"data"`
}

type TotalResponse

type TotalResponse struct {
	Total int `json:"total"`
}

type TrafficInfo

type TrafficInfo struct {
	Subscription          *string `json:"subscription"`
	SubscriptionStartsAt  *string `json:"subscription_starts_at"`
	SubscriptionExpiresAt *string `json:"subscription_expires_at"`
	RegularBytes          int     `json:"regular_bytes"`
	RegularHuman          string  `json:"regular_human"`
	SubscriptionBytes     int     `json:"subscription_bytes"`
	SubscriptionHuman     string  `json:"subscription_human"`
	TotalBytes            int     `json:"total_bytes"`
	TotalHuman            string  `json:"total_human"`
}

type TwoFactorEnableResponse

type TwoFactorEnableResponse struct {
	QR            string   `json:"qr"`
	Secret        string   `json:"secret"`
	RecoveryCodes []string `json:"recovery_codes"`
}

type TwoFactorService

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

TwoFactorService handles two-factor authentication endpoints.

func (*TwoFactorService) ChangePassword

func (s *TwoFactorService) ChangePassword(ctx context.Context, params ChangePasswordParams) (any, error)

ChangePassword changes the user's password.

func (*TwoFactorService) Confirm

func (s *TwoFactorService) Confirm(ctx context.Context, code string) (any, error)

Confirm confirms 2FA setup with a verification code.

func (*TwoFactorService) Disable

func (s *TwoFactorService) Disable(ctx context.Context, twofaCode string) (any, error)

Disable disables 2FA with a verification code.

func (*TwoFactorService) DisableByRecovery

func (s *TwoFactorService) DisableByRecovery(ctx context.Context, recoveryCode string) (any, error)

DisableByRecovery disables 2FA using a recovery code.

func (*TwoFactorService) Enable

Enable initiates 2FA setup.

func (*TwoFactorService) QRCode

QRCode returns the QR code for 2FA setup.

func (*TwoFactorService) RecoveryCodes

func (s *TwoFactorService) RecoveryCodes(ctx context.Context) (*RecoveryCodes, error)

RecoveryCodes returns the 2FA recovery codes.

func (*TwoFactorService) Status

Status returns the 2FA status for the authenticated user.

type TwoFactorStatus

type TwoFactorStatus struct {
	Enabled bool `json:"enabled"`
}

type UpdateProxyPresetParams

type UpdateProxyPresetParams struct {
	Name *string        `json:"name,omitempty"`
	Data map[string]any `json:"data,omitempty"`
}

type UpdateSubUserGroupParams

type UpdateSubUserGroupParams struct {
	Name        *string `json:"name,omitempty"`
	Description *string `json:"description,omitempty"`
}

type UpdateSubUserParams

type UpdateSubUserParams struct {
	ProxyPassword    *string `json:"proxy_password,omitempty"`
	IsTrafficLimited *bool   `json:"is_traffic_limited,omitempty"`
	TrafficLimit     *string `json:"traffic_limit,omitempty"`
	Name             *string `json:"name,omitempty"`
	Notes            *string `json:"notes,omitempty"`
}

type User

type User struct {
	UUID    string      `json:"uuid"`
	Name    string      `json:"name"`
	Email   string      `json:"email"`
	Traffic TrafficInfo `json:"traffic"`
}

type Zipcode

type Zipcode struct {
	Code           string  `json:"code"`
	Name           string  `json:"name"`
	CountryCode    string  `json:"country_code"`
	CityCode       *string `json:"city_code"`
	Availability   *string `json:"availability"`
	ConnectionType *string `json:"connection_type"`
}

type ZipcodeParams

type ZipcodeParams struct {
	LocationParams
	CountryCode *string
	CityCode    *string
}

ZipcodeParams extends LocationParams with country and city code filters.

Jump to

Keyboard shortcuts

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