Documentation
¶
Index ¶
- Variables
- type Client
- func (c *Client) CreatePreAuthKey(ctx context.Context, preAuthKeyConfig PreAuthKeyConfig) (status PreAuthKeyStatus, preAuthKey PreAuthKeyResponse, err error)
- func (c *Client) CreateUser(ctx context.Context, name string) (status UserStatus, user UserConfig, err error)
- func (c *Client) DeleteUser(ctx context.Context, name string) (status UserStatus, err error)
- func (c *Client) GetUser(ctx context.Context, name string) (status UserStatus, user UserConfig, err error)
- func (c *Client) ListUsers(ctx context.Context) (users []UserConfig, err error)
- type PreAuthKeyConfig
- type PreAuthKeyResponse
- type PreAuthKeyStatus
- type UserConfig
- type UserCreationResponse
- type UserStatus
Constants ¶
This section is empty.
Variables ¶
var ( // ErrUserNotFound : error returned when a headscale user is not found ErrUserNotFound = errors.New("Headscale : User not found") )
Functions ¶
This section is empty.
Types ¶
type Client ¶
Client : struct that define a Headscale Client
func NewClient ¶
func NewClient() *Client
NewClient returns a Headscale client and instantiatethe http client
func (*Client) CreatePreAuthKey ¶
func (c *Client) CreatePreAuthKey(ctx context.Context, preAuthKeyConfig PreAuthKeyConfig) (status PreAuthKeyStatus, preAuthKey PreAuthKeyResponse, err error)
CreatePreAuthKey creates a preAuthKey from a PreAuthKeyConfig
func (*Client) CreateUser ¶
func (c *Client) CreateUser(ctx context.Context, name string) (status UserStatus, user UserConfig, err error)
CreateUser create a new Headscale user and return its status
func (*Client) DeleteUser ¶
DeleteUser delete a headscale user from the control plance and return deletion status
func (*Client) GetUser ¶
func (c *Client) GetUser(ctx context.Context, name string) (status UserStatus, user UserConfig, err error)
GetUser : return a Headscale user and its status
type PreAuthKeyConfig ¶
type PreAuthKeyConfig struct {
User string `json:"name"`
Reusable bool `json:"reusable"`
Ephemeral bool `json:"ephemeral"`
Expiration time.Time `json:"expiration"`
Tags []string `json:"acl_tags"`
}
PreAuthKeyConfig is used to create a preAuthKey
type PreAuthKeyResponse ¶
type PreAuthKeyResponse struct {
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"`
} `json:"preAuthKey"`
}
PreAuthKeyResponse stores the HEadscale response
type PreAuthKeyStatus ¶
type PreAuthKeyStatus uint8
PreAuthKeyStatus defines the status of a Headscale preauthkey
const ( PreAuthKeyCreated PreAuthKeyStatus = iota PreAuthKeyExists PreAuthKeyStatus = iota PreAuthKeyDeleted PreAuthKeyStatus = iota PreAuthKeyUnknown PreAuthKeyStatus = iota PreAuthKeyError PreAuthKeyStatus = iota )
Instantiate the PreAuthKeyStatus enum
type UserConfig ¶
type UserConfig struct {
ID uint32 `json:"id,string"`
Name string `json:"name"`
CreatedAt time.Time `json:"createdAt"`
}
UserConfig : struct that defines a Headscale users
type UserCreationResponse ¶
type UserCreationResponse struct {
User UserConfig `json:"user"`
}
type UserStatus ¶
type UserStatus uint8
UserStatus : defined the status of a Headscale user
const ( UserCreated UserStatus = iota UserExists UserStatus = iota UserDeleted UserStatus = iota UserUnknown UserStatus = iota UserError UserStatus = iota )
Defined UserStatus enum values