api

package
v0.1.14 Latest Latest
Warning

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

Go to latest
Published: Aug 30, 2023 License: AGPL-3.0 Imports: 11 Imported by: 0

README

KIProtect - KIProtect API

KIProtect provides an API to the KIProtect tool, allowing users to transform data via a RESTful API.

Building

To build the API, run the following commands in the parent directory:

make
make install

Running the tests

Run the following in the parent directory:

make test-api

Running the API command

First, define the KODEX_SETTINGS environment variable. Then, run

kodex api run

Documentation

Index

Constants

View Source
const (
	Insert Op = 0
	Remove    = 1
	Update    = 2
	Swap      = 3
)

Variables

View Source
var AccessTokenForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "token",
			Validators: []forms.Validator{
				forms.IsBytes{Encoding: "hex"},
			},
		},
		{
			Name: "scopes",
			Validators: []forms.Validator{
				forms.IsList{
					Validators: []forms.Validator{
						forms.IsString{},
					},
				},
			},
		},
	},
}
View Source
var BPObjectRoleForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "objectType",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
		{
			Name: "organizationID",
			Validators: []forms.Validator{
				forms.IsBytes{Encoding: "hex"},
			},
		},
		{
			Name: "organizationSource",
			Validators: []forms.Validator{
				forms.IsOptional{Default: "inMemory"},
				forms.IsIn{Choices: []interface{}{"inMemory"}},
			},
		},
		{
			Name: "objectID",
			Validators: []forms.Validator{
				forms.IsBytes{Encoding: "hex"},
			},
		},
		{
			Name: "organizationRole",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
		{
			Name: "objectRole",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
	},
}
View Source
var BPOrganizationForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "source",
			Validators: []forms.Validator{
				forms.IsOptional{Default: "inMemory"},
				forms.IsIn{Choices: []interface{}{"inMemory"}},
			},
		},
		{
			Name: "name",
			Validators: []forms.Validator{
				forms.IsString{},
			},
		},
		{
			Name: "default",
			Validators: []forms.Validator{
				forms.IsOptional{Default: false},
				forms.IsBoolean{},
			},
		},
		{
			Name: "id",
			Validators: []forms.Validator{
				forms.IsBytes{Encoding: "hex"},
			},
		},
	},
}
View Source
var BlueprintConfigForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "users",
			Validators: []forms.Validator{
				forms.IsOptional{},
				forms.IsList{
					Validators: []forms.Validator{
						forms.IsStringMap{
							Form: &BlueprintUserForm,
						},
					},
				},
			},
		},
		{
			Name: "roles",
			Validators: []forms.Validator{
				forms.IsList{
					Validators: []forms.Validator{
						forms.IsStringMap{
							Form: &BPObjectRoleForm,
						},
					},
				},
			},
		},
	},
}
View Source
var BlueprintUserForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "source",
			Validators: []forms.Validator{
				forms.IsOptional{Default: "inMemory"},
				forms.IsIn{Choices: []interface{}{"inMemory"}},
			},
		},
		{
			Name: "email",
			Validators: []forms.Validator{
				forms.IsOptional{},
				forms.IsString{},
			},
		},
		{
			Name: "displayName",
			Validators: []forms.Validator{
				forms.IsOptional{},
				forms.IsString{},
			},
		},
		{
			Name: "superuser",
			Validators: []forms.Validator{
				forms.IsOptional{Default: false},
				forms.IsBoolean{},
			},
		},
		{
			Name: "accessToken",
			Validators: []forms.Validator{
				forms.IsStringMap{
					Form: &AccessTokenForm,
				},
			},
		},
		{
			Name: "roles",
			Validators: []forms.Validator{
				forms.IsList{
					Validators: []forms.Validator{
						forms.IsStringMap{
							Form: &RolesForm,
						},
					},
				},
			},
		},
	},
}
View Source
var ChangeRequestForm = forms.Form{
	ErrorMsg: "invalid data encountered in the change request config",
	Fields: []forms.Field{
		{
			Name: "data",
			Validators: []forms.Validator{
				forms.IsOptional{},
				forms.IsStringMap{},
			},
		},
		{
			Name: "description",
			Validators: []forms.Validator{
				forms.IsString{MinLength: 5},
			},
		},
		{
			Name: "title",
			Validators: []forms.Validator{
				forms.IsString{MinLength: 2},
			},
		},
		{
			Name: "status",
			Validators: []forms.Validator{
				forms.IsOptional{Default: DraftCR},
				IsChangeRequestStatus{},
			},
		},
	},
}
View Source
var ChangeRequestReviewForm = forms.Form{
	ErrorMsg: "invalid data encountered in the change request config",
	Fields: []forms.Field{
		{
			Name: "data",
			Validators: []forms.Validator{
				forms.IsOptional{},
				forms.IsStringMap{},
			},
		},
		{
			Name: "description",
			Validators: []forms.Validator{
				forms.IsString{MinLength: 10},
			},
		},
		{
			Name: "status",
			Validators: []forms.Validator{
				forms.IsOptional{Default: ReviewRequested},
				IsChangeRequestReviewStatus{},
				forms.IsIn{Choices: []interface{}{ReviewRequested}},
			},
		},
	},
}
View Source
var CommentForm = forms.Form{
	ErrorMsg: "invalid data encountered in the change request config",
	Fields: []forms.Field{
		{
			Name: "data",
			Validators: []forms.Validator{
				forms.IsOptional{},
				forms.IsStringMap{},
			},
		},
		{
			Name: "text",
			Validators: []forms.Validator{
				forms.IsString{MinLength: 5},
			},
		},
		{
			Name: "status",
			Validators: []forms.Validator{
				forms.IsOptional{Default: DraftComment},
				IsCommentStatus{},
				forms.IsIn{Choices: []interface{}{DraftComment, PublishedComment, DeletedComment}},
			},
		},
	},
}
View Source
var DefaultObjectRoleForm = forms.Form{
	ErrorMsg: "invalid data encountered in the default object role form",
	Fields: []forms.Field{
		{
			Name: "organization_role",
			Validators: []forms.Validator{
				forms.IsRequired{},
				forms.IsString{MinLength: 2, MaxLength: 100},
				forms.MatchesRegex{Regexp: regexp.MustCompile(`^[\w\d\-\:\.]{2,100}$`)},
			},
		},
		{
			Name: "role",
			Validators: []forms.Validator{
				forms.IsRequired{},
				forms.IsString{},
				forms.IsIn{Choices: []interface{}{"superuser", "admin", "viewer", "reviewer", "editor", "legal-reviewer", "technical-reviewer"}},
			},
		},
	},
}
View Source
var ObjectRoleForm = forms.Form{
	ErrorMsg: "invalid data encountered in the object role form",
	Fields: []forms.Field{
		{
			Name: "organization_role",
			Validators: []forms.Validator{
				forms.IsRequired{},
				forms.IsString{MinLength: 2, MaxLength: 100},
				forms.MatchesRegex{Regexp: regexp.MustCompile(`^[\w\d\-\:\.]{2,100}$`)},
			},
		},
		{
			Name: "role",
			Validators: []forms.Validator{
				forms.IsRequired{},
				forms.IsString{},
				forms.IsIn{Choices: []interface{}{"superuser", "admin", "viewer", "reviewer", "editor", "legal-reviewer", "technical-reviewer"}},
			},
		},
	},
}
View Source
var OrganizationForm = forms.Form{
	ErrorMsg: "invalid data encountered in the organization form",
	Fields: []forms.Field{
		{
			Name: "name",
			Validators: append([]forms.Validator{
				forms.IsRequired{}}, kodex.NameValidators...),
		},
		{
			Name: "description",
			Validators: append([]forms.Validator{
				forms.IsOptional{Default: ""}}, kodex.DescriptionValidators...),
		},
		{
			Name:       "data",
			Validators: []forms.Validator{forms.IsOptional{}, forms.IsStringMap{}},
		},
	},
}
View Source
var RolesForm = forms.Form{
	Fields: []forms.Field{
		{
			Name: "roles",
			Validators: []forms.Validator{
				forms.IsStringList{},
			},
		},
		{
			Name: "organization",
			Validators: []forms.Validator{
				forms.IsStringMap{
					Form: &BPOrganizationForm,
				},
			},
		},
	},
}
View Source
var UserForm = forms.Form{
	ErrorMsg: "invalid data encountered in the user form",
	Fields: []forms.Field{
		{
			Name: "displayName",
			Validators: append([]forms.Validator{
				forms.IsRequired{}}, kodex.NameValidators...),
		},
		{
			Name: "email",
			Validators: append([]forms.Validator{
				forms.IsRequired{}}, kodex.NameValidators...),
		},
		{
			Name:       "data",
			Validators: []forms.Validator{forms.IsOptional{}, forms.IsStringMap{}},
		},
	},
}

Functions

func ApplyChanges added in v0.1.0

func ApplyChanges(object any, changes []Change) error

func ApplyChangesWithObject added in v0.1.0

func ApplyChangesWithObject(object any, changes []Change) (any, error)

Applies a sequence of changes to an object

func FormatError

func FormatError(err error) interface{}

func HandleError

func HandleError(c *gin.Context, code int, err error)

func InitRoles added in v0.1.0

func InitRoles(controller Controller, roles []*ObjectRoleSpec) error

func InitUsers added in v0.1.0

func InitUsers(controller Controller, users []*ExternalUser) error

func OpName added in v0.1.0

func OpName(op Op) string

Types

type APIControllerDefinitions

type APIControllerDefinitions map[string]APIControllerMaker

type APIControllerMaker

type APIControllerMaker func(
	config map[string]interface{},
	baseController kodex.Controller,
	definitions *Definitions) (Controller, error)

type APIPlugin

type APIPlugin interface {
	InitializeAPI(*gin.RouterGroup, Controller, kodex.Meter) error
	InitializeAdaptors(map[string]ObjectAdaptor) error
}

type AccessToken

type AccessToken struct {
	Scopes []string `json:"scopes"`
	Token  []byte   `json:"-" coerce:"name:token"`
}

func MakeAccessToken

func MakeAccessToken(scopes []string) *AccessToken

type AssociateAdaptor

type AssociateAdaptor interface {
	Associate(c *gin.Context, left, right kodex.Model) bool
	Dissociate(c *gin.Context, left, right kodex.Model) bool
	Get(c *gin.Context, left kodex.Model) interface{}
	LeftType() string
	RightType() string
}

type BaseChangeRequest added in v0.1.0

type BaseChangeRequest struct {
	Self     ChangeRequest
	Creator_ User
}

func (*BaseChangeRequest) Create added in v0.1.0

func (b *BaseChangeRequest) Create(values map[string]interface{}) error

func (*BaseChangeRequest) Creator added in v0.1.0

func (b *BaseChangeRequest) Creator() User

func (*BaseChangeRequest) MarshalJSON added in v0.1.0

func (b *BaseChangeRequest) MarshalJSON() ([]byte, error)

func (*BaseChangeRequest) Type added in v0.1.0

func (b *BaseChangeRequest) Type() string

func (*BaseChangeRequest) Update added in v0.1.0

func (b *BaseChangeRequest) Update(values map[string]interface{}) error

type BaseChangeRequestReview added in v0.1.0

type BaseChangeRequestReview struct {
	Self     ChangeRequestReview
	Project_ kodex.Project
	Creator_ User
}

func (*BaseChangeRequestReview) Create added in v0.1.0

func (b *BaseChangeRequestReview) Create(values map[string]interface{}) error

func (*BaseChangeRequestReview) Creator added in v0.1.0

func (b *BaseChangeRequestReview) Creator() User

func (*BaseChangeRequestReview) MarshalJSON added in v0.1.0

func (b *BaseChangeRequestReview) MarshalJSON() ([]byte, error)

func (*BaseChangeRequestReview) Project added in v0.1.0

func (b *BaseChangeRequestReview) Project() kodex.Project

func (*BaseChangeRequestReview) Type added in v0.1.0

func (b *BaseChangeRequestReview) Type() string

func (*BaseChangeRequestReview) Update added in v0.1.0

func (b *BaseChangeRequestReview) Update(values map[string]interface{}) error

type BaseComment added in v0.1.0

type BaseComment struct {
	Self     Comment
	Creator_ User
}

func (*BaseComment) Create added in v0.1.0

func (b *BaseComment) Create(values map[string]interface{}) error

func (*BaseComment) Creator added in v0.1.0

func (b *BaseComment) Creator() User

func (*BaseComment) MarshalJSON added in v0.1.0

func (b *BaseComment) MarshalJSON() ([]byte, error)

func (*BaseComment) Type added in v0.1.0

func (b *BaseComment) Type() string

func (*BaseComment) Update added in v0.1.0

func (b *BaseComment) Update(values map[string]interface{}) error

type BaseController

type BaseController struct {
	Definitions_  *Definitions
	UserProvider_ UserProvider
	Self          Controller
}

func (*BaseController) APIDefinitions

func (b *BaseController) APIDefinitions() *Definitions

func (*BaseController) CanAccess

func (b *BaseController) CanAccess(user *ExternalUser, object kodex.Model, objectRoles []string) (bool, error)

func (*BaseController) ObjectRolesForUser

func (b *BaseController) ObjectRolesForUser(objectType string, user *ExternalUser) ([]ObjectRole, error)

func (*BaseController) RegisterAPIPlugin

func (b *BaseController) RegisterAPIPlugin(plugin APIPlugin) error

func (*BaseController) UserProvider

func (b *BaseController) UserProvider() (UserProvider, error)

type BaseDefaultObjectRole added in v0.1.0

type BaseDefaultObjectRole struct {
	Self DefaultObjectRole
}

BaseDefaultObjectRole contains useful common functionality that should be shared by all implementations of the interface, such as validation.

func (*BaseDefaultObjectRole) Create added in v0.1.0

func (b *BaseDefaultObjectRole) Create(values map[string]interface{}) error

func (*BaseDefaultObjectRole) MarshalJSON added in v0.1.0

func (b *BaseDefaultObjectRole) MarshalJSON() ([]byte, error)

func (*BaseDefaultObjectRole) Type added in v0.1.0

func (b *BaseDefaultObjectRole) Type() string

func (*BaseDefaultObjectRole) Update added in v0.1.0

func (b *BaseDefaultObjectRole) Update(values map[string]interface{}) error

type BaseObjectRole

type BaseObjectRole struct {
	Self ObjectRole
}

BaseObjectRole contains useful common functionality that should be shared by all implementations of the interface, such as validation.

func (*BaseObjectRole) Create

func (b *BaseObjectRole) Create(values map[string]interface{}) error

func (*BaseObjectRole) MarshalJSON

func (b *BaseObjectRole) MarshalJSON() ([]byte, error)

func (*BaseObjectRole) Type

func (b *BaseObjectRole) Type() string

func (*BaseObjectRole) Update

func (b *BaseObjectRole) Update(values map[string]interface{}) error

type BaseOrganization

type BaseOrganization struct {
	Self        Organization
	Controller_ Controller
}

func (*BaseOrganization) Controller

func (b *BaseOrganization) Controller() Controller

func (*BaseOrganization) Create

func (b *BaseOrganization) Create(values map[string]interface{}) error

func (*BaseOrganization) MarshalJSON

func (b *BaseOrganization) MarshalJSON() ([]byte, error)

func (*BaseOrganization) Type

func (b *BaseOrganization) Type() string

func (*BaseOrganization) Update

func (b *BaseOrganization) Update(values map[string]interface{}) error

type BaseUser added in v0.1.0

type BaseUser struct {
	Self        User
	Controller_ Controller
}

func (*BaseUser) Controller added in v0.1.0

func (b *BaseUser) Controller() Controller

func (*BaseUser) Create added in v0.1.0

func (b *BaseUser) Create(values map[string]interface{}) error

func (*BaseUser) MarshalJSON added in v0.1.0

func (b *BaseUser) MarshalJSON() ([]byte, error)

func (*BaseUser) Type added in v0.1.0

func (b *BaseUser) Type() string

func (*BaseUser) Update added in v0.1.0

func (b *BaseUser) Update(values map[string]interface{}) error

type Blueprint

type Blueprint struct {
	// contains filtered or unexported fields
}

func MakeBlueprint

func MakeBlueprint(config map[string]interface{}) *Blueprint

func (*Blueprint) Create

func (b *Blueprint) Create(controller Controller) error

type BlueprintSpec added in v0.1.5

type BlueprintSpec struct {
	Users []*ExternalUser   `json:"users"`
	Roles []*ObjectRoleSpec `json:"roles"`
}

type Change added in v0.1.0

type Change struct {
	Op          Op            `json:"op"`
	Value       any           `json:"value"`
	Path        []PathElement `json:"path"`
	Description string        `json:"description"`
}

func Diff added in v0.1.0

func Diff(a, b any) []Change

Returns the difference between two data structures as a sequence of changes

func DiffWithOptions added in v0.1.0

func DiffWithOptions(a, b any, options DiffOptions) []Change

func (Change) String added in v0.1.0

func (c Change) String() string

type ChangeRequest added in v0.1.0

type ChangeRequest interface {
	kodex.Model
	Title() string
	SetTitle(string) error
	Description() string
	SetDescription(string) error
	SetData(interface{}) error
	Data() interface{}
	Changes() []ChangeSet
	SetChanges([]ChangeSet) error
	SetStatus(ChangeRequestStatus) error
	Status() ChangeRequestStatus
	Reviews() ([]ChangeRequestReview, error)
	MakeReview(User) (ChangeRequestReview, error)
	Review([]byte) (ChangeRequestReview, error)
	Creator() User
	ObjectID() []byte
	ObjectType() string
}

type ChangeRequestReview added in v0.1.0

type ChangeRequestReview interface {
	kodex.Model
	Description() string
	SetDescription(string) error
	SetData(interface{}) error
	Data() interface{}
	SetStatus(ChangeRequestReviewStatus) error
	Status() ChangeRequestReviewStatus
	ChangeRequest() ChangeRequest
	Creator() User
}

type ChangeRequestReviewStatus added in v0.1.0

type ChangeRequestReviewStatus string
const (
	ReviewRequested ChangeRequestReviewStatus = "requested"
	RequestRejected ChangeRequestReviewStatus = "rejected"
	RequestApproved ChangeRequestReviewStatus = "approved"
)

type ChangeRequestStatus added in v0.1.0

type ChangeRequestStatus string
const (
	DraftCR     ChangeRequestStatus = "draft"
	ReadyCR     ChangeRequestStatus = "ready"
	WithdrawnCR ChangeRequestStatus = "withdrawn"
	ApprovedCR  ChangeRequestStatus = "approved"
	RejectedCR  ChangeRequestStatus = "rejected"
)

type ChangeSet added in v0.1.0

type ChangeSet struct {
	Description string   `json:"description"`
	Changes     []Change `json:"changes"`
	Data        any      `json:"data"`
}

type Comment added in v0.1.0

type Comment interface {
	kodex.Model
	Text() string
	SetText(string) error
	SetData(interface{}) error
	Data() interface{}
	SetStatus(CommentStatus) error
	Status() CommentStatus
	Creator() User
	ObjectID() []byte
	ObjectType() string
}

type CommentStatus added in v0.1.0

type CommentStatus string
const (
	DraftComment     CommentStatus = "draft"
	PublishedComment CommentStatus = "published"
	DeletedComment   CommentStatus = "deleted"
)

type Controller

type Controller interface {
	kodex.Controller

	// Clone the controller
	ApiClone() (Controller, error)

	KodexController() kodex.Controller
	RegisterAPIPlugin(APIPlugin) error
	APIDefinitions() *Definitions

	// User provider
	UserProvider() (UserProvider, error)

	// Object roles
	CanAccess(user *ExternalUser, object kodex.Model, objectRoles []string) (bool, error)
	ObjectRole(id []byte) (ObjectRole, error)
	RolesForObject(object kodex.Model) ([]ObjectRole, error)
	ObjectRolesForUser(objectType string, user *ExternalUser) ([]ObjectRole, error)
	ObjectRolesForOrganizationRoles(objectType string, organizationRoles []string, organizationID []byte) ([]ObjectRole, error)
	MakeObjectRole(object kodex.Model, organization Organization) ObjectRole

	// Default object roles
	DefaultObjectRoles(organizationID []byte) ([]DefaultObjectRole, error)
	DefaultObjectRole(id []byte) (DefaultObjectRole, error)
	MakeDefaultObjectRole(objectType string, organization Organization) DefaultObjectRole

	// Change request
	ChangeRequests(object kodex.Model) ([]ChangeRequest, error)
	ChangeRequest(id []byte) (ChangeRequest, error)
	MakeChangeRequest(id []byte, object kodex.Model, user User) (ChangeRequest, error)

	// Users
	MakeUser() User
	User(source string, sourceID []byte) (User, error)
	Users(filters map[string]interface{}) ([]User, error)

	// Organizations
	MakeOrganization() Organization
	Organization(source string, sourceID []byte) (Organization, error)
	Organizations(filters map[string]interface{}) ([]Organization, error)
}

type Copyable added in v0.1.0

type Copyable interface {
	Copy() any
}

type CreateObjectAdaptor

type CreateObjectAdaptor interface {
	MakeObject(*gin.Context) kodex.Model
}

type CreateUserProvider

type CreateUserProvider interface {
	Create(user *ExternalUser) error
}

type DefaultObjectRole added in v0.1.0

type DefaultObjectRole interface {
	kodex.Model
	OrganizationID() []byte
	OrganizationRole() string
	SetOrganizationRole(string) error
	ObjectRole() string
	SetObjectRole(string) error
	ObjectType() string
}

type Definitions

type Definitions struct {
	kodex.Definitions
	Routes                   []Routes
	APIControllerDefinitions APIControllerDefinitions
	ObjectAdaptors           map[string]ObjectAdaptor
	AssociateAdaptors        map[string]AssociateAdaptor
	UserProviders            map[string]UserProviderDefinition
}

func MergeDefinitions

func MergeDefinitions(a, b Definitions) Definitions

func (Definitions) Marshal

func (d Definitions) Marshal() map[string]interface{}

func (Definitions) MarshalJSON

func (d Definitions) MarshalJSON() ([]byte, error)

type DiffOptions added in v0.1.0

type DiffOptions struct {
	Identifiers []string
}

type ExternalUser added in v0.1.0

type ExternalUser struct {
	Source      string                 `json:"source"`
	SourceID    []byte                 `json:"sourceID"`
	Email       string                 `json:"email"`
	DisplayName string                 `json:"displayName"`
	Superuser   bool                   `json:"superuser"`
	AccessToken *AccessToken           `json:"accessToken"`
	Roles       []*OrganizationRoles   `json:"roles"`
	Limits      map[string]interface{} `json:"limits"`
	// contains filtered or unexported fields
}

func MakeUser

func MakeUser(source, email string, superuser bool, roles []*OrganizationRoles, limits map[string]interface{}, token *AccessToken) *ExternalUser

func (*ExternalUser) ApiUser added in v0.1.0

func (i *ExternalUser) ApiUser(controller Controller) (User, error)

type IsChangeRequestReviewStatus added in v0.1.0

type IsChangeRequestReviewStatus struct{}

func (IsChangeRequestReviewStatus) Validate added in v0.1.0

func (i IsChangeRequestReviewStatus) Validate(value interface{}, values map[string]interface{}) (interface{}, error)

type IsChangeRequestStatus added in v0.1.0

type IsChangeRequestStatus struct{}

func (IsChangeRequestStatus) Validate added in v0.1.0

func (i IsChangeRequestStatus) Validate(value interface{}, values map[string]interface{}) (interface{}, error)

type IsCommentStatus added in v0.1.0

type IsCommentStatus struct{}

func (IsCommentStatus) Validate added in v0.1.0

func (i IsCommentStatus) Validate(value interface{}, values map[string]interface{}) (interface{}, error)

type ListAllObjectAdaptor

type ListAllObjectAdaptor interface {
	AllObjects(*gin.Context) []kodex.Model
}

type ObjectAdaptor

type ObjectAdaptor interface {
	// Returns the object for the given ID and its role object, if possible
	Get(Controller, *gin.Context, []byte) (kodex.Model, kodex.Model, error)
	Initialize(Controller, *gin.RouterGroup) error
	Objects(*gin.Context) []kodex.Model
	Type() string
	DependsOn() string
}

type ObjectRole

type ObjectRole interface {
	kodex.Model
	OrganizationID() []byte
	ObjectID() []byte
	OrganizationRole() string
	SetOrganizationRole(string) error
	ObjectRole() string
	SetObjectRole(string) error
	ObjectType() string
}

type ObjectRoleSpec

type ObjectRoleSpec struct {
	ObjectRole         string `json:"objectRole"`
	OrganizationRole   string `json:"organizationRole"`
	OrganizationID     []byte `json:"organizationID"`
	OrganizationSource string `json:"organizationSource"`
	ObjectID           []byte `json:"objectID"`
	ObjectType         string `json:"objectType"`
}

type Op added in v0.1.0

type Op int

type Organization

type Organization interface {
	kodex.Model
	Source() string
	SourceID() []byte
	Name() string
	SetName(string) error
	Description() string
	SetDescription(string) error
	SetSource(string) error
	SetSourceID([]byte) error
	Data() interface{}
	SetData(interface{}) error
}

type OrganizationRoles

type OrganizationRoles struct {
	Roles        []string          `json:"roles"`
	Organization *UserOrganization `json:"organization"`
}

func MakeOrganizationRoles

func MakeOrganizationRoles(org *UserOrganization, roles []string) *OrganizationRoles

type PathElement added in v0.1.0

type PathElement struct {
	PathType   PathType `json:"pathType"`
	Name       string   `json:"name"`
	Index      int      `json:"index"`
	Identifier string   `json:"identifier"`
	Value      any      `json:"value"`
}

func ArrayPath added in v0.1.0

func ArrayPath(index int) PathElement

func ByIdPath added in v0.1.0

func ByIdPath(identifier string, value any) PathElement

func DirectPath added in v0.1.0

func DirectPath(name string) PathElement

func (PathElement) String added in v0.1.0

func (p PathElement) String() string

type PathType added in v0.1.0

type PathType int
const (
	Direct PathType = 0
	ById   PathType = 1
	Array  PathType = 2
)

type Routes

type Routes func(*gin.RouterGroup, Controller, kodex.Meter) error

type Settings

type Settings struct {
	UserProvider *UserProviderSettings `json:"userProvider"`
}

type SettingsValidator

type SettingsValidator func(settings map[string]interface{}) (interface{}, error)

type UpdateObjectAdaptor

type UpdateObjectAdaptor interface {
	UpdateObject(kodex.Model, map[string]interface{}) (kodex.Model, error)
	SaveUpdated(updatedObject, object kodex.Model) error
}

type User

type User interface {
	kodex.Model
	Source() string
	SourceID() []byte
	Email() string
	DisplayName() string
	Superuser() bool
	SetDisplayName(string) error
	SetEmail(string) error
	SetSuperuser(bool) error
	SetSource(string) error
	SetSourceID([]byte) error
	Data() interface{}
	SetData(interface{}) error
}

type UserOrganization

type UserOrganization struct {
	Source      string `json:"source"`
	Name        string `json:"name"`
	Default     bool   `json:"default"`
	Description string `json:"description"`
	ID          []byte `json:"id"`
	// contains filtered or unexported fields
}

func MakeUserOrganization

func MakeUserOrganization(source, name, description string, id []byte) *UserOrganization

func (*UserOrganization) ApiOrganization

func (i *UserOrganization) ApiOrganization(controller Controller) (Organization, error)

type UserProvider

type UserProvider interface {
	Initialize(controller Controller, group *gin.RouterGroup) error
	Logout(controller Controller, request *http.Request, writer http.ResponseWriter) error
	Get(controller Controller, request *http.Request) (*ExternalUser, error)
}

type UserProviderDefinition

type UserProviderDefinition struct {
	Name              string            `json:"name"`
	Description       string            `json:"description"`
	Maker             UserProviderMaker `json:"-"`
	SettingsValidator SettingsValidator `json:"-"`
}

type UserProviderDefinitions

type UserProviderDefinitions map[string]UserProviderDefinition

type UserProviderMaker

type UserProviderMaker func(settings kodex.Settings) (UserProvider, error)

type UserProviderPlugin added in v0.1.0

type UserProviderPlugin interface {
	InitializeUserProviders(map[string]UserProviderDefinition) error
}

type UserProviderSettings

type UserProviderSettings struct {
	Type     string      `json:"type"`
	Settings interface{} `json:"settings"`
}

Directories

Path Synopsis
gin
v1
resources/pcap/pcapgo
Package pcapgo provides some native PCAP support, not requiring C libpcap to be installed.
Package pcapgo provides some native PCAP support, not requiring C libpcap to be installed.

Jump to

Keyboard shortcuts

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