Documentation
¶
Index ¶
- Constants
- Variables
- func ErrorWithParams(err error, params ...any) error
- type Auth
- func (a *Auth) ApplyAuth(ctx context.Context, req *authgrpc.ApplyAuthRequest) (*authgrpc.ApplyAuthResponse, error)
- func (a *Auth) ConfirmJob(ctx context.Context, job orbital.Job) (orbital.JobConfirmResult, error)
- func (a *Auth) GetAuth(ctx context.Context, req *authgrpc.GetAuthRequest) (*authgrpc.GetAuthResponse, error)
- func (a *Auth) HandleJobCanceled(ctx context.Context, job orbital.Job) error
- func (a *Auth) HandleJobDone(ctx context.Context, job orbital.Job) error
- func (a *Auth) HandleJobFailed(ctx context.Context, job orbital.Job) error
- func (a *Auth) ListAuths(ctx context.Context, in *authgrpc.ListAuthsRequest) (*authgrpc.ListAuthsResponse, error)
- func (a *Auth) RemoveAuth(ctx context.Context, req *authgrpc.RemoveAuthRequest) (*authgrpc.RemoveAuthResponse, error)
- func (a *Auth) ResolveTasks(ctx context.Context, job orbital.Job, ...) (orbital.TaskResolverResult, error)
- type JobHandler
- type Mapping
- func (m *Mapping) Get(ctx context.Context, in *mappinggrpc.GetRequest) (*mappinggrpc.GetResponse, error)
- func (m *Mapping) MapSystemToTenant(ctx context.Context, in *mappinggrpc.MapSystemToTenantRequest) (*mappinggrpc.MapSystemToTenantResponse, error)
- func (m *Mapping) UnmapSystemFromTenant(ctx context.Context, in *mappinggrpc.UnmapSystemFromTenantRequest) (*mappinggrpc.UnmapSystemFromTenantResponse, error)
- type Meters
- type Orbital
- type System
- func (s *System) DeleteSystem(ctx context.Context, in *systemgrpc.DeleteSystemRequest) (*systemgrpc.DeleteSystemResponse, error)
- func (s *System) ListSystems(ctx context.Context, in *systemgrpc.ListSystemsRequest) (*systemgrpc.ListSystemsResponse, error)
- func (s *System) RegisterSystem(ctx context.Context, in *systemgrpc.RegisterSystemRequest) (*systemgrpc.RegisterSystemResponse, error)
- func (s *System) RemoveSystemLabels(ctx context.Context, in *systemgrpc.RemoveSystemLabelsRequest) (*systemgrpc.RemoveSystemLabelsResponse, error)
- func (s *System) SetSystemLabels(ctx context.Context, in *systemgrpc.SetSystemLabelsRequest) (*systemgrpc.SetSystemLabelsResponse, error)
- func (s *System) UpdateSystemL1KeyClaim(ctx context.Context, in *systemgrpc.UpdateSystemL1KeyClaimRequest) (*systemgrpc.UpdateSystemL1KeyClaimResponse, error)
- func (s *System) UpdateSystemStatus(ctx context.Context, in *systemgrpc.UpdateSystemStatusRequest) (*systemgrpc.UpdateSystemStatusResponse, error)
- type Tenant
- func (t *Tenant) BlockTenant(ctx context.Context, in *tenantgrpc.BlockTenantRequest) (*tenantgrpc.BlockTenantResponse, error)
- func (t *Tenant) ConfirmJob(ctx context.Context, job orbital.Job) (orbital.JobConfirmResult, error)
- func (t *Tenant) GetTenant(ctx context.Context, in *tenantgrpc.GetTenantRequest) (*tenantgrpc.GetTenantResponse, error)
- func (t *Tenant) HandleJobCanceled(ctx context.Context, job orbital.Job) error
- func (t *Tenant) HandleJobDone(ctx context.Context, job orbital.Job) error
- func (t *Tenant) HandleJobFailed(ctx context.Context, job orbital.Job) error
- func (t *Tenant) ListTenants(ctx context.Context, in *tenantgrpc.ListTenantsRequest) (*tenantgrpc.ListTenantsResponse, error)
- func (t *Tenant) RegisterTenant(ctx context.Context, in *tenantgrpc.RegisterTenantRequest) (*tenantgrpc.RegisterTenantResponse, error)
- func (t *Tenant) RemoveTenantLabels(ctx context.Context, in *tenantgrpc.RemoveTenantLabelsRequest) (*tenantgrpc.RemoveTenantLabelsResponse, error)
- func (t *Tenant) ResolveTasks(_ context.Context, job orbital.Job, ...) (orbital.TaskResolverResult, error)
- func (t *Tenant) SetTenantLabels(ctx context.Context, in *tenantgrpc.SetTenantLabelsRequest) (*tenantgrpc.SetTenantLabelsResponse, error)
- func (t *Tenant) SetTenantUserGroups(ctx context.Context, in *tenantgrpc.SetTenantUserGroupsRequest) (*tenantgrpc.SetTenantUserGroupsResponse, error)
- func (t *Tenant) TerminateTenant(ctx context.Context, in *tenantgrpc.TerminateTenantRequest) (*tenantgrpc.TerminateTenantResponse, error)
- func (t *Tenant) UnblockTenant(ctx context.Context, in *tenantgrpc.UnblockTenantRequest) (*tenantgrpc.UnblockTenantResponse, error)
Constants ¶
const ( SelectTenantErrMsg = "could not select tenant" UpdateTenantErrMsg = "could not update tenant" DeleteTenantErrMsg = "could not delete tenant" TenantNotFoundMsg = "tenant not found" )
const ( SelectSystemErrMsg = "could not select system" UpdateSystemErrMsg = "could not update system" DeleteSystemErrMsg = "could not delete system" SystemNotFoundMsg = "system not found" TenantStatusTransitionNotAllowedMsg = "tenant status transition not allowed" InvalidTenantStatusMsg = "invalid tenant status" )
const ( SelectAuthErrMsg = "could not select auth" UpdateAuthErrMsg = "could not update auth" AuthNotFoundErrMsg = "auth not found" AuthAlreadyExistsMsg = "auth with the given external ID already exists" AuthInvalidStatusMsg = "invalid auth status" )
const ( MissingLabelKeysMsg = "missing label keys" MissingLabelsMsg = "missing labels" EmptyLabelKeysMsg = "label keys cannot be empty" UserGroupsNilMsg = "user groups cannot be nil" )
const ( AttrRegion = "region" AttrTenantLinked = "tenant_linked" AttrStatus = "status" ErrDomainMetrics = "metrics" )
Variables ¶
var ( ErrTenantSelect = status.Error(codes.Internal, SelectTenantErrMsg) ErrTenantUpdate = status.Error(codes.Internal, UpdateTenantErrMsg) ErrTenantDelete = status.Error(codes.Internal, DeleteTenantErrMsg) ErrTenantIDFormat = status.Error(codes.InvalidArgument, "tenant ID is not valid") ErrTenantNotFound = status.Error(codes.NotFound, TenantNotFoundMsg) ErrTenantEncoding = status.Error(codes.Internal, "failed to encode tenant data") ErrTenantStatusTransitionNotAllowed = errors.New(TenantStatusTransitionNotAllowedMsg) ErrInvalidTenantStatus = errors.New(InvalidTenantStatusMsg) ErrTenantUserGroups = status.Error(codes.InvalidArgument, UserGroupsNilMsg) )
var ( ErrSystemSelect = status.Error(codes.Internal, SelectSystemErrMsg) ErrSystemUpdate = status.Error(codes.Internal, UpdateSystemErrMsg) ErrSystemDelete = status.Error(codes.Internal, DeleteSystemErrMsg) ErrExternalIDIsEmpty = status.Error(codes.InvalidArgument, "external ID cannot be empty") ErrRegionIsEmpty = status.Error(codes.InvalidArgument, "region cannot be empty") ErrSystemNotFound = status.Error(codes.NotFound, SystemNotFoundMsg) ErrSystemIsLinkedToTenant = status.Error(codes.FailedPrecondition, "system is linked to the tenant") ErrSystemIsNotLinkedToTenant = status.Error(codes.FailedPrecondition, "system is not linked to the tenant") ErrSystemLinkedToDifferentTenant = status.Error(codes.FailedPrecondition, "system is linked to a different tenant") ErrSystemHasL1KeyClaim = status.Error(codes.FailedPrecondition, "system has active l1 key claim") ErrNoTenantID = status.Error(codes.InvalidArgument, "no tenantID provided") ErrSystemListNotAllowed = status.Error(codes.InvalidArgument, "need either externalID and region or tenantID to list systems") ErrRegisterSystemNotAllowedWithTenantID = status.Error(codes.InvalidArgument, "system cannot be registered because other system(s) with same external ID and type are already linked to a different tenant") ErrSystemProtoConversion = status.Error(codes.Internal, "failed to convert system to proto message struct") ErrTooManyTypes = status.Error(codes.FailedPrecondition, "cannot determine type") )
var ( ErrAuthSelect = status.Error(codes.Internal, SelectAuthErrMsg) ErrAuthUpdate = status.Error(codes.Internal, UpdateAuthErrMsg) ErrAuthNotFound = status.Error(codes.NotFound, AuthNotFoundErrMsg) ErrAuthAlreadyExists = status.Error(codes.AlreadyExists, AuthAlreadyExistsMsg) ErrAuthInvalidStatus = status.Error(codes.FailedPrecondition, AuthInvalidStatusMsg) )
var ( ErrTranCtxTimeout = status.Error(codes.Aborted, "transaction was aborted due to timeout, please try again") ErrPanic = status.Error(codes.Internal, "an unexpected error occurred on the server, please try again") ErrKeyClaimAlreadyActive = status.Error(codes.FailedPrecondition, "key claim is already active") ErrKeyClaimAlreadyInactive = status.Error(codes.FailedPrecondition, "key claim is already inactive") ErrMissingLabelKeys = status.Error(codes.InvalidArgument, MissingLabelKeysMsg) ErrMissingLabels = status.Error(codes.InvalidArgument, MissingLabelsMsg) ErrEmptyLabelKeys = status.Error(codes.InvalidArgument, EmptyLabelKeysMsg) ErrValidationConversion = status.Error(codes.Internal, "validation conversion error") ErrValidationFailed = status.Error(codes.InvalidArgument, "validation failed") )
var ( ErrWrongConnectionType = errors.New("wrong initiator type") ErrUnexpectedJobType = errors.New("unexpected job type") )
var AuthNonUpdatableState = map[string]struct{}{ authgrpc.AuthStatus_AUTH_STATUS_REMOVED.String(): {}, authgrpc.AuthStatus_AUTH_STATUS_APPLYING_ERROR.String(): {}, }
var AuthTransientStates = map[string]struct{}{ authgrpc.AuthStatus_AUTH_STATUS_APPLYING.String(): {}, authgrpc.AuthStatus_AUTH_STATUS_REMOVING.String(): {}, authgrpc.AuthStatus_AUTH_STATUS_BLOCKING.String(): {}, authgrpc.AuthStatus_AUTH_STATUS_UNBLOCKING.String(): {}, }
Functions ¶
func ErrorWithParams ¶
ErrorWithParams will return an error with new message, where params get appended at end of the error message. If the input is normal error then error is wrapped. If the input is a GRPC error it will create a new GRPC error. Note GRPC error returned cannot be used to check `errors.Is`.
Types ¶
type Auth ¶ added in v1.2.0
type Auth struct {
authgrpc.UnimplementedServiceServer
// contains filtered or unexported fields
}
Auth implements the procedure calls defined as protobufs. See https://github.com/openkcm/api-sdk/blob/main/proto/kms/api/cmk/registry/auth/v1/auth.proto.
func NewAuth ¶ added in v1.2.0
func NewAuth(repo repository.Repository, orbital *Orbital, validation *validation.Validation) *Auth
NewAuth creates and return a new instance of Auth. It also registers the job handlers to the Orbital instance.
func (*Auth) ApplyAuth ¶ added in v1.2.0
func (a *Auth) ApplyAuth(ctx context.Context, req *authgrpc.ApplyAuthRequest) (*authgrpc.ApplyAuthResponse, error)
ApplyAuth creates a new auth and starts a job to apply it to the linked tenant. If an auth with the same external ID already exists, it returns success to make the action idempotent.
func (*Auth) ConfirmJob ¶ added in v1.2.0
ConfirmJob confirms that the auth associated with the job exists.
func (*Auth) GetAuth ¶ added in v1.2.0
func (a *Auth) GetAuth(ctx context.Context, req *authgrpc.GetAuthRequest) (*authgrpc.GetAuthResponse, error)
GetAuth retrieves an auth by its external ID.
func (*Auth) HandleJobCanceled ¶ added in v1.2.0
HandleJobCanceled updates auth when the job is canceled.
func (*Auth) HandleJobDone ¶ added in v1.2.0
HandleJobDone updates auth when the job is done.
func (*Auth) HandleJobFailed ¶ added in v1.2.0
HandleJobFailed updates auth when the job is failed.
func (*Auth) ListAuths ¶ added in v1.6.0
func (a *Auth) ListAuths(ctx context.Context, in *authgrpc.ListAuthsRequest) (*authgrpc.ListAuthsResponse, error)
func (*Auth) RemoveAuth ¶ added in v1.2.0
func (a *Auth) RemoveAuth(ctx context.Context, req *authgrpc.RemoveAuthRequest) (*authgrpc.RemoveAuthResponse, error)
RemoveAuth marks an auth for removal by its external ID and starts a job to remove it from the linked tenant. If the auth does not exist or is not in APPLIED status, it returns an error. If the linked tenant does not exist or is not active, it returns an error.
func (*Auth) ResolveTasks ¶ added in v1.2.0
func (a *Auth) ResolveTasks(ctx context.Context, job orbital.Job, targetsByRegion map[string]orbital.ManagerTarget) (orbital.TaskResolverResult, error)
ResolveTasks determines the tasks to be executed for a given job.
type JobHandler ¶ added in v1.1.0
type JobHandler interface {
ConfirmJob(ctx context.Context, job orbital.Job) (orbital.JobConfirmResult, error)
ResolveTasks(ctx context.Context, job orbital.Job, targets map[string]orbital.ManagerTarget) (orbital.TaskResolverResult, error)
HandleJobDone(ctx context.Context, job orbital.Job) error
HandleJobCanceled(ctx context.Context, job orbital.Job) error
HandleJobFailed(ctx context.Context, job orbital.Job) error
}
JobHandler defines the lifecycle callbacks for job processing.
type Mapping ¶ added in v1.7.0
type Mapping struct {
mappinggrpc.UnimplementedServiceServer
// contains filtered or unexported fields
}
Mapping implements the procedure calls defined as protobufs. See https://github.com/openkcm/api-sdk/blob/main/proto/kms/api/cmk/registry/mapping/v1/mapping.proto.
func NewMapping ¶ added in v1.7.0
func NewMapping(repo repository.Repository, meters *Meters, validation *validation.Validation) *Mapping
NewMapping creates and returns a new instance of Mapping.
func (*Mapping) Get ¶ added in v1.7.0
func (m *Mapping) Get(ctx context.Context, in *mappinggrpc.GetRequest) (*mappinggrpc.GetResponse, error)
Get gets the mapped tenant from the system.
func (*Mapping) MapSystemToTenant ¶ added in v1.7.0
func (m *Mapping) MapSystemToTenant(ctx context.Context, in *mappinggrpc.MapSystemToTenantRequest) (*mappinggrpc.MapSystemToTenantResponse, error)
MapSystemToTenant links Systems to the Tenant.
func (*Mapping) UnmapSystemFromTenant ¶ added in v1.7.0
func (m *Mapping) UnmapSystemFromTenant(ctx context.Context, in *mappinggrpc.UnmapSystemFromTenantRequest) (*mappinggrpc.UnmapSystemFromTenantResponse, error)
UnmapSystemFromTenant unlinks Systems from the Tenant.
type Orbital ¶
type Orbital struct {
// contains filtered or unexported fields
}
Orbital manages jobs and their execution targets.
func NewOrbital ¶
NewOrbital initializes the Orbital manager with the provided database and target configurations. It sets up the AMQP clients for each target and starts the manager.
func (*Orbital) PrepareJob ¶
PrepareJob creates a new job with the given data, external ID, and job type.
func (*Orbital) RegisterJobHandler ¶ added in v1.1.0
func (o *Orbital) RegisterJobHandler(jobType string, handler JobHandler)
RegisterJobHandler registers a JobHandler for a specific job type.
type System ¶
type System struct {
systemgrpc.UnimplementedServiceServer
// contains filtered or unexported fields
}
System implements the procedure calls defined as protobufs. See https://github.com/openkcm/api-sdk/blob/main/proto/kms/api/cmk/registry/system/v1/system.proto.
func NewSystem ¶
func NewSystem(repo repository.Repository, meters *Meters, validation *validation.Validation) *System
NewSystem creates and return a new instance of System.
func (*System) DeleteSystem ¶
func (s *System) DeleteSystem(ctx context.Context, in *systemgrpc.DeleteSystemRequest) (*systemgrpc.DeleteSystemResponse, error)
DeleteSystem handles the deletion of a new System. The response contains deletion status and error if failed.
func (*System) ListSystems ¶
func (s *System) ListSystems(ctx context.Context, in *systemgrpc.ListSystemsRequest) (*systemgrpc.ListSystemsResponse, error)
ListSystems retrieves a list of Systems based on optional query parameters such as tenant_id. region and external_id To retrieve sSystems one of tenant_id or a combination of region and external_id must be provided.
func (*System) RegisterSystem ¶
func (s *System) RegisterSystem(ctx context.Context, in *systemgrpc.RegisterSystemRequest) (*systemgrpc.RegisterSystemResponse, error)
RegisterSystem handles the creation of a new System. The response contains the created System's ID.
func (*System) RemoveSystemLabels ¶
func (s *System) RemoveSystemLabels(ctx context.Context, in *systemgrpc.RemoveSystemLabelsRequest) (*systemgrpc.RemoveSystemLabelsResponse, error)
RemoveSystemLabels removes the specified labels from the System identified by its external ID and region. If one or more label keys are not found, they will be ignored. If the update is successful, a success message will be returned, otherwise an error will be returned.
func (*System) SetSystemLabels ¶
func (s *System) SetSystemLabels(ctx context.Context, in *systemgrpc.SetSystemLabelsRequest) (*systemgrpc.SetSystemLabelsResponse, error)
SetSystemLabels sets the labels for the System identified by its external ID and region. Existing labels with the same keys will be overwritten. If the update is successful, a success message will be returned, otherwise an error will be returned.
func (*System) UpdateSystemL1KeyClaim ¶
func (s *System) UpdateSystemL1KeyClaim(ctx context.Context, in *systemgrpc.UpdateSystemL1KeyClaimRequest) (*systemgrpc.UpdateSystemL1KeyClaimResponse, error)
UpdateSystemL1KeyClaim updates the l1_key_claim parameter of the System identified by its system_id.
func (*System) UpdateSystemStatus ¶
func (s *System) UpdateSystemStatus(ctx context.Context, in *systemgrpc.UpdateSystemStatusRequest) (*systemgrpc.UpdateSystemStatusResponse, error)
UpdateSystemStatus updates the status of the System identified by its ID. The status can be one of a predefined set of values. If the update is successful, a success message will be returned, otherwise an error will be returned.
type Tenant ¶
type Tenant struct {
tenantgrpc.UnimplementedServiceServer
// contains filtered or unexported fields
}
Tenant implements the procedure calls defined as protobufs. See https://github.com/openkcm/api-sdk/blob/main/proto/kms/api/cmk/registry/tenant/v1/tenant.proto.
func NewTenant ¶
func NewTenant(repo repository.Repository, orbital *Orbital, meters *Meters, validation *validation.Validation) *Tenant
NewTenant creates and returns a new instance of Tenant.
func (*Tenant) BlockTenant ¶
func (t *Tenant) BlockTenant(ctx context.Context, in *tenantgrpc.BlockTenantRequest) (*tenantgrpc.BlockTenantResponse, error)
BlockTenant updates the status of a Tenant to BLOCKED. If the update is successful, a success message will be returned, otherwise an error will be returned.
func (*Tenant) ConfirmJob ¶ added in v1.1.0
ConfirmJob checks if a job can be confirmed based on tenant existence and tenant status.
func (*Tenant) GetTenant ¶ added in v1.1.0
func (t *Tenant) GetTenant(ctx context.Context, in *tenantgrpc.GetTenantRequest) (*tenantgrpc.GetTenantResponse, error)
GetTenant retrieves the details of a Tenant by its ID. If the Tenant is found, its details will be returned, otherwise an error will be returned.
func (*Tenant) HandleJobCanceled ¶ added in v1.1.0
HandleJobCanceled applies the changes to the tenant based on the job type when the job is canceled.
func (*Tenant) HandleJobDone ¶ added in v1.1.0
HandleJobDone applies the changes to the tenant based on the job type when the job is done.
func (*Tenant) HandleJobFailed ¶ added in v1.1.0
HandleJobFailed applies the changes to the tenant based on the job type when the job is failed.
func (*Tenant) ListTenants ¶
func (t *Tenant) ListTenants(ctx context.Context, in *tenantgrpc.ListTenantsRequest) (*tenantgrpc.ListTenantsResponse, error)
ListTenants retrieves a list of Tenants based on optional query parameters such as id, name, region, owner_id, and owner_type. Retrieves all Tenants if all query parameters are empty.
func (*Tenant) RegisterTenant ¶
func (t *Tenant) RegisterTenant(ctx context.Context, in *tenantgrpc.RegisterTenantRequest) (*tenantgrpc.RegisterTenantResponse, error)
RegisterTenant handles the creation of a new Tenant. The response contains the created Tenant's ID.
func (*Tenant) RemoveTenantLabels ¶
func (t *Tenant) RemoveTenantLabels(ctx context.Context, in *tenantgrpc.RemoveTenantLabelsRequest) (*tenantgrpc.RemoveTenantLabelsResponse, error)
RemoveTenantLabels removes the specified labels from the Tenant identified by its external ID and region. If one or more label keys are not found, they will be ignored. If the update is successful, a success message will be returned, otherwise an error will be returned.
func (*Tenant) ResolveTasks ¶ added in v1.1.0
func (t *Tenant) ResolveTasks(_ context.Context, job orbital.Job, targetsByRegion map[string]orbital.ManagerTarget) (orbital.TaskResolverResult, error)
ResolveTasks creates a task for the job based on the tenant's region.
func (*Tenant) SetTenantLabels ¶
func (t *Tenant) SetTenantLabels(ctx context.Context, in *tenantgrpc.SetTenantLabelsRequest) (*tenantgrpc.SetTenantLabelsResponse, error)
SetTenantLabels sets the labels for the Tenant identified by its ID. Existing labels with the same keys will be overwritten. If the update is successful, a success message will be returned, otherwise an error will be returned.
func (*Tenant) SetTenantUserGroups ¶ added in v1.1.0
func (t *Tenant) SetTenantUserGroups(ctx context.Context, in *tenantgrpc.SetTenantUserGroupsRequest) (*tenantgrpc.SetTenantUserGroupsResponse, error)
func (*Tenant) TerminateTenant ¶
func (t *Tenant) TerminateTenant(ctx context.Context, in *tenantgrpc.TerminateTenantRequest) (*tenantgrpc.TerminateTenantResponse, error)
TerminateTenant updates the status of a Tenant to TERMINATED. If the update is successful, a success message will be returned, otherwise an error will be returned.
func (*Tenant) UnblockTenant ¶
func (t *Tenant) UnblockTenant(ctx context.Context, in *tenantgrpc.UnblockTenantRequest) (*tenantgrpc.UnblockTenantResponse, error)
UnblockTenant updates the status of a Tenant to ACTIVE. If the update is successful, a success message will be returned, otherwise an error will be returned.