Documentation ¶
Index ¶
- Constants
- type FilterBase
- type Filtering
- type LocalFiltering
- func (f *LocalFiltering) And(condition1, condition2 interface{}) bool
- func (f *LocalFiltering) Contains(attr string, value interface{}) bool
- func (f *LocalFiltering) Equals(attr string, value interface{}) bool
- func (f *LocalFiltering) Exists(attr string, value interface{}) bool
- func (f *LocalFiltering) GreaterThan(attr string, value interface{}) bool
- func (f *LocalFiltering) GreaterThanEqual(attr string, value interface{}) bool
- func (f *LocalFiltering) In(attr string, values interface{}) bool
- func (f *LocalFiltering) LessThan(attr string, value interface{}) bool
- func (f *LocalFiltering) LessThanEqual(attr string, value interface{}) bool
- func (f *LocalFiltering) NotContains(attr string, value interface{}) bool
- func (f *LocalFiltering) NotEqual(attr string, value interface{}) bool
- func (f *LocalFiltering) NotIn(attr string, values interface{}) bool
- func (f *LocalFiltering) Or(condition1, condition2 interface{}) bool
- func (f *LocalFiltering) StartsWith(attr string, value interface{}) bool
- type OperationMap
- type Scoutr
- func (api *Scoutr) BuildParams(req types.Request) map[string][]string
- func (api *Scoutr) CanAccessEndpoint(method string, path string, user *types.User, request *types.Request) bool
- func (api *Scoutr) GetConfig() config.Config
- func (api Scoutr) GetUser(id string, userData *types.UserData) (*types.User, error)
- func (api Scoutr) InitializeRequest(req types.Request) (*types.User, error)
- func (api *Scoutr) MergePermissions(user *types.User, group *types.Group)
- func (api *Scoutr) PostProcess(data []types.Record, user *types.User)
- func (api Scoutr) PrepareCreate(request types.Request, data map[string]interface{}, ...) (*types.User, error)
- func (api *Scoutr) UserIdentifier(user *types.User) string
- func (api *Scoutr) ValidateFields(validation map[string]types.FieldValidation, requiredFields []string, ...) error
- func (api *Scoutr) ValidateRequest(req types.Request, user *types.User) error
- func (api *Scoutr) ValidateUser(user *types.User) error
- type ScoutrBase
- type ScoutrFilters
- type ScoutrProvider
Constants ¶
const ( AuditActionCreate = "CREATE" AuditActionUpdate = "UPDATE" AuditActionList = "LIST" AuditActionGet = "GET" AuditActionSearch = "SEARCH" AuditActionDelete = "DELETE" )
const ( FilterActionRead = "READ" FilterActionCreate = "CREATE" FilterActionUpdate = "UPDATE" FilterActionDelete = "DELETE" OperationEqual = "eq" OperationNotEqual = "ne" OperationStartsWith = "startswith" OperationContains = "contains" OperationNotContains = "notcontains" OperationExists = "exists" OperationGreaterThan = "gt" OperationLessThan = "lt" OperationGreaterThanEqual = "ge" OperationLessThanEqual = "le" OperationBetween = "between" OperationIn = "in" OperationNotIn = "notin" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FilterBase ¶
type FilterBase interface { Operations() OperationMap // Filter operation, Returns generated conditions and any errors Filter(user *types.User, filters map[string][]string, action string) (interface{}, error) // contains filtered or unexported methods }
FilterBase : Interface used to generalize the filter logic across multiple providers
type LocalFiltering ¶
type LocalFiltering struct { Filtering // contains filtered or unexported fields }
func (*LocalFiltering) And ¶
func (f *LocalFiltering) And(condition1, condition2 interface{}) bool
func (*LocalFiltering) Contains ¶
func (f *LocalFiltering) Contains(attr string, value interface{}) bool
func (*LocalFiltering) Equals ¶
func (f *LocalFiltering) Equals(attr string, value interface{}) bool
func (*LocalFiltering) Exists ¶
func (f *LocalFiltering) Exists(attr string, value interface{}) bool
func (*LocalFiltering) GreaterThan ¶
func (f *LocalFiltering) GreaterThan(attr string, value interface{}) bool
func (*LocalFiltering) GreaterThanEqual ¶
func (f *LocalFiltering) GreaterThanEqual(attr string, value interface{}) bool
func (*LocalFiltering) In ¶
func (f *LocalFiltering) In(attr string, values interface{}) bool
func (*LocalFiltering) LessThan ¶
func (f *LocalFiltering) LessThan(attr string, value interface{}) bool
func (*LocalFiltering) LessThanEqual ¶
func (f *LocalFiltering) LessThanEqual(attr string, value interface{}) bool
func (*LocalFiltering) NotContains ¶
func (f *LocalFiltering) NotContains(attr string, value interface{}) bool
func (*LocalFiltering) NotEqual ¶
func (f *LocalFiltering) NotEqual(attr string, value interface{}) bool
func (*LocalFiltering) NotIn ¶
func (f *LocalFiltering) NotIn(attr string, values interface{}) bool
func (*LocalFiltering) Or ¶
func (f *LocalFiltering) Or(condition1, condition2 interface{}) bool
func (*LocalFiltering) StartsWith ¶
func (f *LocalFiltering) StartsWith(attr string, value interface{}) bool
type OperationMap ¶
OperationMap : Map of operator to a callable to perform the filter
type Scoutr ¶
type Scoutr struct { ScoutrBase Filtering FilterBase Config config.Config }
Scoutr : Base struct that implements ScoutrBase and sets up some commonly used functions across various cloud providers
func (*Scoutr) BuildParams ¶
BuildParams : Takes in a request object and generates a parameters map that can be used in Filter calls
func (*Scoutr) CanAccessEndpoint ¶
func (api *Scoutr) CanAccessEndpoint(method string, path string, user *types.User, request *types.Request) bool
CanAccessEndpoint : Determine if a user has access to a specific endpoint
func (Scoutr) GetUser ¶
GetUser : Fetch a user from the backend, merging any permissions from group memberships
func (Scoutr) InitializeRequest ¶
InitializeRequest : Given a request, get the corresponding user and perform user and request validation.
func (*Scoutr) MergePermissions ¶
MergePermissions : Merge permissions expressed in a group into the user object
func (*Scoutr) PostProcess ¶
PostProcess : Perform post processing on records before returning to user
func (Scoutr) PrepareCreate ¶
func (*Scoutr) UserIdentifier ¶
UserIdentifier : Generate a user identifier for logs
func (*Scoutr) ValidateFields ¶
func (*Scoutr) ValidateRequest ¶
ValidateRequest : Validate the user has permissions to perform the request
type ScoutrBase ¶
type ScoutrBase interface { ScoutrProvider GetConfig() config.Config CanAccessEndpoint(string, string, *types.User, *types.Request) bool }
ScoutrBase : Low level interface that defines all the functions used by a Scoutr provider. Some of these would be implemented by the Scoutr struct
type ScoutrFilters ¶
type ScoutrFilters interface { And(condition1 interface{}, condition2 interface{}) interface{} Or(condition1 interface{}, condition2 interface{}) interface{} Equals(key string, value interface{}) (interface{}, error) NotEqual(key string, value interface{}) (interface{}, error) StartsWith(key string, value interface{}) (interface{}, error) Contains(key string, value interface{}) (interface{}, error) NotContains(key string, value interface{}) (interface{}, error) Exists(key string, value interface{}) (interface{}, error) GreaterThan(key string, value interface{}) (interface{}, error) LessThan(key string, value interface{}) (interface{}, error) GreaterThanEqual(key string, value interface{}) (interface{}, error) LessThanEqual(key string, value interface{}) (interface{}, error) Between(key string, values interface{}) (interface{}, error) In(key string, values interface{}) (interface{}, error) NotIn(key string, values interface{}) (interface{}, error) }
type ScoutrProvider ¶
type ScoutrProvider interface { GetEntitlements([]string) ([]types.User, error) GetAuth(string) (*types.User, error) GetGroup(string) (*types.Group, error) Create(request types.Request, item map[string]interface{}, validation map[string]types.FieldValidation, requiredFields []string) error Update(request types.Request, partitionKey map[string]interface{}, item map[string]interface{}, validation map[string]types.FieldValidation, requiredFields []string, auditAction string) (interface{}, error) Patch(request types.Request, partitionKey map[string]interface{}, item map[string]interface{}, validation map[string]types.FieldValidation, auditAction string) (interface{}, error) Get(request types.Request, id string) (types.Record, error) List(request types.Request) ([]types.Record, error) ListUniqueValues(request types.Request, uniqueKey string) ([]string, error) ListAuditLogs(request types.Request, pathParams map[string]string, queryParams map[string][]string) ([]types.AuditLog, error) History(request types.Request, key string, value string, queryParams map[string][]string, actions []string) ([]types.History, error) Search(request types.Request, key string, values []string) ([]types.Record, error) Delete(request types.Request, partitionKey map[string]interface{}) error }