token

package
v2.0.14 Latest Latest
Warning

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

Go to latest
Published: Jan 21, 2025 License: Apache-2.0 Imports: 6 Imported by: 3

Documentation

Index

Constants

View Source
const (
	TokenAPI = "$GVT.%s.API.TOKEN"
)

Variables

View Source
var (
	ErrTokenNotFound      = errors.New("product not found")
	ErrTokenExistsAlready = errors.New("product exists already")
	ErrInvalidTokenToken  = errors.New("invalid product token")
)
View Source
var (
	ErrSubscriptionNotFound = errors.New("subscription not found")
)

Functions

This section is empty.

Types

type CreateTokenReply

type CreateTokenReply struct {
	core.ErrorReply
	Token   string        `json:"token"`
	Setting *TokenSetting `json:"setting"`
}

type CreateTokenRequest

type CreateTokenRequest struct {
	TokenID string        `json:"tokenID"`
	Setting *TokenSetting `json:"setting"`
}

type DeleteTokenReply

type DeleteTokenReply struct {
	core.ErrorReply
}

type DeleteTokenRequest

type DeleteTokenRequest struct {
	TokenID string `json:"tokenID"`
}

type InfoTokenReply

type InfoTokenReply struct {
	core.ErrorReply
	Token   string        `json:"token"`
	Setting *TokenSetting `json:"setting"`
}

type InfoTokenRequest

type InfoTokenRequest struct {
	TokenID string `json:"token"`
}

type ListAvailablePermissionsReply

type ListAvailablePermissionsReply struct {
	core.ErrorReply

	Permissions map[string]string `json:"permissions"`
}

type ListAvailablePermissionsRequest

type ListAvailablePermissionsRequest struct {
}

type ListTokensReply

type ListTokensReply struct {
	core.ErrorReply

	Tokens []*TokenSetting `json:"products"`
}

type ListTokensRequest

type ListTokensRequest struct {
}

type Options

type Options struct {
	Domain  string
	Verbose bool
}

func NewOptions

func NewOptions() *Options

type Permission

type Permission map[string]interface{}

type SubscriptionInfo

type SubscriptionInfo struct {
	Subscriptions map[string]string `json:"subscriptions"` // key: subscription id, value: product id
}

type TokenClient

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

func NewTokenClient

func NewTokenClient(client *core.Client, options *Options) *TokenClient

func (*TokenClient) CreateToken

func (pc *TokenClient) CreateToken(tokenID string, tokenSetting *TokenSetting) (string, *TokenSetting, error)

func (*TokenClient) DeleteToken

func (pc *TokenClient) DeleteToken(tokenID string) error

func (*TokenClient) GetToken

func (pc *TokenClient) GetToken(tokenID string) (string, *TokenSetting, error)

func (*TokenClient) ListAvailablePermissions

func (pc *TokenClient) ListAvailablePermissions() (map[string]string, error)

func (*TokenClient) ListTokens

func (pc *TokenClient) ListTokens() ([]*TokenSetting, error)

func (*TokenClient) UpdateToken

func (pc *TokenClient) UpdateToken(tokenID string, productSetting *TokenSetting) (*TokenSetting, error)

type TokenSetting

type TokenSetting struct {
	ID           string                 `json:"id"`
	Description  string                 `json:"desc"`
	Enabled      bool                   `json:"enabled"`
	Permissions  map[string]*Permission `json:"permissions"`
	Subscription *SubscriptionInfo      `json:"subscription"`
	CreatedAt    time.Time              `json:"createdAt"`
	UpdatedAt    time.Time              `json:"updatedAt"`
}

func (*TokenSetting) CheckPermission

func (ts *TokenSetting) CheckPermission(perm string) bool

func (*TokenSetting) CheckSubscription

func (ts *TokenSetting) CheckSubscription(subscriptionID string) bool

func (*TokenSetting) GetSubscriptionByProduct

func (ts *TokenSetting) GetSubscriptionByProduct(product string) (string, error)

type UpdateTokenReply

type UpdateTokenReply struct {
	core.ErrorReply
	Setting *TokenSetting `json:"setting"`
}

type UpdateTokenRequest

type UpdateTokenRequest struct {
	TokenID string        `json:"token"`
	Setting *TokenSetting `json:"setting"`
}

Jump to

Keyboard shortcuts

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