Documentation
¶
Index ¶
- Constants
- type AuditRecordService
- type BlockedError
- type Blocker
- type CheckoutService
- type Config
- type CreditService
- type CustomerService
- type DomainService
- type GroupService
- type InvitationService
- type InvoiceService
- type KycService
- type MembershipService
- type OrganizationService
- type OrganizationToDelete
- type OrganizationToLeave
- type Parent
- type PlanService
- type PolicyService
- type ProjectService
- type ResourceService
- type RoleService
- type Rule
- type Rules
- type Service
- func (d Service) CheckOrganizationDelete(ctx context.Context, id string) ([]Blocker, error)
- func (d Service) CheckProjectDelete(ctx context.Context, id string) ([]Blocker, error)
- func (d Service) CheckUserDelete(ctx context.Context, userID string) (UserDeleteCheck, error)
- func (d Service) DeleteCustomers(ctx context.Context, id string) error
- func (d Service) DeleteGroup(ctx context.Context, id string) error
- func (d Service) DeleteOrganization(ctx context.Context, id string) error
- func (d Service) DeleteProject(ctx context.Context, id string) error
- func (d Service) DeleteUser(ctx context.Context, userID string) error
- func (d Service) OrganizationResourceBlockers(ctx context.Context, orgID string) ([]Blocker, error)
- func (d Service) ProjectResourceBlockers(ctx context.Context, projectID string) ([]Blocker, error)
- type ServiceUserService
- type SubscriptionService
- type UserDeleteCheck
- type UserDeleteNoticeConfig
- type UserPATService
- type UserService
Constants ¶
const ( BlockerActiveSubscription = "ACTIVE_SUBSCRIPTION" BlockerUnpaidInvoice = "UNPAID_INVOICE" BlockerNegativeTokenBalance = "NEGATIVE_TOKEN_BALANCE" BlockerResourcesExist = "RESOURCES_EXIST" BlockerSoleOwnerWithMembers = "SOLE_OWNER_WITH_MEMBERS" )
Reasons a delete can be blocked. The API error carries them as violation types, so a client can tell the reasons apart without reading the message text.
const ( SubjectSubscription = "billing_subscription" SubjectInvoice = "billing_invoice" SubjectBillingAccount = "billing_account" SubjectResourceNamespace = "resource_namespace" SubjectOrganization = "organization" )
Kinds of entity a Blocker's Subject id refers to.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AuditRecordService ¶ added in v0.119.0
type AuditRecordService interface {
List(ctx context.Context, query *rql.Query) (auditrecord.AuditRecordsList, error)
}
type BlockedError ¶ added in v0.116.0
BlockedError carries the blockers that stop a delete, so the caller gets one checklist instead of discovering blockers one retry at a time.
func (*BlockedError) Error ¶ added in v0.116.0
func (e *BlockedError) Error() string
type Blocker ¶ added in v0.116.0
type Blocker struct {
// Type is one of the Blocker* constants.
Type string
// Subject is the id of the entity behind the reason, or the namespace
// for BlockerResourcesExist.
Subject string
// SubjectType is one of the Subject* constants and says what kind of
// entity the Subject id refers to.
SubjectType string
// Count is the number of blocking resources, for BlockerResourcesExist.
Count int
// Message says what blocks the delete and how to clear it. Empty for
// BlockerResourcesExist, except in a refused user delete.
Message string
}
Blocker is one reason a project, an organization or a user cannot be deleted right now.
type CheckoutService ¶ added in v0.114.0
type Config ¶ added in v0.119.0
type Config struct {
Enabled bool `yaml:"enabled" mapstructure:"enabled" default:"false"`
Resources map[string]Rules `yaml:"resources" mapstructure:"resources"`
// sent whether or not Enabled is set
UserDeleteNotice UserDeleteNoticeConfig `yaml:"user_delete_notice" mapstructure:"user_delete_notice"`
}
type CreditService ¶ added in v0.114.0
type CustomerService ¶ added in v0.8.35
type DomainService ¶ added in v0.119.0
type GroupService ¶
type InvitationService ¶
type InvitationService interface {
List(ctx context.Context, flt invitation.Filter) ([]invitation.Invitation, error)
Delete(ctx context.Context, id uuid.UUID) error
}
type InvoiceService ¶ added in v0.8.35
type KycService ¶ added in v0.114.0
type MembershipService ¶ added in v0.103.0
type MembershipService interface {
OnGroupDeleted(ctx context.Context, groupID string) error
ListResourcesByPrincipal(ctx context.Context, principal authenticate.Principal, resourceType string, filter membership.ResourceFilter) ([]string, error)
ListPrincipalsByResource(ctx context.Context, resourceID, resourceType string, filter membership.MemberFilter) ([]membership.Member, error)
RemoveOrganizationMemberOnDelete(ctx context.Context, orgID, principalID, principalType string) error
RemovePrincipalPolicies(ctx context.Context, principalID, principalType string) error
}
type OrganizationService ¶
type OrganizationService interface {
GetRaw(ctx context.Context, id string) (organization.Organization, error)
DeleteModel(ctx context.Context, id string) error
}
type OrganizationToDelete ¶ added in v0.120.0
type OrganizationToDelete struct {
Organization organization.Organization
Blockers []Blocker
}
type OrganizationToLeave ¶ added in v0.120.0
type OrganizationToLeave struct {
Organization organization.Organization
RoleTitle string
Blockers []Blocker
}
type PlanService ¶ added in v0.116.0
type PolicyService ¶
type ProjectService ¶
type ResourceService ¶
type RoleService ¶
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func NewCascadeDeleter ¶
func NewCascadeDeleter(orgService OrganizationService, projService ProjectService, resService ResourceService, groupService GroupService, membershipService MembershipService, policyService PolicyService, roleService RoleService, invitationService InvitationService, userService UserService, userPATService UserPATService, domainService DomainService, serviceUserService ServiceUserService, customerService CustomerService, subService SubscriptionService, invoiceService InvoiceService, checkoutService CheckoutService, creditService CreditService, kycService KycService, planService PlanService, auditRecordService AuditRecordService, mailDialer mailer.Dialer, deleteNoticeConfig billing.OrgDeleteNoticeConfig, deletionConfig Config) *Service
func (Service) CheckOrganizationDelete ¶ added in v0.116.0
CheckOrganizationDelete reports everything that currently blocks deleting the organization, without changing anything: no subscription gets canceled and the invoice rows are read as they are (they sync from the provider on a timer). The answer is advisory — DeleteOrganization re-checks against fresh provider data before actually deleting.
func (Service) CheckProjectDelete ¶ added in v0.119.0
func (Service) CheckUserDelete ¶ added in v0.120.0
func (Service) DeleteCustomers ¶ added in v0.8.35
func (Service) DeleteGroup ¶ added in v0.103.0
DeleteGroup orchestrates teardown of a single group: clears every member's policies and relations plus the org<->group hierarchy relations via membership, then deletes the group entity itself.
func (Service) DeleteOrganization ¶
DeleteOrganization removes an org and everything belonging to it. Billing is torn down first: it talks to the billing provider and is the step most likely to fail. Identity (projects, policies, and so on) goes after, with org policies (the org owners) near the end. This way a failure at any step leaves the org owned and the delete can simply be run again. Every step treats already-deleted data as success for the same reason. That applies to data inside a half-deleted org; an org whose row is already fully gone answers not found instead, so a caller can tell a finished delete from a repeatable one (and a mistyped org id from a success).
func (Service) DeleteUser ¶ added in v0.7.6
DeleteUser stops on any blocker the check finds. Otherwise it deletes the orgs where the user is the only member and leaves the others, disabled orgs too.
func (Service) OrganizationResourceBlockers ¶ added in v0.119.0
type ServiceUserService ¶ added in v0.100.0
type ServiceUserService interface {
List(ctx context.Context, flt serviceuser.Filter) ([]serviceuser.ServiceUser, error)
Delete(ctx context.Context, id string) error
}
type SubscriptionService ¶ added in v0.8.35
type SubscriptionService interface {
List(ctx context.Context, filter subscription.Filter) ([]subscription.Subscription, error)
Cancel(ctx context.Context, id string, immediate bool) (subscription.Subscription, error)
DeleteByCustomer(ctx context.Context, customr customer.Customer) error
}
type UserDeleteCheck ¶ added in v0.120.0
type UserDeleteCheck struct {
Blockers []Blocker
OrganizationsToDelete []OrganizationToDelete
OrganizationsToLeave []OrganizationToLeave
PATCount int
}
func (UserDeleteCheck) CanDelete ¶ added in v0.120.0
func (c UserDeleteCheck) CanDelete() bool