kervan

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Apr 19, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

README

kervan-go

Kervan Go is a Go client library for accessing the Kervan API. It provides convenient access to Kervan's API from applications written in the Go language.

Installation

go get github.com/kervandev/kervan-go

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateLicenceCheckJWT

func GenerateLicenceCheckJWT(licenceKey, ip_address string, data map[string]string, secret string) (string, error)

Types

type API

type API struct {
	EndPoint string `json:"end_point"`
	Token    string `json:"token"`
}

API is the main struct for the Kervan API

func NewAPI

func NewAPI(token string) *API

NewAPI creates a new KervanAPI struct

func NewCustomAPI

func NewCustomAPI(endpoint, token string) *API

NewAPIWithEndpoint creates a new KervanAPI struct with a custom endpoint

func (*API) CheckLicence

func (t *API) CheckLicence(payload *CheckLicencePayload) (*CheckLicenceResponse, error)

func (*API) GetVersion

func (t *API) GetVersion() (*GetVersionResponse, error)

type CheckLicencePayload

type CheckLicencePayload struct {
	Token string `json:"token"`
}

type CheckLicenceResponse

type CheckLicenceResponse struct {
	Token string `json:"token"`
}

type ErrorResponse

type ErrorResponse struct {
	Error string `json:"error"`
}

type GetVersionResponse

type GetVersionResponse struct {
	Version          string `json:"version"`
	Description      string `json:"description"`
	IsLatest         bool   `json:"is_latest"`
	IsSecurityUpdate bool   `json:"is_security_update"`
	UnattendedUpdate bool   `json:"unattended_update"`
	CreatedAt        string `json:"created_at"`
}

type LicenceCheckJWT

type LicenceCheckJWT struct {
	LicenceKey string            `json:"licence_key"`
	IpAddress  string            `json:"ip_address"`
	Data       map[string]string `json:"data"`
	jwt.RegisteredClaims
}

type LicenceCheckResponseJWT

type LicenceCheckResponseJWT struct {
	IsValid  bool   `json:"is_valid"`
	PlanCode string `json:"plan_code"`
	jwt.RegisteredClaims
}

func ParseLicenceCheckResponseJWT

func ParseLicenceCheckResponseJWT(tokenString, secret string) (claims *LicenceCheckResponseJWT, err error)

Jump to

Keyboard shortcuts

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