Documentation ¶
Index ¶
- Variables
- func GetRuntimeInfo() (*runtime.Runtime, error)
- func PaginateSlice[T any](req api.PaginatedRequest, values []T, less func(a T, b T) bool, ...) (page []T, npt string, err error)
- func PaginateStorage[T any](req api.PaginatedRequest, storage persistence.Storage, opts PaginationOpts, ...) (page []T, npt string, err error)
- func ValidateRequest(req IncomingRequest) (err error)
- type AuthorizationStrategy
- type AuthorizationStrategyAllowAll
- type AuthorizationStrategyJWT
- type IncomingRequest
- type Option
- type PaginationOpts
- type RequestType
Constants ¶
This section is empty.
Variables ¶
var DefaultPaginationOpts = PaginationOpts{
DefaultPageSize: 50,
MaxPageSize: 1500,
}
DefaultPaginationOpts are sensible defaults for the pagination size.
var ErrPermissionDenied = status.Errorf(codes.PermissionDenied, "access denied")
ErrPermissionDenied represents an error, where permission to fulfill the request is denied.
Functions ¶
func GetRuntimeInfo ¶ added in v1.7.4
GetRuntimeInfo implements method to get Clouditors runtime information
func PaginateSlice ¶ added in v1.4.6
func PaginateSlice[T any](req api.PaginatedRequest, values []T, less func(a T, b T) bool, opts PaginationOpts) (page []T, npt string, err error)
PaginateSlice is a helper function that helps to paginate a slice based on list requests. It parses the necessary information out if a paginated request, e.g. the page token and the desired page size and returns a sliced page as well as the next page token.
func PaginateStorage ¶ added in v1.4.6
func PaginateStorage[T any](req api.PaginatedRequest, storage persistence.Storage, opts PaginationOpts, conds ...interface{}) (page []T, npt string, err error)
PaginateStorage is a helper function that helps to paginate records in persisted storage based on list requests. It parses the necessary information out if a paginated request, e.g. the page token and the desired page size and returns a sliced page as well as the next page token.
func ValidateRequest ¶ added in v1.7.0
func ValidateRequest(req IncomingRequest) (err error)
ValidateRequest validates an incoming request according to different criteria:
- If the request is nil, api.ErrEmptyRequest is returned
- The request is validated according to the generated validation method
- Lastly, if the request is a api.PaginatedRequest, an additional check is performed to ensure only valid columns are listed
Note: This function already returns a gRPC error, so the error can be returned directly without any wrapping in a request function.
Types ¶
type AuthorizationStrategy ¶ added in v1.6.2
type AuthorizationStrategy interface { CheckAccess(ctx context.Context, typ RequestType, req api.CloudServiceRequest) bool AllowedCloudServices(ctx context.Context) (all bool, IDs []string) }
AuthorizationStrategy is an interface that implements a function which checkers whether the current cloud service request can be fulfilled using the supplied context (e.g., based on the authenticated user).
type AuthorizationStrategyAllowAll ¶ added in v1.6.2
type AuthorizationStrategyAllowAll struct{}
AuthorizationStrategyAllowAll is an AuthorizationStrategy that allows all requests.
func (*AuthorizationStrategyAllowAll) AllowedCloudServices ¶ added in v1.6.2
func (*AuthorizationStrategyAllowAll) AllowedCloudServices(_ context.Context) (all bool, list []string)
AllowedCloudServices retrieves a list of allowed cloud service IDs according to the current access strategy. Returns `all = true` since strategy is `AuthorizationStrategyAllowAll`
func (*AuthorizationStrategyAllowAll) CheckAccess ¶ added in v1.6.2
func (*AuthorizationStrategyAllowAll) CheckAccess(_ context.Context, _ RequestType, _ api.CloudServiceRequest) bool
CheckAccess checks whether the current request can be fulfilled using the current access strategy. Returns true since strategy is `AuthorizationStrategyAllowAll`
type AuthorizationStrategyJWT ¶ added in v1.6.2
AuthorizationStrategyJWT is an AuthorizationStrategy that expects a list of cloud service IDs to be in a specific JWT claim key.
func (*AuthorizationStrategyJWT) AllowedCloudServices ¶ added in v1.6.2
func (a *AuthorizationStrategyJWT) AllowedCloudServices(ctx context.Context) (all bool, list []string)
AllowedCloudServices retrieves a list of allowed cloud service IDs according to the current access strategy.
func (*AuthorizationStrategyJWT) CheckAccess ¶ added in v1.6.2
func (a *AuthorizationStrategyJWT) CheckAccess(ctx context.Context, _ RequestType, req api.CloudServiceRequest) bool
CheckAccess checks whether the current request can be fulfilled using the current access strategy.
type IncomingRequest ¶ added in v1.7.0
type Option ¶ added in v1.4.11
type Option[T any] func(*T)
Option is a functional option type to configure services.
type PaginationOpts ¶ added in v1.4.6
type PaginationOpts struct { // DefaultPageSize is the page size that is used as a default if the request does not specify one DefaultPageSize int32 // MaxPageSize is the maximum page size that can be requested MaxPageSize int32 }
PaginationOpts can be used to fine-tune the pagination, especially with regards to the page sizes. This can be important if the messages within a page are extremly large and thus the page size needs to be decreased.
type RequestType ¶ added in v1.6.2
type RequestType int
RequestType specifies the type of request, usually CRUD.
const ( AccessCreate RequestType = iota AccessRead AccessUpdate AccessDelete )