delete

package
v2.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2024 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NotFoundErr = errors.New("nothing with given name found")

NotFoundErr is a sentinel error signifying that the resource desired to be deleted was not found. Generally this error can be treated as a succeful "deletion" of the resource.

Functions

func AccountResources

func AccountResources(ctx context.Context, account Account, resourcesToDelete Resources) error

AccountResources removes all given Resources from the given Account Returns an error if any resource fails to be deleted, but attempts to delete as many resources as possible and only returns an error at the end.

func GenerateJSONSchema added in v2.10.0

func GenerateJSONSchema() ([]byte, error)

Types

type Account

type Account struct {
	// Name of this account - as defined in the manifest.Manifest
	Name string
	// UUID of this account
	UUID string
	// APIClient is a Client for authenticated access to delete resources for this Account
	APIClient Client
}

Account defines everything required to access the account management API

func (Account) String

func (a Account) String() string

type AccountAPIClient

type AccountAPIClient struct {
	// contains filtered or unexported fields
}

AccountAPIClient is the default implementation of a delete Client, accessing the Account Management API using an accounts.Client

func (*AccountAPIClient) DeleteAccountPolicy

func (c *AccountAPIClient) DeleteAccountPolicy(ctx context.Context, name string) error

DeleteAccountPolicy removes the account-level policy with the given name from the account If the policy is still bound to any groups, it will be force removed from them. Returns error if any API call fails unless the policy is already not present (HTTP 404)

func (*AccountAPIClient) DeleteEnvironmentPolicy

func (c *AccountAPIClient) DeleteEnvironmentPolicy(ctx context.Context, environmentID, name string) error

DeleteEnvironmentPolicy removes the environment-level policy with the given name from the given environment. If the policy is still bound to any groups, it will be force removed from them. Returns error if any API call fails unless the policy is already not present (HTTP 404)

func (*AccountAPIClient) DeleteGroup

func (c *AccountAPIClient) DeleteGroup(ctx context.Context, name string) error

DeleteGroup removes the group with the given name from the account Returns error if any API call fails unless the group is already not present (HTTP 404)

func (*AccountAPIClient) DeleteUser

func (c *AccountAPIClient) DeleteUser(ctx context.Context, email string) error

DeleteUser removes the user with the given email from the account Returns error if any API call fails unless the user is already not present (HTTP 404)

type AccountPolicy

type AccountPolicy struct {
	Name string
}

type Client

type Client interface {
	DeleteUser(ctx context.Context, email string) error
	DeleteGroup(ctx context.Context, name string) error
	DeleteAccountPolicy(ctx context.Context, name string) error
	DeleteEnvironmentPolicy(ctx context.Context, environment, name string) error
}

Client for deleting resources from the Account Management API

func NewAccountAPIClient

func NewAccountAPIClient(accountUUID string, restClient *accounts.Client) Client

type DeleteEntry

type DeleteEntry struct {
	Type string `yaml:"type" json:"type" mapstructure:"type" jsonschema:"required,enum=user,enum=group,enum=policy"`
}

DeleteEntry defines the one shared property of account delete entries - their Type Individual entries are to be loaded as UserDeleteEntry, GroupDeleteEntry or PolicyDeleteEntry nased on the content of Type

type DeleteEntryParserError

type DeleteEntryParserError struct {
	Value  string `json:"value"`
	Index  int    `json:"index"`
	Reason string `json:"reason"`
}

func (DeleteEntryParserError) Error

func (e DeleteEntryParserError) Error() string

type Entries added in v2.10.0

type Entries []DeleteEntry

func (Entries) JSONSchema added in v2.10.0

func (_ Entries) JSONSchema() *jsonschema.Schema

JSONSchema manually defines the schema for account DeleteEntry as the nature of this structs dependent required fields makes it impossible to simply generate the schema via reflection. This definition likely needs to change if the DeleteEntry changes

type EnvironmentPolicy

type EnvironmentPolicy struct {
	Name        string
	Environment string
}

type FileDefinition

type FileDefinition struct {
	DeleteEntries []any `yaml:"delete"`
}

type Group

type Group struct {
	Name string
}

type GroupDeleteEntry

type GroupDeleteEntry struct {
	Name string `mapstructure:"name"`
}

type PolicyDeleteEntry

type PolicyDeleteEntry struct {
	Name  string      `mapstructure:"name"`
	Level PolicyLevel `mapstructure:"level"` // either PolicyLevelAccount or PolicyLevelEnvironment
}

type PolicyLevel

type PolicyLevel struct {
	Type        string `mapstructure:"type"`
	Environment string `mapstructure:"environment"`
}

type Resources

type Resources struct {
	Users               []User
	Groups              []Group
	AccountPolicies     []AccountPolicy
	EnvironmentPolicies []EnvironmentPolicy
}

Resources defines which account resources to delete. Each field defines the information required to delete that type.

func LoadResourcesToDelete

func LoadResourcesToDelete(fs afero.Fs, deleteFile string) (Resources, error)

type SchemaDef added in v2.10.0

type SchemaDef struct {
	DeleteEntries Entries `json:"delete" jsonschema:"required"`
}

type User

type User struct {
	Email secret.Email
}

type UserDeleteEntry

type UserDeleteEntry struct {
	Email string `mapstructure:"email"`
}

Jump to

Keyboard shortcuts

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