Documentation ¶
Index ¶
- Constants
- func ApiErrorWithCode(c codes.Code) error
- func ApiErrorWithCodeAndMessage(c codes.Code, msg string, args ...interface{}) error
- func ErrorHandler() runtime.ErrorHandlerFunc
- func ForbiddenError() error
- func GetOpts(opt ...Option) options
- func JSONMarshaler() *runtime.JSONPb
- func MaskContains(paths []string, s string) bool
- func NotFoundError() error
- func OutgoingResponseFilter(ctx context.Context, w http.ResponseWriter, m proto.Message) error
- func ProtoToStruct(p proto.Message) (*structpb.Struct, error)
- func SetStatusCode(ctx context.Context, code int) error
- func StructToProto(fields *structpb.Struct, p proto.Message, opt ...Option) error
- func ToApiError(e error) *pb.Error
- func UnauthenticatedError() error
- func ValidId(i Id, prefixes ...string) bool
- func ValidNameDescription(in string) bool
- func ValidateCreateRequest(i ApiResource, fn CustomValidatorFunc) error
- func ValidateDeleteRequest(fn CustomValidatorFunc, r DeleteRequest, prefix ...string) error
- func ValidateGetRequest(fn CustomValidatorFunc, r GetRequest, prefix ...string) error
- func ValidateUpdateRequest(r UpdateRequest, i ApiResource, fn CustomValidatorFunc, prefix ...string) error
- type ApiError
- type ApiResource
- type CustomValidatorFunc
- type DeleteRequest
- type Filter
- type GetRequest
- type Id
- type MaskDestination
- type MaskManager
- type MaskSource
- type Option
- func WithAuthorizedActions(acts []string) Option
- func WithAuthorizedCollectionActions(colActs map[string]*structpb.ListValue) Option
- func WithDiscardUnknownFields(discard bool) Option
- func WithHostSetIds(ids []string) Option
- func WithManagedGroupIds(ids []string) Option
- func WithMemberIds(ids []string) Option
- func WithOutputFields(fields *perms.OutputFieldsMap) Option
- func WithPlugin(plg *plugins.PluginInfo) Option
- func WithScope(scp *scopes.ScopeInfo) Option
- func WithUserIsAnonymous(anonListing bool) Option
- type UpdateRequest
Constants ¶
const ( HttpOnlyCookieName = "wt-http-token-cookie" JsVisibleCookieName = "wt-js-token-cookie" StatusCodeHeader = "x-http-code" )
Variables ¶
This section is empty.
Functions ¶
func ApiErrorWithCode ¶
ApiErrorWithCode returns an api error with the provided code.
func ApiErrorWithCodeAndMessage ¶
ApiErrorWithCodeAndMessage returns an api error with the provided code and message.
func ErrorHandler ¶
func ErrorHandler() runtime.ErrorHandlerFunc
func ForbiddenError ¶
func ForbiddenError() error
func GetOpts ¶
func GetOpts(opt ...Option) options
GetOpts - iterate the inbound Options and return a struct
func JSONMarshaler ¶
JSONMarshaler provides marshaler used for marshaling all proto as JSON in a format expected by the user facing controller API.
func MaskContains ¶
func NotFoundError ¶
func NotFoundError() error
NotFoundError returns an ApiError indicating a resource couldn't be found.
func OutgoingResponseFilter ¶
OutgoingResponseFilter is a gRPC gateway WithForwardResponseOption. It's basically a filter that can manipulate the http response and has acesss to the outgoing proto msg
func SetStatusCode ¶
SetStatusCode allows a grpc service handler to set the outgoing http status code
func StructToProto ¶
func ToApiError ¶
func UnauthenticatedError ¶
func UnauthenticatedError() error
func ValidNameDescription ¶
func ValidateCreateRequest ¶
func ValidateCreateRequest(i ApiResource, fn CustomValidatorFunc) error
func ValidateDeleteRequest ¶
func ValidateDeleteRequest(fn CustomValidatorFunc, r DeleteRequest, prefix ...string) error
func ValidateGetRequest ¶
func ValidateGetRequest(fn CustomValidatorFunc, r GetRequest, prefix ...string) error
func ValidateUpdateRequest ¶
func ValidateUpdateRequest(r UpdateRequest, i ApiResource, fn CustomValidatorFunc, prefix ...string) error
Types ¶
type ApiError ¶
func InvalidArgumentErrorf ¶
func NotFoundErrorf ¶
NotFoundErrorf returns an ApiError indicating a resource couldn't be found.
type ApiResource ¶
type CustomValidatorFunc ¶
var NoopValidatorFn CustomValidatorFunc = func() map[string]string { return nil }
type DeleteRequest ¶
type DeleteRequest interface {
GetId() string
}
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
func NewFilter ¶
NewFilter returns a Filter which can be evluated against. An empty string paramter indicates all items passed to it should succeed.
func (*Filter) Match ¶
Match returns if the provided interface matches the filter. If the filter does not match the structure of the object being Matched, false is returned. TODO: Support more than just matching against the item being filtered. Also allow matching against values in the request or the request context itself.
type GetRequest ¶
type GetRequest interface {
GetId() string
}
type MaskDestination ¶
type MaskDestination []protoreflect.ProtoMessage
type MaskManager ¶
func NewMaskManager ¶
func NewMaskManager(dest MaskDestination, src MaskSource) (MaskManager, error)
NewMaskManager returns a mask manager that can translate field masks into the first proto from all subsequent protos assuming they are both using the mask_mapping custom option. Error is returned if no mappings are found or if one of the passed protos has a mapping that doesn't reciprocate.
func (MaskManager) Translate ¶
func (m MaskManager) Translate(paths []string, passedThroughPrefix ...string) []string
Translate takes a field mask's paths and returns paths translated for the destination's protobuf. If a translation doesn't exist for a specific path entry then nothing is returned for that specific path entry unless passedThroughPrefix is used and applies to that entry.
passedThroughPrefix is helpful when the field mask's paths cannot be mapped through the mask mapper for some reason (we don't know the mapping at compile time, for example) but we still want certain paths to be passed on. If a path entry isn't mapped to anything by the MaskManager but does contain a prefix which matches a passedThroughPrefix it will be added unmodified to the returned value.
type MaskSource ¶
type MaskSource []protoreflect.ProtoMessage
type Option ¶
type Option func(*options)
Option - how Options are passed as arguments. Some of these are used for types within the handlers package, and some are for handlers to re-use across the various handler types.
func WithAuthorizedActions ¶
WithAuthorizedActions provides an option when creating responses to include the given authorized actions if allowed
func WithAuthorizedCollectionActions ¶
WithAuthorizedCollectionActions provides an option when creating responses to include the given authorized collection actions if allowed
func WithDiscardUnknownFields ¶
WithDiscardUnknownFields provides an option to cause StructToProto to ignore unknown fields. This is useful in some instances when we need to unmarshal a value from a pb.Struct after we've added some custom extra fields.
func WithHostSetIds ¶
WithHostSetIds provides an option when creating responses to include the given host set IDs if allowed
func WithManagedGroupIds ¶
WithManagedGroupIds provides an option when creating responses to include the given managed group IDs if allowed
func WithMemberIds ¶
WithMemberIds provides an option when creating responses to include the given member IDs if allowed
func WithOutputFields ¶
func WithOutputFields(fields *perms.OutputFieldsMap) Option
WithOutputFields provides an option when creating responses to only include specific fields
func WithPlugin ¶
func WithPlugin(plg *plugins.PluginInfo) Option
WithPlugin provides an option when creating responses to include the given plugin if allowed
func WithScope ¶
WithScope provides an option when creating responses to include the given scope if allowed
func WithUserIsAnonymous ¶
DEPRECATED: Superceded by WithOutputFields. Will be removed once all handlers have been migrated to that.
type UpdateRequest ¶
type UpdateRequest interface { GetId() string GetUpdateMask() *field_mask.FieldMask }