command

package
v0.0.0-...-2e5e463 Latest Latest
Warning

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

Go to latest
Published: May 14, 2018 License: MIT Imports: 13 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ClientSchema

type ClientSchema struct {
	Arguments []schemas.MessagePacket `json:"arguments"`
	Enabled   *bool                   `json:"enabled"`
	Response  EmbeddedResponseSchema  `json:"response"`
}

ClientSchema is the schema the data from the client will be marshalled into

func (ClientSchema) DumpBody

func (cs ClientSchema) DumpBody(data []byte) ([]byte, error)

DumpBody dumps the body data bytes into this specific schema and returns the bytes from this

type Command

type Command struct {
	Conn  *rethink.Connection // The RethinkDB connection
	Table string              // The database table we're using
}

Command is the struct that implements the handler interface for the command resource

func (*Command) Create

func (c *Command) Create(ctx *gin.Context)

Create creates a new record

func (*Command) Delete

func (c *Command) Delete(ctx *gin.Context)

Delete soft-deletes a record

func (*Command) GetAll

func (c *Command) GetAll(ctx *gin.Context)

GetAll returns all records associated with the token

func (*Command) GetSingle

func (c *Command) GetSingle(ctx *gin.Context)

GetSingle returns a single record

func (*Command) ReturnOne

func (c *Command) ReturnOne(filter map[string]interface{}) (ResponseSchema, error)

ReturnOne retrieves a single record given the filter provided

func (*Command) Routes

func (c *Command) Routes() []types.RouteDetails

Routes returns the routing information for this endpoint

func (*Command) Update

func (c *Command) Update(ctx *gin.Context)

Update handles the updating of a record if the record exists

type CreationSchema

type CreationSchema struct {
	ClientSchema
	// Ignore these fields in user input, they will be filled automatically by the API
	Count     int       `json:"count"`
	CreatedAt time.Time `json:"createdAt"`
	DeletedAt float64   `json:"deletedAt"`
	Token     string    `json:"token"`
	Name      string    `json:"name"`
	Enabled   bool      `json:"enabled"`
}

CreationSchema is all the data required for a new command to be created

func (CreationSchema) DumpBody

func (cs CreationSchema) DumpBody(data []byte) ([]byte, error)

DumpBody dumps the body data bytes into this specific schema and returns the bytes from this

type EmbeddedResponseSchema

type EmbeddedResponseSchema struct {
	Action  bool                    `json:"action" jsonapi:"attr,action"`
	Message []schemas.MessagePacket `json:"message" jsonapi:"attr,message"`
	Role    int                     `json:"role" jsonapi:"attr,role"`
	Target  string                  `json:"target" jsonapi:"attr,target"`
	User    string                  `json:"user" jsonapi:"attr,user"`
}

EmbeddedResponseSchema is the schema that is stored under the response key in ResponseSchema

func (EmbeddedResponseSchema) GetAPITag

func (r EmbeddedResponseSchema) GetAPITag(lookup string) string

GetAPITag allows each of these types to implement the JSONAPISchema interface

type ResponseSchema

type ResponseSchema struct {
	ID        string                  `jsonapi:"primary,command"`
	Arguments []schemas.MessagePacket `jsonapi:"attr,arguments"`
	Count     int                     `jsonapi:"attr,count"`
	CreatedAt string                  `jsonapi:"meta,createdAt"`
	Enabled   bool                    `jsonapi:"attr,enabled"`
	Name      string                  `jsonapi:"attr,name"`
	Response  EmbeddedResponseSchema  `jsonapi:"attr,response"`
	Token     string                  `jsonapi:"meta,token"`
}

ResponseSchema is the schema for the data that will be sent out to the client

func (ResponseSchema) DumpBody

func (rs ResponseSchema) DumpBody(data []byte) ([]byte, error)

DumpBody dumps the body data bytes into this specific schema and returns the bytes from this

func (ResponseSchema) GetAPITag

func (rs ResponseSchema) GetAPITag(lookup string) string

GetAPITag allows each of these types to implement the JSONAPISchema interface

func (ResponseSchema) JSONAPIMeta

func (rs ResponseSchema) JSONAPIMeta() *types.Meta

JSONAPIMeta returns a meta object for the response

type UpdateEmbeddedResponseSchema

type UpdateEmbeddedResponseSchema struct {
	Action  *bool                   `json:"action,omitempty" jsonapi:"attr,action"`
	Message []schemas.MessagePacket `json:"message,omitempty" jsonapi:"attr,message"`
	Role    *int                    `json:"role,omitempty" jsonapi:"attr,role"`
	Target  *string                 `json:"target,omitempty" jsonapi:"attr,target"`
	User    *string                 `json:"user,omitempty" jsonapi:"attr,user"`
}

UpdateEmbeddedResponseSchema is the schema that is stored under the response key in UpdateSchema

func (UpdateEmbeddedResponseSchema) GetAPITag

func (r UpdateEmbeddedResponseSchema) GetAPITag(lookup string) string

GetAPITag allows each of these types to implement the JSONAPISchema interface

type UpdateSchema

type UpdateSchema struct {
	Arguments []schemas.MessagePacket      `json:"arguments,omitempty"`
	Enabled   *bool                        `json:"enabled,omitempty"`
	Response  UpdateEmbeddedResponseSchema `json:"response,omitempty"`
}

UpdateSchema is ClientSchema that is used when updating

func (UpdateSchema) DumpBody

func (us UpdateSchema) DumpBody(data []byte) ([]byte, error)

DumpBody dumps the body data bytes into this specific schema and returns the bytes from this

Jump to

Keyboard shortcuts

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