service

package
v1.10.1 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2023 License: Apache-2.0 Imports: 17 Imported by: 6

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultPaginationOpts = PaginationOpts{
	DefaultPageSize: 50,
	MaxPageSize:     1500,
}

DefaultPaginationOpts are sensible defaults for the pagination size.

View Source
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

func GetRuntimeInfo() (*runtime.Runtime, error)

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

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

type AuthorizationStrategyJWT struct {
	CloudServicesKey string
	AllowAllKey      string
}

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

CheckAccess checks whether the current request can be fulfilled using the current access strategy.

type IncomingRequest added in v1.7.0

type IncomingRequest interface {
	Validate() error
	proto.Message
}

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
)

Directories

Path Synopsis
aws
k8s

Jump to

Keyboard shortcuts

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