schema

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2021 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Forbidden = &Error{
	StatusCode: http.StatusForbidden,
	ErrCode:    riposo.ErrCodeForbidden,
	Text:       "Forbidden",
	Message:    "This user cannot access this resource.",
}

Forbidden is a standard forbidden error response.

View Source
var MethodNotAllowed = &Error{
	StatusCode: http.StatusMethodNotAllowed,
	ErrCode:    riposo.ErrCodeMethodNotAllowed,
	Text:       "Method Not Allowed",
	Message:    "Method not allowed on this endpoint.",
}

MethodNotAllowed is a standard unauthorized error response.

View Source
var MissingAuthToken = &Error{
	StatusCode: http.StatusUnauthorized,
	ErrCode:    riposo.ErrCodeMissingAuthToken,
	Text:       "Unauthorized",
	Message:    "Please authenticate yourself to use this endpoint.",
}

MissingAuthToken is a standard unauthorized error response.

View Source
var NotFound = &Error{
	StatusCode: 404,
	ErrCode:    riposo.ErrCodeMissingResource,
	Text:       "Not Found",
	Message:    "The resource you are looking for could not be found.",
}

NotFound is a standard not found error response.

View Source
var NotModified = &Error{
	StatusCode: http.StatusNotModified,
}

NotModified is a standard not modified error response.

Functions

This section is empty.

Types

type Error

type Error struct {
	StatusCode int            `json:"code"`
	ErrCode    riposo.ErrCode `json:"errno"`
	Text       string         `json:"error"`
	Message    string         `json:"message,omitempty"`
	Info       string         `json:"info,omitempty"`
	Details    interface{}    `json:"details,omitempty"`
}

Error is an error response.

func BadRequest

func BadRequest(err error) *Error

BadRequest generates an Error.

func InternalError

func InternalError(err error) *Error

InternalError generates an Error from an internal error.

func InvalidBody

func InvalidBody(field, description string) *Error

InvalidBody generates an Error.

func InvalidPath

func InvalidPath(description string) *Error

InvalidPath generates an Error.

func InvalidQuery

func InvalidQuery(description string) *Error

InvalidQuery generates an Error.

func InvalidResource

func InvalidResource(path riposo.Path) *Error

InvalidResource generates a specific resource not found Error.

func MissingResource

func MissingResource(id, resourceName string) *Error

MissingResource generates an Error.

func ModifiedMeanwhile

func ModifiedMeanwhile(existing *Object) *Error

ModifiedMeanwhile generates a PreconditionFailed Error.

func (*Error) Error

func (e *Error) Error() string

Error implements the error interface.

func (*Error) HTTPStatus

func (e *Error) HTTPStatus() int

HTTPStatus returns the http status code.

type Heartbeat

type Heartbeat struct {
	Storage    bool `json:"storage"`
	Permission bool `json:"permission"`
	Cache      bool `json:"cache"`
}

Heartbeat response object.

type Hello

type Hello struct {
	ProjectName    string `json:"project_name"`
	ProjectDocs    string `json:"project_docs"`
	ProjectVersion string `json:"project_version"`
	HTTPAPIVersion string `json:"http_api_version"`
	URL            string `json:"url"`
	EOS            string `json:"eos,omitempty"`
	Settings       struct {
		BatchMaxRequests int  `json:"batch_max_requests"`
		Readonly         bool `json:"readonly"`
	} `json:"settings"`
	Capabilities interface{} `json:"capabilities"`
}

Hello response object.

type Object

type Object struct {
	ID      string
	ModTime riposo.Epoch
	Deleted bool
	Extra   []byte
}

Object is a stored object.

func (*Object) DecodeExtra

func (o *Object) DecodeExtra(v interface{}) error

DecodeExtra unmarshals extra Extra into a value.

func (*Object) EncodeExtra

func (o *Object) EncodeExtra(v interface{}) error

EncodeExtra marshals v into extra Extra.

func (*Object) Get

func (o *Object) Get(field string) Value

Get returns the value of field.

func (*Object) MarshalJSON

func (o *Object) MarshalJSON() ([]byte, error)

MarshalJSON implements json.Marshaler interface.

func (*Object) Patch

func (o *Object) Patch(x *Object) error

Patch merges attributes of x into o.

func (*Object) UnmarshalJSON

func (o *Object) UnmarshalJSON(p []byte) error

UnmarshalJSON implements custom JSON unmarshaler.

func (*Object) Update

func (o *Object) Update(x *Object)

Update uses values of x to update o.

type Objects

type Objects struct {
	Data []*Object `json:"data"`
}

Objects contains a slice of objects.

type PermissionSet

type PermissionSet map[string][]string

PermissionSet contain a list of principals by type of access.

func (PermissionSet) Add

func (p PermissionSet) Add(perm, principal string)

Add adds a single principal to the set.

type Resource

type Resource struct {
	StatusCode  int           `json:"-"`
	Data        *Object       `json:"data,omitempty"`
	Permissions PermissionSet `json:"permissions,omitempty"`
}

Resource contain a combination of object and permissions.

func (*Resource) HTTPStatus

func (r *Resource) HTTPStatus() int

HTTPStatus returns the http status code.

type Value

type Value gjson.Result

Value is a parameter/object value.

func ParseValue

func ParseValue(s string) Value

ParseValue parses a value.

func StringValue

func StringValue(s string) Value

StringValue converts a string literal to a value.

func (Value) Bool

func (v Value) Bool() bool

Bool returns the boolean representation of the value.

func (Value) Exists

func (v Value) Exists() bool

Exists returns true it the value exists.

func (Value) Float

func (v Value) Float() float64

Float returns the numeric representation of the value.

func (Value) Int

func (v Value) Int() int64

Int returns the integer representation of the value.

func (Value) IsNull

func (v Value) IsNull() bool

IsNull returns true if value is null.

func (Value) MarshalJSON

func (v Value) MarshalJSON() ([]byte, error)

MarshalJSON implement custom JSON marshaler.

func (Value) String

func (v Value) String() string

String returns the string representation of the value.

func (*Value) UnmarshalJSON

func (v *Value) UnmarshalJSON(p []byte) error

UnmarshalJSON implement custom JSON unmarshaler.

func (Value) Value

func (v Value) Value() interface{}

Value returns a the value converted to the appropriate type.

Jump to

Keyboard shortcuts

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