Documentation
¶
Overview ¶
Package schema represents the tree structure of an API schema.
For more information, refer to the main "geyser" package documentation.
Index ¶
- Variables
- type Interface
- type InterfaceKey
- type InterfaceMethodNotFoundError
- type InterfaceNotFoundError
- type Interfaces
- type InterfacesGroup
- type InvalidInterfaceNameError
- type InvalidMethodHTTPMethodError
- type InvalidMethodNameError
- type InvalidMethodVersionError
- type Method
- type MethodKey
- type MethodParam
- type MethodParams
- type Methods
- type MethodsGroup
- type RequiredParameterError
- type Schema
Constants ¶
This section is empty.
Variables ¶
var ( // ErrEmptyInterfaces is returned when trying to manipulate an empty `Interfaces`. ErrEmptyInterfaces = errors.New("empty interfaces collection") // ErrMixedInterfaces is returned when trying to use group helpers on a `Interfaces` collection // containing mixed interface names. ErrMixedInterfaces = errors.New("mixed interfaces collection") // ErrMixedMethods is returned when trying to use group helpers on a `Methods` collection // containing mixed method names. ErrMixedMethods = errors.New("mixed methods collection") )
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface struct { Name string `json:"name"` Methods Methods `json:"methods"` Undocumented bool `json:"undocumented"` // contains filtered or unexported fields }
Interface holds the specification of an API interface.
The struct should be read-only.
func (*Interface) Key ¶
func (i *Interface) Key() (InterfaceKey, error)
Key returns the key identifying the interface.
Interface names are formed by a base name and an optional AppID part, in the format `<BaseName>_<AppID>`. Interfaces can be non app-specific and omit the "_<AppID>" part, in these cases Key returns a key with AppID = 0.
For example in "IDOTAMatch_570", the base name is "IDOTAMatch" and AppID is 570. In "ISteamApps", the base name is "ISteamApps" and AppID is 0.
Key parses the interface name and extracts the base name and the AppID from the name.
Returns errors described in `Validate`.
type InterfaceKey ¶
InterfaceKey is the key that uniquely identifies a `Interface`.
type InterfaceMethodNotFoundError ¶
type InterfaceMethodNotFoundError struct {
Key MethodKey
}
InterfaceMethodNotFoundError is returned when tried to access an interface method with invalid name or invalid version.
func (InterfaceMethodNotFoundError) Error ¶
func (InterfaceMethodNotFoundError) Error() string
type InterfaceNotFoundError ¶
type InterfaceNotFoundError struct {
Key InterfaceKey
}
InterfaceNotFoundError is returned when tried to access an interface with invalid name or invalid AppID.
func (InterfaceNotFoundError) Error ¶
func (InterfaceNotFoundError) Error() string
type Interfaces ¶
type Interfaces []*Interface
Interfaces is a collection of `Interface`s.
func MustNewInterfaces ¶
func MustNewInterfaces(interfaces ...*Interface) Interfaces
MustNewInterfaces is like `NewInterfaces` but panics if it returned an error.
func NewInterfaces ¶
func NewInterfaces(interfaces ...*Interface) (Interfaces, error)
NewInterfaces creates a new collection.
Returns errors described in `Interface.Validate`.
func (Interfaces) Get ¶
func (c Interfaces) Get(key InterfaceKey) (*Interface, error)
Get returns the interface with given key.
Returns an error of type `*InterfaceNotFoundError` if none was found.
Returns errors described in `Interface.Key`.
func (Interfaces) GroupByBaseName ¶
func (c Interfaces) GroupByBaseName() (map[string]InterfacesGroup, error)
GroupByName groups the interfaces by base name.
The definition of base name is described in `Interface.Key`.
Returns errors described in `Interface.Key`.
func (Interfaces) Validate ¶
func (c Interfaces) Validate() error
Validate checks if all contained interfaces are valid.
Returns errors described in `Interface.Validate`.
type InterfacesGroup ¶
type InterfacesGroup map[InterfaceKey]*Interface
InterfacesGroup is a group of `Interface`s with the same base name.
The definition of base name is described in `Interface.Key`.
It's a regular map and therefore provides no guarantees on consistency:
* Keys are not guaranteed to be correctly associated to their respective interfaces
* Interfaces are not guaranteed to be unique for each key
* Interfaces are not guaranteed to have the same base name
The group creator is responsible for ensuring consistency. Group consumers can assume it's consistent.
Behavior of inconsistent groups is undefined.
func (InterfacesGroup) AppIDs ¶
func (g InterfacesGroup) AppIDs() []uint32
AppIDs collects the AppID of all interfaces in the group.
Interfaces with no AppID (0) are omitted.
func (InterfacesGroup) GroupMethods ¶
func (g InterfacesGroup) GroupMethods() (map[string]MethodsGroup, error)
GroupMethods groups interfaces methods by method name.
Returns errors described in `Methods.GroupByName`.
func (InterfacesGroup) Name ¶
func (g InterfacesGroup) Name() (name string)
Name returns the common base name of all interfaces in the group.
The definition of base name is described in `Interface.Key`.
type InvalidInterfaceNameError ¶
InvalidInterfaceNameError is returned when an interface has an invalid name.
func (InvalidInterfaceNameError) Error ¶
func (InvalidInterfaceNameError) Error() string
type InvalidMethodHTTPMethodError ¶
type InvalidMethodHTTPMethodError struct {
Method *Method
}
InvalidMethodHTTPMethodError is returned when a method has an invalid version.
func (InvalidMethodHTTPMethodError) Error ¶
func (InvalidMethodHTTPMethodError) Error() string
type InvalidMethodNameError ¶
type InvalidMethodNameError struct {
Method *Method
}
InvalidMethodNameError is returned when a method has an invalid name.
func (InvalidMethodNameError) Error ¶
func (InvalidMethodNameError) Error() string
type InvalidMethodVersionError ¶
type InvalidMethodVersionError struct {
Method *Method
}
InvalidMethodVersionError is returned when a method has an invalid version.
func (InvalidMethodVersionError) Error ¶
func (InvalidMethodVersionError) Error() string
type Method ¶
type Method struct { Name string `json:"name"` Version int `json:"version"` HTTPMethod string `json:"httpmethod"` Params MethodParams `json:"parameters"` Undocumented bool `json:"undocumented"` // contains filtered or unexported fields }
Method holds the specification of an API interface method.
The struct should be read-only.
func (*Method) FormatVersion ¶
FormatVersion returns the formatted version string (in the format "v<version>") to be used as a request path parameter.
func (*Method) Key ¶
Key returns the key identifying the method.
Returns errors described in `Validate`.
func (*Method) Validate ¶
Validate checks if the method is valid.
Returns an error of type `*InvalidMethodNameError` if the method has an invalid name.
Returns an error of type `*InvalidMethodVersionError` if the method has an invalid version.
Returns an error of type `*InvalidMethodHTTPMethodError` if the method has an invalid http method.
type MethodParam ¶
type MethodParam struct { Name string `json:"name"` Type string `json:"type"` Optional bool `json:"optional"` Description string `json:"description"` }
MethodParam holds the specification of an API interface method parameter.
The struct should be read-only.
func (*MethodParam) ValidateValue ¶
func (p *MethodParam) ValidateValue(value string) error
ValidateValue validates the given value against the parameter specification.
Returns an error of type `*RequiredParameterError` if the parameter is required and the value is empty.
type MethodParams ¶
type MethodParams []*MethodParam
MethodParams is a collection of `MethodParam`s.
func NewMethodParams ¶
func NewMethodParams(params ...*MethodParam) MethodParams
NewMethodParams creates a new collection.
func (MethodParams) ValidateParams ¶
func (c MethodParams) ValidateParams(params url.Values) error
ValidateParams validates the given parameters against each parameter in the collection.
Returns errors described in `MethodParam.ValidateParam`.
type Methods ¶
type Methods []*Method
Methods is a collection of `Method`s.
func MustNewMethods ¶
MustNewMethods is like `NewMethods` but panics if it returned an error.
func NewMethods ¶
NewMethods creates a new collection.
Returns errors described in `Method.Validate`.
func (Methods) Get ¶
Get returns the method with the given key.
Returns an error of type `*InterfaceMethodNotFoundError` if none was found.
Returns errors described in `Method.Key`.
func (Methods) GroupByName ¶
func (c Methods) GroupByName() (map[string]MethodsGroup, error)
GroupByName groups the methods by name.
Returns errors described in `Method.Key`.
type MethodsGroup ¶
MethodsGroup is a group of `Method`s with the same name.
It's a regular map and therefore provides no guarantees on consistency:
* Keys are not guaranteed to be correctly associated to their respective methods
* Methods are not guaranteed to be unique for each key
* Methods are not guaranteed to have the same name
The group creator is responsible for ensuring consistency. Group consumers can assume it's consistent.
Behavior of inconsistent groups is undefined.
func (MethodsGroup) Versions ¶
func (g MethodsGroup) Versions() []int
Versions collects the versions of all methods in the group.
type RequiredParameterError ¶
type RequiredParameterError struct {
Param *MethodParam
}
RequiredParameterError is returned when a required parameter is missing.
func (RequiredParameterError) Error ¶
func (RequiredParameterError) Error() string
type Schema ¶
type Schema struct { Host string `json:"host"` Interfaces Interfaces `json:"interfaces"` }
Schema is the root of an API schema specification.