dynamo

package
v0.1523.0-MLPAB2641vou... Latest Latest
Warning

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

Go to latest
Published: Nov 5, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package dynamo provides a client for AWS DyanmoDB.

We use a combination of records for a full LPA. An example of the expected set for an LPA is:

| PK           | SK                             | Description                                                     | Type                             |
| ------------ | ------------------------------ | --------------------------------------------------------------- | -------------------------------- |
| LPA#...      | SUB#...                        | Links a OneLogin subject to all LPAs they can access            | dashboarddata.LpaLink            |
| LPA#...      | DONOR#...                      | Data entered online by the donor                                | donordata.Provided               |
| LPA#...      | RESERVED#DONOR#                | Ensure an LPA only has one donor                                |                                  |
| LPA#...      | CERTIFICATE_PROVIDER#...       | Data entered online by the certificate provider                 | certificateproviderdata.Provided |
| LPA#...      | RESERVED#CERTIFICATE_PROVIDER# | Ensure an LPA only has one certificate provider                 |                                  |
| LPA#...      | ATTORNEY#...                   | Data entered online by an attorney (or replacement/trust corp.) | attorneydata.Provided            |
| LPA#...      | VOUCHER#...                    | Data entered online by a voucher                                | voucherdata.Provided             |
| LPA#...      | RESERVED#VOUCHER#              | Ensure an LPA only has one voucher                              |                                  |
| LPA#...      | DOCUMENT#...                   | A document uploaded as evidence for a reduced fee               | document.Document                |
| LPA#...      | EVIDENCE_RECEIVED#             | Marker to show paper evidence has been sent in to the OPG       |                                  |
| UID#...      | METADATA#                      | Ensure a UID is only set once                                   |                                  |

For supporters there is data for the organisation, but also the LPA is stored against the donor differently:

| PK               | SK               | Description                                                        | Type                       |
| ---------------- | ---------------- | ------------------------------------------------------------------ | -------------------------- |
| ORGANISATION#... | ORGANISATION#... | Holds data about the organisation                                  | supporterdata.Organisation |
| ORGANISATION#... | MEMBER#...       | A member of an organisation                                        | supporterdata.Member       |
| ORGANISATION#... | MEMBERINVITE#... | An invitation for a member to join an organisation                 | supporterdata.MemberInvite |
| ORGANISATION#... | MEMBERID#...     | Allows querying a member by their ID, rather than OneLogin subject | supporter.organisationLink |
| LPA#...          | ORGANISATION#... | Data entered for an LPA by a supporter at the organisation         | donordata.Provided         |
| LPA#...          | DONOR#...        | Reference to the data accessible by the donor                      | donor.lpaReference         |

For sharing an LPA with each actor we generate records like:

| PK                           | SK                       | Description                                                    | Type               |
| ---------------------------- | ------------------------ | -------------------------------------------------------------- | ------------------ |
| VOUCHERSHAREKEY#...          | VOUCHERSHARESORT#...     | A share of the LPA to a voucher                                | sharecodedata.Link |
| DONORSHAREKEY#...            | DONORINVITE#...          | A share of an organisation created LPA to a donor              | sharecodedata.Link |
| CERTIFICATEPROVIDERSHARE#... | METADATA#...             | A share of the LPA to a certificate provider                   | sharecodedata.Link |
| ATTORNEYSHARE#...            | METADATA#...             | A share of the LPA to an attorney (or replacement/trust corp.) | sharecodedata.Link |

The scheduler uses the following structure:

| PK               | SK            | Description                          | Type            |
| ---------------- | ------------- | ------------------------------------ | --------------- |
| SCHEDULEDDAY#... | SCHEDULED#... | An event to run on the specified day | scheduled.Event |

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttorneyKeyType added in v0.1151.0

type AttorneyKeyType string

func AttorneyKey added in v0.1116.0

func AttorneyKey(s string) AttorneyKeyType

AttorneyKey is used as the SK (with LpaKey as PK) for attorney entered information.

func (AttorneyKeyType) SK added in v0.1151.0

func (t AttorneyKeyType) SK() string

type AttorneyShareKeyType added in v0.1151.0

type AttorneyShareKeyType string

func AttorneyShareKey added in v0.1151.0

func AttorneyShareKey(code string) AttorneyShareKeyType

AttorneyShareKey is used as the PK for sharing an Lpa with an attorney.

func (AttorneyShareKeyType) PK added in v0.1151.0

type CertificateProviderKeyType added in v0.1151.0

type CertificateProviderKeyType string

func CertificateProviderKey added in v0.1116.0

func CertificateProviderKey(s string) CertificateProviderKeyType

CertificateProviderKey is used as the SK (with LpaKey as PK) for certificate provider entered information.

func (CertificateProviderKeyType) SK added in v0.1151.0

type CertificateProviderShareKeyType added in v0.1151.0

type CertificateProviderShareKeyType string

func CertificateProviderShareKey added in v0.1151.0

func CertificateProviderShareKey(code string) CertificateProviderShareKeyType

CertificateProviderShareKey is used as the PK for sharing an Lpa with a certificate provider.

func (CertificateProviderShareKeyType) PK added in v0.1151.0

type Client

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

func NewClient

func NewClient(cfg aws.Config, tableName string) (*Client, error)

func (*Client) AllByKeys added in v0.712.0

func (c *Client) AllByKeys(ctx context.Context, keys []Keys) ([]map[string]types.AttributeValue, error)

func (*Client) AllByPartialSK added in v0.1025.0

func (c *Client) AllByPartialSK(ctx context.Context, pk PK, partialSk SK, v interface{}) error

func (*Client) AllBySK added in v0.1023.0

func (c *Client) AllBySK(ctx context.Context, sk SK, v interface{}) error

func (*Client) AllKeysByPK added in v0.1025.0

func (c *Client) AllKeysByPK(ctx context.Context, pk PK) ([]Keys, error)

func (*Client) AnyByPK added in v0.1487.0

func (c *Client) AnyByPK(ctx context.Context, pk PK, v interface{}) error

func (*Client) BatchPut added in v0.794.0

func (c *Client) BatchPut(ctx context.Context, values []interface{}) error

func (*Client) Create

func (c *Client) Create(ctx context.Context, v interface{}) error

Create writes data ensuring that the (PK, SK) combination is unique.

func (*Client) CreateOnly added in v0.1515.0

func (c *Client) CreateOnly(ctx context.Context, v interface{}) error

CreateOnly writes data ensuring that the PK is unique.

func (*Client) DeleteKeys added in v0.785.0

func (c *Client) DeleteKeys(ctx context.Context, keys []Keys) error

func (*Client) DeleteOne added in v0.794.0

func (c *Client) DeleteOne(ctx context.Context, pk PK, sk SK) error

func (*Client) LatestForActor added in v0.712.0

func (c *Client) LatestForActor(ctx context.Context, sk SK, v interface{}) error

func (*Client) Move added in v0.1393.0

func (c *Client) Move(ctx context.Context, oldKeys Keys, value any) error

func (*Client) One added in v0.712.0

func (c *Client) One(ctx context.Context, pk PK, sk SK, v interface{}) error

func (*Client) OneByPK added in v0.1089.0

func (c *Client) OneByPK(ctx context.Context, pk PK, v interface{}) error

func (*Client) OneByPartialSK added in v0.1025.0

func (c *Client) OneByPartialSK(ctx context.Context, pk PK, partialSK SK, v interface{}) error

func (*Client) OneBySK added in v0.1023.0

func (c *Client) OneBySK(ctx context.Context, sk SK, v interface{}) error

func (*Client) OneByUID added in v0.712.0

func (c *Client) OneByUID(ctx context.Context, uid string, v interface{}) error

func (*Client) Put

func (c *Client) Put(ctx context.Context, v interface{}) error

func (*Client) Update added in v0.794.0

func (c *Client) Update(ctx context.Context, pk PK, sk SK, values map[string]types.AttributeValue, expression string) error

func (*Client) WriteTransaction added in v0.1196.0

func (c *Client) WriteTransaction(ctx context.Context, transaction *Transaction) error

type ConditionalCheckFailedError added in v0.794.0

type ConditionalCheckFailedError struct{}

func (ConditionalCheckFailedError) Error added in v0.794.0

type DocumentKeyType added in v0.1151.0

type DocumentKeyType string

func DocumentKey added in v0.1116.0

func DocumentKey(s3Key string) DocumentKeyType

DocumentKey is used as the SK (with LpaKey as PK) for any documents uploaded as evidence for reduced fees.

func (DocumentKeyType) SK added in v0.1151.0

func (t DocumentKeyType) SK() string

type DonorInviteKeyType added in v0.1151.0

type DonorInviteKeyType string

func DonorInviteKey added in v0.1116.0

func DonorInviteKey(organisation OrganisationKeyType, lpa LpaKeyType) DonorInviteKeyType

DonorInviteKey is used as the SK (with DonorShareKey as PK) for an invitation to a donor to link an Lpa being created by a member of an organisation.

func (DonorInviteKeyType) SK added in v0.1151.0

func (t DonorInviteKeyType) SK() string

type DonorKeyType added in v0.1151.0

type DonorKeyType string

func DonorKey added in v0.1116.0

func DonorKey(s string) DonorKeyType

DonorKey is used as the SK (with LpaKey as PK) for donor entered information. It is set to PAPER when the donor information has been provided from paper forms.

func (DonorKeyType) SK added in v0.1151.0

func (t DonorKeyType) SK() string

type DonorShareKeyType added in v0.1151.0

type DonorShareKeyType string

func DonorShareKey added in v0.1116.0

func DonorShareKey(code string) DonorShareKeyType

DonorShareKey is used as the PK for sharing an Lpa with a donor.

func (DonorShareKeyType) PK added in v0.1151.0

func (t DonorShareKeyType) PK() string

type EvidenceReceivedKeyType added in v0.1151.0

type EvidenceReceivedKeyType string

func EvidenceReceivedKey added in v0.1116.0

func EvidenceReceivedKey() EvidenceReceivedKeyType

EvidenceReceivedKey is used as the SK (with LpaKey as PK) to show that paper evidence has been submitted for an Lpa.

func (EvidenceReceivedKeyType) SK added in v0.1151.0

type Keys added in v0.1151.0

type Keys struct {
	PK PK
	SK SK
}

func (*Keys) UnmarshalDynamoDBAttributeValue added in v0.1151.0

func (k *Keys) UnmarshalDynamoDBAttributeValue(av types.AttributeValue) error

func (*Keys) UnmarshalJSON added in v0.1151.0

func (k *Keys) UnmarshalJSON(text []byte) error

type LpaKeyType added in v0.1151.0

type LpaKeyType string

func LpaKey added in v0.1116.0

func LpaKey(s string) LpaKeyType

LpaKey is used as the PK for all Lpa related information.

func (LpaKeyType) ID added in v0.1165.0

func (t LpaKeyType) ID() string

func (LpaKeyType) PK added in v0.1151.0

func (t LpaKeyType) PK() string

type LpaOwnerKeyType added in v0.1151.0

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

func LpaOwnerKey added in v0.1151.0

func LpaOwnerKey(sk interface {
	SK
	lpaOwner()
}) LpaOwnerKeyType

LpaOwnerKey is used as the SK (with LpaKey as PK) to allow both donors and organisations to "own" LPAs.

func (LpaOwnerKeyType) Equals added in v0.1151.0

func (k LpaOwnerKeyType) Equals(sk SK) bool

func (LpaOwnerKeyType) MarshalDynamoDBAttributeValue added in v0.1151.0

func (k LpaOwnerKeyType) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)

func (LpaOwnerKeyType) MarshalText added in v0.1151.0

func (k LpaOwnerKeyType) MarshalText() ([]byte, error)

func (LpaOwnerKeyType) Organisation added in v0.1165.0

func (k LpaOwnerKeyType) Organisation() (OrganisationKeyType, bool)

func (LpaOwnerKeyType) SK added in v0.1151.0

func (k LpaOwnerKeyType) SK() string

func (*LpaOwnerKeyType) UnmarshalDynamoDBAttributeValue added in v0.1151.0

func (k *LpaOwnerKeyType) UnmarshalDynamoDBAttributeValue(av types.AttributeValue) error

func (*LpaOwnerKeyType) UnmarshalText added in v0.1151.0

func (k *LpaOwnerKeyType) UnmarshalText(text []byte) error

type MemberIDKeyType added in v0.1151.0

type MemberIDKeyType string

func MemberIDKey added in v0.1116.0

func MemberIDKey(memberID string) MemberIDKeyType

MemberIDKey is used as the SK (with OrganisationKey as PK) to allow retrieving a member using their ID instead of their OneLogin sub.

func (MemberIDKeyType) SK added in v0.1151.0

func (t MemberIDKeyType) SK() string

type MemberInviteKeyType added in v0.1151.0

type MemberInviteKeyType string

func MemberInviteKey added in v0.1116.0

func MemberInviteKey(email string) MemberInviteKeyType

MemberInviteKey is used as the SK (with OrganisationKey as PK) for a member invite.

func (MemberInviteKeyType) SK added in v0.1151.0

func (t MemberInviteKeyType) SK() string

type MemberKeyType added in v0.1151.0

type MemberKeyType string

func MemberKey added in v0.1116.0

func MemberKey(sessionID string) MemberKeyType

MemberKey is used as the SK (with OrganisationKey as PK) for a member of an organisation.

func (MemberKeyType) SK added in v0.1151.0

func (t MemberKeyType) SK() string

type MetadataKeyType added in v0.1151.0

type MetadataKeyType string

func MetadataKey added in v0.1116.0

func MetadataKey(s string) MetadataKeyType

Metadata is used as the SK when the value of the SK is not used for any purpose.

func (MetadataKeyType) SK added in v0.1151.0

func (t MetadataKeyType) SK() string

type NotFoundError

type NotFoundError struct{}

func (NotFoundError) Error

func (n NotFoundError) Error() string

type OrganisationKeyType added in v0.1151.0

type OrganisationKeyType string

func OrganisationKey added in v0.1116.0

func OrganisationKey(organisationID string) OrganisationKeyType

OrganisationKey is used as the PK to group organisation data; or as the SK (with OrganisationKey as PK) for the organisation itself; or as the SK (with LpaKey as PK) for the donor information entered by a member of an organisation.

func (OrganisationKeyType) ID added in v0.1165.0

func (t OrganisationKeyType) ID() string

func (OrganisationKeyType) PK added in v0.1151.0

func (t OrganisationKeyType) PK() string

func (OrganisationKeyType) SK added in v0.1151.0

func (t OrganisationKeyType) SK() string

type PK added in v0.1151.0

type PK interface{ PK() string }

type ReservedKeyType added in v0.1515.0

type ReservedKeyType string

func ReservedKey added in v0.1515.0

func ReservedKey[T SK](sk func(string) T) ReservedKeyType

ReservedKey is used to mark a key prefix as used. This allows creates for (A#abc, B#def) to check for the presence of any (A#abc, B#*) by instead using a transaction that writes [(A#abc, B#def), (A#abc, Reserved#B#)].

func (ReservedKeyType) SK added in v0.1515.0

func (t ReservedKeyType) SK() string

type SK added in v0.1151.0

type SK interface{ SK() string }

type ScheduledDayKeyType added in v0.1393.0

type ScheduledDayKeyType string

func ScheduledDayKey added in v0.1393.0

func ScheduledDayKey(at time.Time) ScheduledDayKeyType

ScheduledDayKey is used as the PK for a scheduled.Event.

func (ScheduledDayKeyType) Handled added in v0.1393.0

func (ScheduledDayKeyType) PK added in v0.1393.0

func (t ScheduledDayKeyType) PK() string

type ScheduledKeyType added in v0.1393.0

type ScheduledKeyType string

func ScheduledKey added in v0.1393.0

func ScheduledKey(at time.Time, action int) ScheduledKeyType

ScheduledKey is used as the SK for a scheduled.Event.

func (ScheduledKeyType) SK added in v0.1393.0

func (t ScheduledKeyType) SK() string

type ShareKeyType added in v0.1151.0

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

func ShareKey added in v0.1151.0

func ShareKey(pk interface {
	PK
	share()
}) ShareKeyType

ShareKey is used as the PK (with ShareSortKey as SK) for sharing an LPA with another actor.

func (ShareKeyType) MarshalDynamoDBAttributeValue added in v0.1151.0

func (k ShareKeyType) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)

func (ShareKeyType) MarshalText added in v0.1151.0

func (k ShareKeyType) MarshalText() ([]byte, error)

func (ShareKeyType) PK added in v0.1151.0

func (k ShareKeyType) PK() string

func (*ShareKeyType) UnmarshalDynamoDBAttributeValue added in v0.1151.0

func (k *ShareKeyType) UnmarshalDynamoDBAttributeValue(av types.AttributeValue) error

func (*ShareKeyType) UnmarshalText added in v0.1151.0

func (k *ShareKeyType) UnmarshalText(text []byte) error

type ShareSortKeyType added in v0.1151.0

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

func ShareSortKey added in v0.1151.0

func ShareSortKey(sk interface {
	SK
	shareSort()
}) ShareSortKeyType

ShareSortKey is used as the SK (with ShareKey as the PK) for sharing an LPA with another actor.

func (ShareSortKeyType) MarshalDynamoDBAttributeValue added in v0.1151.0

func (k ShareSortKeyType) MarshalDynamoDBAttributeValue() (types.AttributeValue, error)

func (ShareSortKeyType) MarshalText added in v0.1151.0

func (k ShareSortKeyType) MarshalText() ([]byte, error)

func (ShareSortKeyType) SK added in v0.1151.0

func (k ShareSortKeyType) SK() string

func (*ShareSortKeyType) UnmarshalDynamoDBAttributeValue added in v0.1151.0

func (k *ShareSortKeyType) UnmarshalDynamoDBAttributeValue(av types.AttributeValue) error

func (*ShareSortKeyType) UnmarshalText added in v0.1151.0

func (k *ShareSortKeyType) UnmarshalText(text []byte) error

type SubKeyType added in v0.1151.0

type SubKeyType string

func SubKey added in v0.1116.0

func SubKey(s string) SubKeyType

SubKey is used as the SK (with LpaKey as PK) to allow queries on a OneLogin sub against all Lpas an actor may have provided information on.

func (SubKeyType) SK added in v0.1151.0

func (t SubKeyType) SK() string

type Transaction added in v0.1196.0

type Transaction struct {
	Creates []any
	Puts    []any
	Deletes []Keys
}

func NewTransaction added in v0.1196.0

func NewTransaction() *Transaction

func (*Transaction) Create added in v0.1209.0

func (t *Transaction) Create(v interface{}) *Transaction

func (*Transaction) Delete added in v0.1196.0

func (t *Transaction) Delete(keys Keys) *Transaction

func (*Transaction) Put added in v0.1196.0

func (t *Transaction) Put(v interface{}) *Transaction

type UIDKeyType added in v0.1515.0

type UIDKeyType string

func UIDKey added in v0.1515.0

func UIDKey(uid string) UIDKeyType

UIDKey is used as the PK (with MetadataKey as SK) to ensure a UID can only be used once.

func (UIDKeyType) PK added in v0.1515.0

func (t UIDKeyType) PK() string

type VoucherKeyType added in v0.1366.0

type VoucherKeyType string

func VoucherKey added in v0.1366.0

func VoucherKey(s string) VoucherKeyType

VoucherKey is used as the SK (with LpaKey as PK) for voucher entered information.

func (VoucherKeyType) SK added in v0.1366.0

func (t VoucherKeyType) SK() string

type VoucherShareKeyType added in v0.1362.0

type VoucherShareKeyType string

func VoucherShareKey added in v0.1362.0

func VoucherShareKey(code string) VoucherShareKeyType

VoucherShareKey is used as the PK for sharing an Lpa with a voucher.

func (VoucherShareKeyType) PK added in v0.1362.0

func (t VoucherShareKeyType) PK() string

type VoucherShareSortKeyType added in v0.1513.0

type VoucherShareSortKeyType string

func VoucherShareSortKey added in v0.1513.0

func VoucherShareSortKey(lpa LpaKeyType) VoucherShareSortKeyType

VoucherShareSortKey is used as the SK (with ShareKey as PK) for sharing an Lpa with an actor.

func (VoucherShareSortKeyType) SK added in v0.1513.0

Jump to

Keyboard shortcuts

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