Documentation ¶
Index ¶
- Constants
- type APIKey
- type APIKeyResource
- func (a *APIKeyResource) Create(ctx context.Context, expiration time.Time) (APIKey, error)
- func (a *APIKeyResource) Delete(ctx context.Context, prefix string) error
- func (a *APIKeyResource) Expire(ctx context.Context, prefix string) error
- func (a *APIKeyResource) List(ctx context.Context) (APIKeysResponse, error)
- type APIKeysResponse
- type AddAPIKeyRequest
- type AddTagsRequest
- type ChangesResponse
- type Client
- type CreatePreAuthKeyRequest
- type CreateUserRequest
- type DefaultLogger
- func (l *DefaultLogger) Debug(ctx context.Context, msg string, keysAndValues ...interface{})
- func (l *DefaultLogger) Error(ctx context.Context, msg string, keysAndValues ...interface{})
- func (l *DefaultLogger) Info(ctx context.Context, msg string, keysAndValues ...interface{})
- func (l *DefaultLogger) Warn(ctx context.Context, msg string, keysAndValues ...interface{})
- type ExpireAPIKeyRequest
- type ExpirePreAuthKeyRequest
- type HeadscaleClientInterface
- type HeadscaleClientOptions
- type LogLevel
- type Logger
- type MockClient
- type Node
- type NodeResource
- func (n *NodeResource) AddTags(ctx context.Context, id string, tags []string) (NodeResponse, error)
- func (n *NodeResource) Delete(ctx context.Context, id string) error
- func (n *NodeResource) Expire(ctx context.Context, id string) error
- func (n *NodeResource) Get(ctx context.Context, id string) (NodeResponse, error)
- func (n *NodeResource) GetRoutes(ctx context.Context, id string) (RoutesResponse, error)
- func (n *NodeResource) List(ctx context.Context) (NodesResponse, error)
- func (n *NodeResource) Register(ctx context.Context, user, key string) (NodeResponse, error)
- func (n *NodeResource) Rename(ctx context.Context, id, name string) (NodeResponse, error)
- func (n *NodeResource) UpdateUser(ctx context.Context, id, user string) (NodeResponse, error)
- type NodeResponse
- type NodesResponse
- type Policy
- type PolicyResource
- type PreAuthKey
- type PreAuthKeyResource
- func (p *PreAuthKeyResource) Create(ctx context.Context, user string, reusable bool, ephemeral bool, ...) (PreAuthKeyResponse, error)
- func (p *PreAuthKeyResource) Expire(ctx context.Context, user string, key string) error
- func (p *PreAuthKeyResource) List(ctx context.Context) (PreAuthKeysResponse, error)
- type PreAuthKeyResponse
- type PreAuthKeysResponse
- type Route
- type RoutesResource
- type RoutesResponse
- type UpdatePolicyRequest
- type User
- type UserResource
- func (u *UserResource) Create(ctx context.Context, name string) (User, error)
- func (u *UserResource) Delete(ctx context.Context, name string) error
- func (u *UserResource) Get(ctx context.Context, name string) (UserResponse, error)
- func (u *UserResource) List(ctx context.Context) (UsersResponse, error)
- func (u *UserResource) Rename(ctx context.Context, name, newName string) error
- type UserResponse
- type UsersResponse
Constants ¶
View Source
const DefaultHTTPClientTimeout = time.Minute
View Source
const DefaultUserAgent = "headscale-client-go"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIKeyResource ¶
type APIKeyResource struct {
Client HeadscaleClientInterface
}
func (*APIKeyResource) Delete ¶
func (a *APIKeyResource) Delete(ctx context.Context, prefix string) error
func (*APIKeyResource) Expire ¶
func (a *APIKeyResource) Expire(ctx context.Context, prefix string) error
func (*APIKeyResource) List ¶
func (a *APIKeyResource) List(ctx context.Context) (APIKeysResponse, error)
type APIKeysResponse ¶
type APIKeysResponse struct {
APIKeys []APIKey `json:"apiKeys"`
}
type AddAPIKeyRequest ¶
type AddTagsRequest ¶
type AddTagsRequest struct {
Tags []string `json:"tags"`
}
type ChangesResponse ¶
type ChangesResponse struct {
Changes []string `json:"changes"`
}
type Client ¶
type Client struct { BaseURL *url.URL UserAgent string APIKey string HTTP *http.Client Logger Logger // contains filtered or unexported fields }
func (*Client) APIKeys ¶
func (c *Client) APIKeys() *APIKeyResource
func (*Client) Nodes ¶
func (c *Client) Nodes() *NodeResource
func (*Client) Policy ¶
func (c *Client) Policy() *PolicyResource
func (*Client) Routes ¶
func (c *Client) Routes() *RoutesResource
func (*Client) Users ¶
func (c *Client) Users() *UserResource
type CreatePreAuthKeyRequest ¶
type CreateUserRequest ¶
type CreateUserRequest struct {
Name string `json:"name"`
}
type DefaultLogger ¶
type DefaultLogger struct {
// contains filtered or unexported fields
}
DefaultLogger is a simple implementation of the Logger interface.
func NewDefaultLogger ¶
func NewDefaultLogger(level LogLevel) *DefaultLogger
NewDefaultLogger creates a new DefaultLogger.
func (*DefaultLogger) Debug ¶
func (l *DefaultLogger) Debug(ctx context.Context, msg string, keysAndValues ...interface{})
Debug logs a debug message.
func (*DefaultLogger) Error ¶
func (l *DefaultLogger) Error(ctx context.Context, msg string, keysAndValues ...interface{})
Error logs an error message.
type ExpireAPIKeyRequest ¶
type ExpireAPIKeyRequest struct {
Prefix string `json:"prefix"`
}
type ExpirePreAuthKeyRequest ¶
type HeadscaleClientInterface ¶
type HeadscaleClientInterface interface { APIKeys() *APIKeyResource Nodes() *NodeResource Policy() *PolicyResource Routes() *RoutesResource Users() *UserResource // contains filtered or unexported methods }
func NewClient ¶
func NewClient(baseURL, apiKey string, opt HeadscaleClientOptions) (HeadscaleClientInterface, error)
func NewMockClient ¶
func NewMockClient() HeadscaleClientInterface
type HeadscaleClientOptions ¶
type Logger ¶
type Logger interface { Info(ctx context.Context, msg string, keysAndValues ...interface{}) Error(ctx context.Context, msg string, keysAndValues ...interface{}) Warn(ctx context.Context, msg string, keysAndValues ...interface{}) Debug(ctx context.Context, msg string, keysAndValues ...interface{}) }
Logger is an interface for logging messages.
type MockClient ¶
MockClient is a mock implementation of the HeadscaleClientInterface.
func (*MockClient) APIKeys ¶
func (m *MockClient) APIKeys() *APIKeyResource
Implementing the HeadscaleClientInterface methods
func (*MockClient) Nodes ¶
func (m *MockClient) Nodes() *NodeResource
func (*MockClient) Policy ¶
func (m *MockClient) Policy() *PolicyResource
func (*MockClient) Routes ¶
func (m *MockClient) Routes() *RoutesResource
func (*MockClient) Users ¶
func (m *MockClient) Users() *UserResource
type Node ¶
type Node struct { ID string `json:"id"` MachineKey string `json:"machineKey"` NodeKey string `json:"nodeKey"` DiscoKey string `json:"discoKey"` IPAddresses []string `json:"ipAddresses"` Name string `json:"name"` User User `json:"user"` LastSeen time.Time `json:"lastSeen"` Expiry time.Time `json:"expiry"` PreAuthKey PreAuthKey `json:"preAuthKey"` CreatedAt time.Time `json:"createdAt"` RegisterMethod string `json:"registerMethod"` ForcedTags []string `json:"forcedTags"` InvalidTags []string `json:"invalidTags"` ValidTags []string `json:"validTags"` GivenName string `json:"givenName"` Online bool `json:"online"` }
type NodeResource ¶
type NodeResource struct {
Client HeadscaleClientInterface
}
func (*NodeResource) AddTags ¶
func (n *NodeResource) AddTags(ctx context.Context, id string, tags []string) (NodeResponse, error)
func (*NodeResource) Get ¶
func (n *NodeResource) Get(ctx context.Context, id string) (NodeResponse, error)
func (*NodeResource) GetRoutes ¶
func (n *NodeResource) GetRoutes(ctx context.Context, id string) (RoutesResponse, error)
func (*NodeResource) List ¶
func (n *NodeResource) List(ctx context.Context) (NodesResponse, error)
func (*NodeResource) Register ¶
func (n *NodeResource) Register(ctx context.Context, user, key string) (NodeResponse, error)
func (*NodeResource) Rename ¶
func (n *NodeResource) Rename(ctx context.Context, id, name string) (NodeResponse, error)
func (*NodeResource) UpdateUser ¶
func (n *NodeResource) UpdateUser(ctx context.Context, id, user string) (NodeResponse, error)
type NodeResponse ¶
type NodeResponse struct {
Node Node `json:"node"`
}
type NodesResponse ¶
type NodesResponse struct {
Nodes []Node `json:"nodes"`
}
type PolicyResource ¶
type PolicyResource struct {
Client HeadscaleClientInterface
}
type PreAuthKey ¶
type PreAuthKey struct { User string `json:"user"` ID string `json:"id"` Key string `json:"key"` Reusable bool `json:"reusable"` Ephemeral bool `json:"ephemeral"` Used bool `json:"used"` Expiration time.Time `json:"expiration"` CreatedAt time.Time `json:"createdAt"` AclTags []string `json:"aclTags"` }
type PreAuthKeyResource ¶
type PreAuthKeyResource struct {
Client HeadscaleClientInterface
}
func (*PreAuthKeyResource) List ¶
func (p *PreAuthKeyResource) List(ctx context.Context) (PreAuthKeysResponse, error)
type PreAuthKeyResponse ¶
type PreAuthKeyResponse struct {
PreAuthKey []PreAuthKey `json:"preAuthKey"`
}
type PreAuthKeysResponse ¶
type PreAuthKeysResponse struct {
PreAuthKeys []PreAuthKey `json:"preAuthKeys"`
}
type Route ¶
type Route struct { ID string `json:"id"` Node NodeResponse `json:"node"` Prefix string `json:"prefix"` Advertised bool `json:"advertised"` Enabled bool `json:"enabled"` IsPrimary bool `json:"isPrimary"` CreatedAt time.Time `json:"createdAt"` UpdatedAt time.Time `json:"updatedAt"` DeletedAt time.Time `json:"deletedAt"` }
type RoutesResource ¶
type RoutesResource struct {
Client HeadscaleClientInterface
}
func (*RoutesResource) Delete ¶
func (r *RoutesResource) Delete(ctx context.Context, id string) error
func (*RoutesResource) Disable ¶
func (r *RoutesResource) Disable(ctx context.Context, id string) error
func (*RoutesResource) Enable ¶
func (r *RoutesResource) Enable(ctx context.Context, id string) error
func (*RoutesResource) List ¶
func (r *RoutesResource) List(ctx context.Context) (RoutesResponse, error)
type RoutesResponse ¶
type RoutesResponse struct {
Routes []Route `json:"routes"`
}
type UpdatePolicyRequest ¶
type UpdatePolicyRequest struct {
Policy string `json:"policy"`
}
type UserResource ¶
type UserResource struct {
Client HeadscaleClientInterface
}
func (*UserResource) Get ¶
func (u *UserResource) Get(ctx context.Context, name string) (UserResponse, error)
func (*UserResource) List ¶
func (u *UserResource) List(ctx context.Context) (UsersResponse, error)
type UserResponse ¶
type UserResponse struct {
User User `json:"user"`
}
type UsersResponse ¶
type UsersResponse struct {
Users []User `json:"user"`
}
Click to show internal directories.
Click to hide internal directories.