api

package
v2.0.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APIError

type APIError struct {
	Code    int
	Message string
}

APIError is the error object

func NewAPIError

func NewAPIError(code int, message string, params ...interface{}) APIError

NewAPIError create new API error with code and message

func (APIError) Error

func (e APIError) Error() string

Error return error message

type Api

type Api interface {
	SavedObject() SavedObjectApi
	ShortenUrl() ShortenUrlApi
	Status() StatusApi
	Client() *resty.Client
}

Api is the main API interface

func New

func New(client *resty.Client) Api

New permit to get the default implementation of Api interface

type DefaultApi

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

DefaultApi is the default implementation of Api interface

func (DefaultApi) Client

func (h DefaultApi) Client() *resty.Client

func (DefaultApi) SavedObject

func (h DefaultApi) SavedObject() SavedObjectApi

func (DefaultApi) ShortenUrl

func (h DefaultApi) ShortenUrl() ShortenUrlApi

func (DefaultApi) Status

func (h DefaultApi) Status() StatusApi

type DefaultSavedObjectApi

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

DefaultSavedObjectApi is the default implementation of SavedObjectApi interface

func (DefaultSavedObjectApi) BulkCreate

func (h DefaultSavedObjectApi) BulkCreate(tenantId string, overwrite bool, bulks []Object) (createdObjects []Object, err error)

func (DefaultSavedObjectApi) BulkGet

func (h DefaultSavedObjectApi) BulkGet(tenantId string, bulks []SavedObjectBulkGetOption) (objects []Object, err error)

func (DefaultSavedObjectApi) Create

func (h DefaultSavedObjectApi) Create(tenantId string, object *Object, overwrite bool) (createdObject *Object, err error)

func (DefaultSavedObjectApi) Delete

func (h DefaultSavedObjectApi) Delete(tenantId string, objectType string, objectId string, force bool) (err error)

func (DefaultSavedObjectApi) Export

func (h DefaultSavedObjectApi) Export(tenantId string, option SavedObjectExportOption) (data []byte, err error)

func (DefaultSavedObjectApi) Find

func (h DefaultSavedObjectApi) Find(tenantId string, option SavedObjectFindOption) (objects []Object, err error)

func (DefaultSavedObjectApi) Get

func (h DefaultSavedObjectApi) Get(tenantId string, objectType string, objectId string) (object *Object, err error)

func (DefaultSavedObjectApi) Import

func (h DefaultSavedObjectApi) Import(tenantId string, option SavedObjectImportOption, data []byte) (res map[string]any, err error)

func (DefaultSavedObjectApi) Update

func (h DefaultSavedObjectApi) Update(tenantId string, object *Object) (updatedObject *Object, err error)

type DefaultShortenUrlApi

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

DefaultShortenUrlApi is the default implementation of ShortenUrlApi interface

func (DefaultShortenUrlApi) Create

func (h DefaultShortenUrlApi) Create(url string) (shortUrl string, err error)

type DefaultStatusApi

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

DefaultStatusApi is the default implementation of StatusApi interface

func (DefaultStatusApi) Status

func (h DefaultStatusApi) Status() (status map[string]any, err error)

type Object

type Object struct {
	Type                 string           `json:"type,omitempty"`
	Id                   string           `json:"id,omitempty"`
	Attributes           map[string]any   `json:"attributes"`
	References           []map[string]any `json:"references,omitempty"`
	Version              string           `json:"version,omitempty"`
	CoreMigrationVersion string           `json:"coreMigrationVersion,omitempty"`
	CreatedAt            *time.Time       `json:"created_at,omitempty"`
	MigrationVersion     map[string]any   `json:"migrationVersion,omitempty"`
	UpdatedAt            *time.Time       `json:"updatedAt,omitempty"`
	OriginId             string           `json:"originId,omitempty"`
}

Object is the object data

type SavedObjectApi

type SavedObjectApi interface {
	Get(tenantId string, objectType string, objectId string) (object *Object, err error)
	BulkGet(tenantId string, bulks []SavedObjectBulkGetOption) (objects []Object, err error)
	Find(tenantId string, option SavedObjectFindOption) (objects []Object, err error)
	Create(tenantId string, object *Object, overwrite bool) (createdObject *Object, err error)
	BulkCreate(tenantId string, overwrite bool, bulks []Object) (createdObjects []Object, err error)
	Update(tenantId string, object *Object) (updatedObject *Object, err error)
	Delete(tenantId string, objectType string, objectId string, force bool) (err error)
	Export(tenantId string, option SavedObjectExportOption) (data []byte, err error)
	Import(tenantId string, option SavedObjectImportOption, data []byte) (res map[string]any, err error)
}

SavedObjectApi is the interface to call with saved object API

func NewSavedObjectApi

func NewSavedObjectApi(client *resty.Client) SavedObjectApi

NewSavedObjectApi permit to get default implementation of SavedObjectApi interface

type SavedObjectBulkGetOption

type SavedObjectBulkGetOption struct {
	Type   string   `json:"type"`
	Id     string   `json:"id"`
	Fields []string `json:"fields,omitempty"`
}

SavedObjectBulkGetOption is the option when call bulk get API

type SavedObjectBulkResponse

type SavedObjectBulkResponse struct {
	SavedObjects []Object `json:"saved_objects"`
}

SavedObjectBulkCreateResponse is the repsonse when call bulk create API

type SavedObjectExportOption

type SavedObjectExportOption struct {
	Type                  string                     `json:"type,omitempty"`
	Objects               []SavedObjectBulkGetOption `json:"objects,omitempty"`
	IncludeReferencesDeep *bool                      `json:"includeReferencesDeep,omitempty"`
	ExcludeExportDetails  *bool                      `json:"excludeExportDetails,omitempty"`
}

SavedObjectExportOption the option when call export API

type SavedObjectFindOption

type SavedObjectFindOption struct {
	Type                  string   `json:"type"`
	PerPage               int      `json:"per_page,omitempty"`
	Page                  int      `json:"page,omitempty"`
	Search                string   `json:"search,omitempty"`
	DefaultSearchOperator string   `json:"default_search_operator,omitempty"`
	SearchFields          []string `json:"search_fields,omitempty"`
	Fields                []string `json:"fields,omitempty"`
	SortField             string   `json:"sort_field,omitempty"`
	HasReference          string   `json:"has_reference,omitempty"`
	Filter                string   `json:"filter,omitempty"`
}

SavedObjectFindOption is the option when call find API

type SavedObjectFindResponse

type SavedObjectFindResponse struct {
	Total        int64    `json:"total"`
	SavedObjects []Object `json:"saved_objects"`
}

SavedObjectFindResponse is the response when cal find API

type SavedObjectImportOption

type SavedObjectImportOption struct {
	CreateNewCopies bool `json:"createNewCopies,omitempty"`
	Overwrite       bool `json:"overwrite,omitempty"`
}

SavedObjectImportOption is the option when call import API

type ShortenUrlApi

type ShortenUrlApi interface {
	Create(url string) (shortUrl string, err error)
}

ShortenUrlApi is the interface to call with shorten API

func NewShortenUrlApi

func NewShortenUrlApi(client *resty.Client) ShortenUrlApi

NewShortenUrlApi permit to get default implementation of ShortenUrlApi interface

type ShortenUrlApiCreatePayload

type ShortenUrlApiCreatePayload struct {
	Url string `json:"url"`
}

ShortenUrlApiCreatePayload is the payload to send when create shorten URL

type ShortenUrlApiCreateResponse

type ShortenUrlApiCreateResponse struct {
	UrlId string `json:"urlId"`
}

ShortenUrlApiCreateResponse is the response when create shorten URL

type StatusApi

type StatusApi interface {
	Status() (status map[string]any, err error)
}

func NewStatusApi

func NewStatusApi(client *resty.Client) StatusApi

NewStatusApi permit to get default implementation of StatusApi interface

Jump to

Keyboard shortcuts

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