Documentation
¶
Overview ¶
Package vctr provides a simple to use API wrapper for the vctr REST API.
Index ¶
Constants ¶
const Version = "1.0.0"
The current package version.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ApiKeyCreatedModel ¶
type ApiKeyCreatedModel struct {
*ApiKeyModel
Key string `json:"key"`
}
type ApiKeyModel ¶
type ApiKeyModel struct {
*EntityModel
LastAccess Time `json:"last_access"`
AccessCount int `json:"access_count"`
}
type Client ¶
type Client struct {
// Authorization endpoints.
Auth *authClient
// Users endpoints.
Users *userClient
// Links endpoints.
Links *linksClient
// API Key endpoints.
ApiKey *apikeyClient
// contains filtered or unexported fields
}
Client provides a simple interface to access the vctr REST API gateway.
func NewClient ¶
NewClient creates a new client instance connecting to the passed vctr instance endpoint, for example https://s.zekro.de or https://vctr.yourhost.com.
You can also pass optional authorization header tokens which can be used to authenticate against the API, but it is recommented to use the methods NewClientWithApiToken and NewClientWithSessionToken for that purpose.
func NewClientWithApiToken ¶
NewClientWithApiKey is shorthand for NewClient with an initial API key used to authenticate against the API.
func NewClientWithSessionToken ¶
NewClientWithSessionKey is shorthand for NewClient with an initial session key used to authenticate against the API.
func (*Client) SetApiToken ¶
SetApiToken sets the passed API token to the client so that it will be used in subsequent requests to authenticate against the API.
func (*Client) SetSessionToken ¶
SetSessionToken sets the passed session token to the client so that it will be used in subsequent requests to authenticate against the API.
type CountModel ¶
type CountModel struct {
Count int `json:"count"`
}
type EntityModel ¶
type LinkCreateModel ¶
type LinkModel ¶
type LinkModel struct {
*EntityModel
Ident string `json:"ident"`
Destination string `json:"destination"`
Enabled bool `json:"enabled"`
PermanentRedirect bool `json:"permanent_redirect"`
PasswordRequired bool `json:"password_required"`
LastAccess Time `json:"last_access"`
AccessCount int `json:"access_count"`
UniqueAccessCount int `json:"unique_access_count"`
TotalAccessLimit int `json:"total_access_limit"`
Expires Time `json:"expires"`
Creator *UserModel `json:"creator"`
}
type LoginModel ¶
type Permissions ¶
type Permissions int
const ( PermViewLinks Permissions = 1 << (iota + 1) PermCreateLinks PermUpdateLinks PermDeleteLinks PermViewUsers PermCreateUsers PermUpdateUsers PermDeleteUsers PermPerformStateChanges PermCreateApiKey PermUnset Permissions = -1 PermAdmin Permissions = 2147483647 )
type ResponseError ¶
ResponseError wraps a HTTP response error with error response code and an API error message.
ResponseError implements the error interface.
func (*ResponseError) Error ¶
func (r *ResponseError) Error() string
type Time ¶
func (*Time) UnmarshalJSON ¶
type UserCreateModel ¶
type UserCreateModel struct {
UserName string `json:"username"`
Password string `json:"password"`
Permissions Permissions `json:"permissions"`
}
type UserLoginModel ¶
type UserModel ¶
type UserModel struct {
*EntityModel
UserName string `json:"username"`
Permissions Permissions `json:"permissions"`
LastLogin Time `json:"last_login"`
}
func (*UserModel) Links ¶
Links returns a list io links of the current user entity.
limit defines the maximum ammount of response entities and offset defines the number of entities to be skipped.
func (*UserModel) LinksCount ¶
func (u *UserModel) LinksCount() (res *CountModel, err error)
LinksCount returns the number of links owned by the current user entity.
func (*UserModel) SearchLinks ¶
SearchLinks searches the links of the current user by the given query.
limit defines the maximum ammount of response entities and offset defines the number of entities to be skipped.
type UserUpdateModel ¶
type UserUpdateModel struct {
UserName string `json:"username"`
Password string `json:"password"`
Permissions Permissions `json:"permissions"`
}