Documentation ¶
Index ¶
- Constants
- Variables
- func GuessPluralName(name string) string
- func IsNotFound(err error) bool
- func NewErrors(errors []error) error
- func NormalizeUrl(existingUrl string) (string, error)
- func ValidMod(mod string) bool
- type APIContext
- type APIVersion
- type AccessControl
- type Action
- type ActionHandler
- type ApiError
- type ClientOpts
- type Collection
- type Condition
- type ErrorHandler
- type Field
- type Filter
- type Formatter
- type GenericCollection
- type ListOpts
- type Pagination
- type QueryCondition
- func EQ(value interface{}) *QueryCondition
- func IN(values ...interface{}) *QueryCondition
- func NE(value interface{}) *QueryCondition
- func NOTIN(values ...interface{}) *QueryCondition
- func NOTNULL(value interface{}) *QueryCondition
- func NULL(value interface{}) *QueryCondition
- func NewCondition(mod QueryConditionType, values ...interface{}) *QueryCondition
- func NewConditionFromString(field, mod string, values ...interface{}) *QueryCondition
- type QueryConditionType
- type QueryOptions
- type RancherBaseClient
- type RancherBaseClientImpl
- func (rancherClient *RancherBaseClientImpl) Action(schemaType string, action string, existing *Resource, ...) error
- func (rancherClient *RancherBaseClientImpl) ById(schemaType string, id string, respObject interface{}) error
- func (rancherClient *RancherBaseClientImpl) Create(schemaType string, createObj interface{}, respObject interface{}) error
- func (rancherClient *RancherBaseClientImpl) Delete(existing *Resource) error
- func (rancherClient *RancherBaseClientImpl) GetLink(resource Resource, link string, respObject interface{}) error
- func (rancherClient *RancherBaseClientImpl) GetOpts() *ClientOpts
- func (rancherClient *RancherBaseClientImpl) GetTypes() map[string]Schema
- func (rancherClient *RancherBaseClientImpl) List(schemaType string, opts *ListOpts, respObject interface{}) error
- func (rancherClient *RancherBaseClientImpl) Post(url string, createObj interface{}, respObject interface{}) error
- func (rancherClient *RancherBaseClientImpl) Reload(existing *Resource, output interface{}) error
- func (rancherClient *RancherBaseClientImpl) Update(schemaType string, existing *Resource, updates interface{}, ...) error
- func (rancherClient *RancherBaseClientImpl) Websocket(url string, headers map[string][]string) (*websocket.Conn, *http.Response, error)
- type RawResource
- type ReferenceValidator
- type RequestHandler
- type Resource
- type ResourceCollection
- type ResponseWriter
- type Schema
- type SchemaCollection
- type Schemas
- func (s *Schemas) AddSchema(schema *Schema) *Schemas
- func (s *Schemas) Err() error
- func (s *Schemas) Schema(version *APIVersion, name string) *Schema
- func (s *Schemas) Schemas() []*Schema
- func (s *Schemas) SchemasForVersion(version APIVersion) map[string]*Schema
- func (s *Schemas) Versions() []APIVersion
- type Sort
- type SortOrder
- type Store
- type URLBuilder
- type Validator
- type ValuesMap
Constants ¶
View Source
const ( SELF = "self" COLLECTION = "collection" )
Variables ¶
View Source
var ( COND_EQ = QueryConditionType{"eq", 1} COND_NE = QueryConditionType{"ne", 1} COND_NULL = QueryConditionType{"null", 0} COND_NOTNULL = QueryConditionType{"notnull", 0} COND_IN = QueryConditionType{"in", -1} COND_NOTIN = QueryConditionType{"notin", -1} COND_OR = QueryConditionType{"or", 1} COND_AND = QueryConditionType{"and", 1} )
View Source
var ( ASC = SortOrder("asc") DESC = SortOrder("desc") )
Functions ¶
func GuessPluralName ¶
func IsNotFound ¶
func NormalizeUrl ¶
Types ¶
type APIContext ¶
type APIContext struct { Action string ID string Type string Link string Method string Schema *Schema Schemas *Schemas Version *APIVersion ResponseFormat string ReferenceValidator ReferenceValidator ResponseWriter ResponseWriter QueryOptions *QueryOptions Body map[string]interface{} URLBuilder URLBuilder AccessControl AccessControl Request *http.Request Response http.ResponseWriter }
func (*APIContext) WriteResponse ¶
func (r *APIContext) WriteResponse(code int, obj interface{})
type APIVersion ¶
type AccessControl ¶
type ActionHandler ¶
type ActionHandler func(actionName string, action *Action, request *APIContext) error
type ClientOpts ¶
type Collection ¶
type Collection struct { Type string `json:"type,omitempty" yaml:"type,omitempty"` Links map[string]string `json:"links" yaml:"links,omitempty"` CreateTypes map[string]string `json:"createTypes,omitempty" yaml:"create_types,omitempty"` Actions map[string]string `json:"actions" yaml:"actions,omitempty"` Pagination *Pagination `json:"pagination,omitempty" yaml:"pagination,omitempty"` Sort *Sort `json:"sort,omitempty" yaml:"sort,omitempty"` Filters map[string][]Condition `json:"filters,omitempty" yaml:"filters,omitempty"` //TODO: remove ResourceType string `json:"resourceType"` }
type Condition ¶
type Condition struct { Modifier string `json:"modifier,omitempty" yaml:"modifier,omitempty"` Value interface{} `json:"value,omitempty" yaml:"value,omitempty"` }
type ErrorHandler ¶
type ErrorHandler func(request *APIContext, err error)
type Field ¶
type Field struct { Type string `json:"type,omitempty" yaml:"type,omitempty"` Default interface{} `json:"default,omitempty" yaml:"default,omitempty"` Nullable bool `json:"nullable,omitempty" yaml:"nullable,omitempty"` Create bool `json:"create,omitempty" yaml:"create,omitempty"` WriteOnly bool `json:"writeOnly,omitempty" yaml:"write_only,omitempty"` Required bool `json:"required,omitempty" yaml:"required,omitempty"` Update bool `json:"update,omitempty" yaml:"update,omitempty"` MinLength *int `json:"minLength,omitempty" yaml:"min_length,omitempty"` MaxLength *int `json:"maxLength,omitempty" yaml:"max_length,omitempty"` Min *int64 `json:"min,omitempty" yaml:"min,omitempty"` Max *int64 `json:"max,omitempty" yaml:"max,omitempty"` Options []string `json:"options,omitempty" yaml:"options,omitempty"` ValidChars string `json:"validChars,omitempty" yaml:"valid_chars,omitempty"` InvalidChars string `json:"invalidChars,omitempty" yaml:"invalid_chars,omitempty"` Description string `json:"description,omitempty" yaml:"description,omitempty"` }
type Filter ¶
type Filter struct {
Modifiers []string `json:"modifiers,omitempty" yaml:"modifiers,omitempty"`
}
type Formatter ¶
type Formatter func(request *APIContext, resource *RawResource)
type GenericCollection ¶
type GenericCollection struct { Collection Data []interface{} `json:"data" yaml:"data"` }
type ListOpts ¶
type ListOpts struct {
Filters map[string]interface{}
}
func NewListOpts ¶
func NewListOpts() *ListOpts
type Pagination ¶
type Pagination struct { Marker string `json:"marker,omitempty" yaml:"marker,omitempty"` First string `json:"first,omitempty" yaml:"first,omitempty"` Previous string `json:"previous,omitempty" yaml:"previous,omitempty"` Next string `json:"next,omitempty" yaml:"next,omitempty"` Limit *int64 `json:"limit,omitempty" yaml:"limit,omitempty"` Total *int64 `json:"total,omitempty" yaml:"total,omitempty"` Partial bool `json:"partial,omitempty" yaml:"partial,omitempty"` }
type QueryCondition ¶
type QueryCondition struct { Field string // contains filtered or unexported fields }
func EQ ¶
func EQ(value interface{}) *QueryCondition
func IN ¶
func IN(values ...interface{}) *QueryCondition
func NE ¶
func NE(value interface{}) *QueryCondition
func NOTIN ¶
func NOTIN(values ...interface{}) *QueryCondition
func NOTNULL ¶
func NOTNULL(value interface{}) *QueryCondition
func NULL ¶
func NULL(value interface{}) *QueryCondition
func NewCondition ¶
func NewCondition(mod QueryConditionType, values ...interface{}) *QueryCondition
func NewConditionFromString ¶
func NewConditionFromString(field, mod string, values ...interface{}) *QueryCondition
func (*QueryCondition) AND ¶
func (c *QueryCondition) AND(right *QueryCondition) *QueryCondition
func (*QueryCondition) OR ¶
func (c *QueryCondition) OR(right *QueryCondition) *QueryCondition
func (*QueryCondition) ToCondition ¶
func (q *QueryCondition) ToCondition() Condition
type QueryConditionType ¶
type QueryOptions ¶
type QueryOptions struct { Sort Sort Pagination *Pagination Conditions []*QueryCondition }
type RancherBaseClient ¶
type RancherBaseClient interface { Websocket(string, map[string][]string) (*websocket.Conn, *http.Response, error) List(string, *ListOpts, interface{}) error Post(string, interface{}, interface{}) error GetLink(Resource, string, interface{}) error Create(string, interface{}, interface{}) error Update(string, *Resource, interface{}, interface{}) error ById(string, string, interface{}) error Delete(*Resource) error Reload(*Resource, interface{}) error Action(string, string, *Resource, interface{}, interface{}) error GetOpts() *ClientOpts GetTypes() map[string]Schema // contains filtered or unexported methods }
type RancherBaseClientImpl ¶
type RancherBaseClientImpl struct { Opts *ClientOpts Schemas *Schemas Types map[string]Schema }
func (*RancherBaseClientImpl) Action ¶
func (rancherClient *RancherBaseClientImpl) Action(schemaType string, action string, existing *Resource, inputObject, respObject interface{}) error
func (*RancherBaseClientImpl) ById ¶
func (rancherClient *RancherBaseClientImpl) ById(schemaType string, id string, respObject interface{}) error
func (*RancherBaseClientImpl) Create ¶
func (rancherClient *RancherBaseClientImpl) Create(schemaType string, createObj interface{}, respObject interface{}) error
func (*RancherBaseClientImpl) Delete ¶
func (rancherClient *RancherBaseClientImpl) Delete(existing *Resource) error
func (*RancherBaseClientImpl) GetLink ¶
func (rancherClient *RancherBaseClientImpl) GetLink(resource Resource, link string, respObject interface{}) error
func (*RancherBaseClientImpl) GetOpts ¶
func (rancherClient *RancherBaseClientImpl) GetOpts() *ClientOpts
func (*RancherBaseClientImpl) GetTypes ¶
func (rancherClient *RancherBaseClientImpl) GetTypes() map[string]Schema
func (*RancherBaseClientImpl) List ¶
func (rancherClient *RancherBaseClientImpl) List(schemaType string, opts *ListOpts, respObject interface{}) error
func (*RancherBaseClientImpl) Post ¶
func (rancherClient *RancherBaseClientImpl) Post(url string, createObj interface{}, respObject interface{}) error
func (*RancherBaseClientImpl) Reload ¶
func (rancherClient *RancherBaseClientImpl) Reload(existing *Resource, output interface{}) error
type RawResource ¶
type RawResource struct { ID string `json:"id,omitempty" yaml:"id,omitempty"` Type string `json:"type,omitempty" yaml:"type,omitempty"` Schema *Schema `json:"-" yaml:"-"` Links map[string]string `json:"links" yaml:"links"` Actions map[string]string `json:"actions" yaml:"actions"` Values map[string]interface{} `json:",inline"` }
func (*RawResource) MarshalJSON ¶
func (r *RawResource) MarshalJSON() ([]byte, error)
type ReferenceValidator ¶
type ReferenceValidator interface { Validate(resourceType, resourceID string) bool Lookup(resourceType, resourceID string) *RawResource }
type RequestHandler ¶
type RequestHandler func(request *APIContext) error
type ResourceCollection ¶
type ResourceCollection struct { Collection Data []Resource `json:"data,omitempty" yaml:"data,omitempty"` }
type ResponseWriter ¶
type ResponseWriter interface {
Write(apiContext *APIContext, code int, obj interface{})
}
type Schema ¶
type Schema struct { ID string `json:"id,omitempty" yaml:"id,omitempty"` Type string `json:"type,omitempty" yaml:"type,omitempty"` Links map[string]string `json:"links" yaml:"links"` Version APIVersion `json:"version" yaml:"version"` PluralName string `json:"pluralName,omitempty" yaml:"plural_name,omitempty"` ResourceMethods []string `json:"resourceMethods,omitempty" yaml:"resource_methods,omitempty"` ResourceFields map[string]*Field `json:"resourceFields,omitempty" yaml:"resource_fields,omitempty"` ResourceActions map[string]*Action `json:"resourceActions,omitempty" yaml:"resource_actions,omitempty"` CollectionMethods []string `json:"collectionMethods,omitempty" yaml:"collection_methods,omitempty"` CollectionFields map[string]*Field `json:"collectionFields,omitempty" yaml:"collection_fields,omitempty"` CollectionActions map[string]*Action `json:"collectionActions,omitempty" yaml:"collection_actions,omitempty"` CollectionFilters map[string]*Filter `json:"collectionFilters,omitempty" yaml:"collection_filters,omitempty"` ActionHandler ActionHandler `json:"-" yaml:"-"` ListHandler RequestHandler `json:"-" yaml:"-"` CreateHandler RequestHandler `json:"-" yaml:"-"` DeleteHandler RequestHandler `json:"-" yaml:"-"` UpdateHandler RequestHandler `json:"-" yaml:"-"` Formatter Formatter `json:"-" yaml:"-"` ErrorHandler ErrorHandler `json:"-" yaml:"-"` Validator Validator `json:"-" yaml:"-"` Store Store `json:"-" yaml:"-"` }
type SchemaCollection ¶
type SchemaCollection struct {
Data []Schema
}
type Schemas ¶
type Schemas struct {
// contains filtered or unexported fields
}
func NewSchemas ¶
func NewSchemas() *Schemas
func (*Schemas) SchemasForVersion ¶
func (s *Schemas) SchemasForVersion(version APIVersion) map[string]*Schema
func (*Schemas) Versions ¶
func (s *Schemas) Versions() []APIVersion
type Store ¶
type Store interface { ByID(apiContext *APIContext, schema *Schema, id string) (map[string]interface{}, error) List(apiContext *APIContext, schema *Schema, opt *QueryOptions) ([]map[string]interface{}, error) Create(apiContext *APIContext, schema *Schema, data map[string]interface{}) (map[string]interface{}, error) Update(apiContext *APIContext, schema *Schema, data map[string]interface{}, id string) (map[string]interface{}, error) Delete(apiContext *APIContext, schema *Schema, id string) error }
type URLBuilder ¶
type URLBuilder interface { Current() string Collection(schema *Schema) string RelativeToRoot(path string) string //Link(resource Resource, name string) string //ReferenceLink(resource Resource) string //ReferenceByIdLink(resourceType string, id string) string Version(version string) string ReverseSort(order SortOrder) string }
type Validator ¶
type Validator func(request *APIContext, data map[string]interface{}) error
Click to show internal directories.
Click to hide internal directories.