api

package
v1.18.0 Latest Latest
Warning

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

Go to latest
Published: Sep 29, 2026 License: MIT Imports: 13 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type API

type API struct {
	Router *mux.Router
	// contains filtered or unexported fields
}

API provides a struct to wrap the api around

func Setup

func Setup(
	cfg *config.Config,
	r *mux.Router,
	permissionsStore PermissionsStore,
	bundler PermissionsBundler,
	auth authorisation.Middleware) *API

Setup function sets up the api and returns an api

func (*API) DeletePolicyHandler added in v0.8.0

func (api *API) DeletePolicyHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)

DeletePolicyHandler is a handler that deletes policy by its ID from DB

func (*API) GetPermissionsBundleHandler added in v0.5.0

func (api *API) GetPermissionsBundleHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)

GetPermissionsBundleHandler gets and returns the permissions bundle as JSON in the HTTP response body.

func (*API) GetPolicyHandler added in v0.5.0

func (api *API) GetPolicyHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)

GetPolicyHandler is a handler that gets policy by its ID from DB

func (*API) GetRoleHandler added in v0.3.0

func (api *API) GetRoleHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)

GetRoleHandler is a handler that gets a role by its ID from MongoDB

func (*API) GetRolesHandler added in v0.4.0

func (api *API) GetRolesHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)

GetRolesHandler is a handler that gets all roles from MongoDB

func (*API) PostPolicyHandler added in v0.5.0

func (api *API) PostPolicyHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)

PostPolicyHandler is a handler that creates a new policies in DB

func (*API) PostPolicyWithIDHandler added in v1.9.0

func (api *API) PostPolicyWithIDHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)

PostPolicyWithIDHandler is a handler that creates a new policy with the given ID

func (*API) UpdatePolicyHandler added in v0.8.0

func (api *API) UpdatePolicyHandler(ctx context.Context, w http.ResponseWriter, req *http.Request) (*models.SuccessResponse, *models.ErrorResponse)

UpdatePolicyHandler is a handler that updates policy by its ID from DB

type PermissionsBundler added in v0.5.0

type PermissionsBundler interface {
	Get(ctx context.Context) (models.Bundle, error)
}

PermissionsBundler defines the functions used by the API to get permissions bundles

type PermissionsStore added in v0.3.0

type PermissionsStore interface {
	Checker(ctx context.Context, state *healthcheck.CheckState) error
	Close(ctx context.Context) error
	GetRole(ctx context.Context, id string) (*models.Role, error)
	GetRoles(ctx context.Context, offset, limit int) (*models.Roles, error)
	AddPolicy(ctx context.Context, policy *models.Policy) (*models.Policy, error)
	UpdatePolicy(ctx context.Context, policy *models.Policy) (*models.UpdateResult, error)
	GetPolicy(ctx context.Context, id string) (*models.Policy, error)
	DeletePolicy(ctx context.Context, id string) error
}

PermissionsStore defines the behaviour of a PermissionsStore

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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