x0

package
v0.0.0-...-9418498 Latest Latest
Warning

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

Go to latest
Published: Jul 20, 2021 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ErrorCodeGenericUnexpectedError   = 1000
	ErrorCodeGenericUnauthorized      = 1001
	ErrorCodeGenericBadQueryParameter = 1002
	ErrorCodeGenericBadRequestBody    = 1003
	ErrorCodeGenericNamespaceNotFound = 1004
	ErrorCodeGenericElementNotFound   = 1005
	ErrorCodeGenericInviteNotFound    = 1006

	ErrorCodeNamespaceIllegalNamespaceID = 2000
	ErrorCodeNamespaceNamespaceIDInUse   = 2001
	ErrorCodeNamespaceInvalidInviteCode  = 2002

	ErrorCodeElementElementKeyInUse          = 3000
	ErrorCodeElementNamespaceDeactivated     = 3001
	ErrorCodeElementPasteEmptyPasteContent   = 3100
	ErrorCodeElementRedirectInvalidTargetURL = 3200

	ErrorCodeInviteInvitesDisabled = 4000
	ErrorCodeInviteInviteCodeInUse = 4001
)
View Source
const (
	PublicInstance        = "https://api.x0.tf"
	PublicStagingInstance = "https://api.s.x0.tf"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code    int                    `json:"code"`
	Message string                 `json:"message"`
	Data    map[string]interface{} `json:"data"`
}

APIError represents a x0-specific error structure returned from the x0 API

func (*APIError) Error

func (err *APIError) Error() string

Error formats a x0-specific error

type Client

type Client struct {
	Instance   *InstanceClient
	Namespaces *NamespacesClient
	Elements   *ElementsClient
	Invites    *InvitesClient
}

Client represents the entrypoint to use the x0 API client

func NewClient

func NewClient(instance string) *Client

NewClient creates a new x0 API client

func NewClientWithToken

func NewClientWithToken(instance, token string) *Client

NewClientWithToken creates a new x0 API client with an auth token set

type ElementsClient

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

ElementsClient is used to execute API requests directed to the element-related scopes

func (*ElementsClient) CreatePaste

func (client *ElementsClient) CreatePaste(namespaceID string, data *schema.CreatePasteElementData) (*schema.Element, error)

CreatePaste creates a new paste element

func (*ElementsClient) CreateRedirect

func (client *ElementsClient) CreateRedirect(namespaceID string, data *schema.CreateRedirectElementData) (*schema.Element, error)

CreateRedirect creates a new redirect element

func (*ElementsClient) Delete

func (client *ElementsClient) Delete(namespaceID, key string) error

Delete deletes an existing element

func (*ElementsClient) GetList

func (client *ElementsClient) GetList(limit, skip int) (*schema.Elements, error)

GetList requests a paginated list of existent elements

func (*ElementsClient) GetListInNamespace

func (client *ElementsClient) GetListInNamespace(namespaceID string, limit, skip int) (*schema.Elements, error)

GetListInNamespace requests a paginated list of existent elements in a specific namespace

func (*ElementsClient) Patch

func (client *ElementsClient) Patch(namespaceID, key string, data *schema.PatchElementData) (*schema.Element, error)

Patch patches an existing element

type InstanceClient

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

InstanceClient is used to execute API requests directed to the general instance

func (*InstanceClient) GetInfo

func (client *InstanceClient) GetInfo() (*schema.InstanceInfo, error)

GetInfo requests the instance information for the specified x0 instance

type InvitesClient

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

InvitesClient is used to execute API requests directed to the invite-related scopes

func (*InvitesClient) Create

func (client *InvitesClient) Create(data *schema.CreateInviteData) (*schema.Invite, error)

Create creates a new invite

func (*InvitesClient) Delete

func (client *InvitesClient) Delete(code string) error

Delete deletes an existing invite

func (*InvitesClient) GetList

func (client *InvitesClient) GetList(limit, skip int) (*schema.Invites, error)

GetList requests a paginated list of existent invites

func (*InvitesClient) GetSingle

func (client *InvitesClient) GetSingle(code string) (*schema.Invite, error)

GetSingle requests a single invite

func (*InvitesClient) Patch

func (client *InvitesClient) Patch(code string, data *schema.PatchInviteData) (*schema.Invite, error)

Patch patches an existing invite

type NamespacesClient

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

NamespacesClient is used to execute API requests directed to the namespace-related scopes

func (*NamespacesClient) Create

Create creates a new namespace

func (*NamespacesClient) Delete

func (client *NamespacesClient) Delete(id string) error

Delete deletes an existing namespace

func (*NamespacesClient) GetList

func (client *NamespacesClient) GetList(limit, skip int) (*schema.Namespaces, error)

GetList requests a paginated list of existent namespaces

func (*NamespacesClient) GetSingle

func (client *NamespacesClient) GetSingle(id string) (*schema.Namespace, error)

GetSingle requests a single namespace

func (*NamespacesClient) Patch

func (client *NamespacesClient) Patch(id string, data *schema.PatchNamespaceData) (*schema.Namespace, error)

Patch patches an existing namespace

func (*NamespacesClient) ResetToken

func (client *NamespacesClient) ResetToken(id string) (*schema.Namespace, error)

ResetToken resets the token of an existing namespace

Jump to

Keyboard shortcuts

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