account

package
v0.38.0 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PrincipalPolicyName default principal policy Name
	PrincipalPolicyName string
)

ValidStatuses has the valid status options

Functions

This section is empty.

Types

type Account

type Account struct {
	ID                  *string                `json:"id,omitempty" dynamodbav:"Id" schema:"id,omitempty"`                                                              // AWS Account ID
	Status              *Status                `json:"accountStatus,omitempty" dynamodbav:"AccountStatus,omitempty" schema:"status,omitempty"`                          // Status of the AWS Account
	LastModifiedOn      *int64                 `json:"lastModifiedOn,omitempty" dynamodbav:"LastModifiedOn" schema:"lastModifiedOn,omitempty"`                          // Last Modified Epoch Timestamp
	CreatedOn           *int64                 `json:"createdOn,omitempty"  dynamodbav:"CreatedOn,omitempty" schema:"createdOn,omitempty"`                              // Account CreatedOn
	AdminRoleArn        *arn.ARN               `json:"adminRoleArn,omitempty"  dynamodbav:"AdminRoleArn" schema:"adminRoleArn,omitempty"`                               // Assumed by the master account, to manage this user account
	PrincipalRoleArn    *arn.ARN               `json:"principalRoleArn,omitempty"  dynamodbav:"PrincipalRoleArn,omitempty" schema:"principalRoleArn,omitempty"`         // Assumed by principal users
	PrincipalPolicyHash *string                `json:"principalPolicyHash,omitempty" dynamodbav:"PrincipalPolicyHash,omitempty" schema:"principalPolicyHash,omitempty"` // The the hash of the policy version deployed
	Metadata            map[string]interface{} `json:"metadata,omitempty"  dynamodbav:"Metadata,omitempty" schema:"-"`                                                  // Any org specific metadata pertaining to the account
	Limit               *int64                 `json:"-" dynamodbav:"-" schema:"limit,omitempty"`
	NextID              *string                `json:"-" dynamodbav:"-" schema:"nextId,omitempty"`
	PrincipalPolicyArn  *arn.ARN               `json:"-" dynamodbav:"-" schema:"-"`
}

Account - Handles importing and exporting Accounts and non-exported Properties

func NewAccount

func NewAccount(input NewAccountInput) (*Account, error)

NewAccount creates a new instance of account

func (*Account) UnmarshalDynamoDBAttributeValue

func (a *Account) UnmarshalDynamoDBAttributeValue(av *dynamodb.AttributeValue) error

UnmarshalDynamoDBAttributeValue handles custom unmarshaling of an ARN

func (*Account) UnmarshalJSON

func (a *Account) UnmarshalJSON(data []byte) error

UnmarshalJSON helps with custom unmarshalling needs

func (*Account) Validate

func (a *Account) Validate() error

Validate the account data

type Accounts

type Accounts []Account

Accounts is a list of type Account

type Deleter

type Deleter interface {
	Delete(i *Account) error
}

Deleter Deletes an Account from the data store

type Eventer

type Eventer interface {
	AccountCreate(account *Account) error
	AccountDelete(account *Account) error
	AccountUpdate(old *Account, new *Account) error
	AccountReset(account *Account) error
}

Eventer for publishing events

type LastEvaluatedKey added in v0.33.1

type LastEvaluatedKey struct {
	ID            dynamodb.AttributeValue
	AccountStatus dynamodb.AttributeValue
}

type Manager

type Manager interface {
	ValidateAccess(role *arn.ARN) error
	UpsertPrincipalAccess(account *Account) error
	DeletePrincipalAccess(account *Account) error
}

Manager manages all the actions against an account

type MultipleReader

type MultipleReader interface {
	List(query *Account) (*Accounts, error)
}

MultipleReader reads multiple accounts from the data store

type NewAccountInput

type NewAccountInput struct {
	ID                string
	AdminRoleArn      arn.ARN
	Metadata          map[string]interface{}
	PrincipalRoleName string
}

NewAccountInput contains all the data for creating a new Account

type NewServiceInput

type NewServiceInput struct {
	PrincipalRoleName string `env:"PRINCIPAL_ROLE_NAME" envDefault:"DCEPrincipal"`
	DataSvc           ReaderWriterDeleter
	ManagerSvc        Manager
	EventSvc          Eventer
}

NewServiceInput Input for creating a new Service

type Reader

type Reader interface {
	SingleReader
	MultipleReader
}

Reader data Layer

type ReaderWriterDeleter

type ReaderWriterDeleter interface {
	Reader
	WriterDeleter
}

ReaderWriterDeleter includes Reader and Writer interfaces

type Service

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

Service is a type corresponding to a Account table record

func NewService

func NewService(input NewServiceInput) *Service

NewService creates a new instance of the Service

func (*Service) Create

func (a *Service) Create(data *Account) (*Account, error)

Create creates a new account using the data provided. Returns the account record

func (*Service) Delete

func (a *Service) Delete(data *Account) error

Delete finds a given account and deletes it if it is not of status `Leased`. Returns the account.

func (*Service) Get

func (a *Service) Get(ID string) (*Account, error)

Get returns an account from ID

func (*Service) List

func (a *Service) List(query *Account) (*Accounts, error)

List Get a list of accounts based on a query

func (*Service) ListPages

func (a *Service) ListPages(query *Account, fn func(*Accounts) bool) error

ListPages Execute a function per page of accounts

func (*Service) Reset

func (a *Service) Reset(id string) (*Account, error)

Reset initiates the Reset account process. It will not change the status as there may be many reasons why a reset is called. Delete, Lease Ending, etc.

func (*Service) Save

func (a *Service) Save(data *Account) error

Save writes the record to the dataSvc

func (*Service) Update

func (a *Service) Update(ID string, data *Account) (*Account, error)

Update the Account record in DynamoDB

func (*Service) UpsertPrincipalAccess

func (a *Service) UpsertPrincipalAccess(data *Account) error

UpsertPrincipalAccess merges principal access to make sure its in sync with expectations

type SingleReader

type SingleReader interface {
	Get(ID string) (*Account, error)
}

SingleReader Reads Account information from the data store

type Status

type Status string

Status is an account status type

const (
	// StatusNone status
	StatusNone Status = "None"
	// StatusReady status
	StatusReady Status = "Ready"
	// StatusNotReady status
	StatusNotReady Status = "NotReady"
	// StatusLeased status
	StatusLeased Status = "Leased"
	// StatusOrphaned status
	StatusOrphaned Status = "Orphaned"
)

func (Status) StatusPtr

func (c Status) StatusPtr() *Status

StatusPtr returns a pointer to the string value of AccountStatus

func (Status) String

func (c Status) String() string

String returns the string value of AccountStatus

func (Status) StringPtr

func (c Status) StringPtr() *string

StringPtr returns a pointer to the string value of AccountStatus

type Writer

type Writer interface {
	Write(i *Account, lastModifiedOn *int64) error
}

Writer put an item into the data store

type WriterDeleter

type WriterDeleter interface {
	Writer
	Deleter
}

WriterDeleter data layer

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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