dbTable

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

View Source
const (
	NoPermission DbPermission = 0
	Collaborate               = 1
	Read                      = 2
	Write                     = 4
	Delete                    = 8
	Administer                = 16
	Owner                     = 32
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Dataset

type Dataset struct {
	Id                           int64          `json:"id"`
	Name                         string         `json:"name"`
	State                        string         `json:"state"`
	Description                  sql.NullString `json:"description"`
	UpdatedAt                    time.Time      `json:"updated_at"`
	CreatedAt                    time.Time      `json:"created_at"`
	NodeId                       sql.NullString `json:"node_id"`
	PermissionBit                sql.NullInt32  `json:"permission_bit"`
	Type                         string         `json:"type"`
	Role                         sql.NullString `json:"role"`
	Status                       string         `json:"status"`
	AutomaticallyProcessPackages bool           `json:"automatically_process_packages"`
	Licence                      sql.NullString `json:"licence"`
	Tags                         []string       `json:"tags"`
	Contributors                 []string       `json:"contributors"`
	BannerId                     uuid.UUID      `json:"banner_id"`
	ReadmeId                     uuid.UUID      `json:"readme_id"`
	StatusId                     int32          `json:"status_id"`
	PublicationStatusId          sql.NullInt32  `json:"publication_status_id"`
	Size                         sql.NullInt64  `json:"size"`
	ETag                         time.Time      `json:"etag"`
	DataUseAgreementId           sql.NullInt32  `json:"data_use_agreement_id"`
	ChangelogId                  uuid.NullUUID  `json:"changelog_id"`
}

func (*Dataset) GetAll

func (d *Dataset) GetAll(db core.PostgresAPI, organizationId int) ([]Dataset, error)

GetAll returns all rows in the Upload Record Table

type DatasetStorage

type DatasetStorage struct {
	DatasetId int64 `json:"dataset_id"`
	Size      int64 `json:"size"`
}

func (*DatasetStorage) Increment

func (d *DatasetStorage) Increment(db core.PostgresAPI, datasetId int64, size int64) error

Increment increases the storage associated with the provided dataset.

type DatasetTeam

type DatasetTeam struct {
	DatasetId int64        `json:"dataset_id"`
	TeamId    int64        `json:"team_id"`
	Role      dataset.Role `json:"role"`
	CreatedAt time.Time    `json:"created_at"`
	UpdatedAt time.Time    `json:"updated_at"`
}

type DatasetUser

type DatasetUser struct {
	DatasetId int64        `json:"dataset_id"`
	UserId    int64        `json:"user_id"`
	Role      dataset.Role `json:"role"`
	CreatedAt time.Time    `json:"created_at"`
	UpdatedAt time.Time    `json:"updated_at"`
}

type DbPermission

type DbPermission int64

func (DbPermission) String

func (s DbPermission) String() string

type ErrFileNotFound

type ErrFileNotFound struct{}

func (*ErrFileNotFound) Error

func (m *ErrFileNotFound) Error() string

type ErrMultipleRowsAffected

type ErrMultipleRowsAffected struct{}

func (*ErrMultipleRowsAffected) Error

func (m *ErrMultipleRowsAffected) Error() string

type FeatureFlags

type FeatureFlags struct {
	OrganizationId int64     `json:"organization_id"`
	Feature        string    `json:"feature"`
	Enabled        bool      `json:"enabled"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

func (*FeatureFlags) GetAll

func (d *FeatureFlags) GetAll(db core.PostgresAPI, organizationId int64) ([]FeatureFlags, error)

GetAll returns all rows in the FeatureFlags Table

type File

type File struct {
	Id              string                          `json:"id"`
	PackageId       int                             `json:"package_id"`
	Name            string                          `json:"name"`
	FileType        fileType.Type                   `json:"file_type"`
	S3Bucket        string                          `json:"s3_bucket"`
	S3Key           string                          `json:"s3_key"`
	ObjectType      objectType.ObjectType           `json:"object_type"`
	Size            int64                           `json:"size"`
	CheckSum        string                          `json:"checksum"`
	UUID            uuid.UUID                       `json:"uuid"`
	ProcessingState processingState.ProcessingState `json:"processing_state"`
	UploadedState   uploadState.UploadedState       `json:"uploaded_state"`
	CreatedAt       time.Time                       `json:"created_at"`
	UpdatedAt       time.Time                       `json:"updated_at"`
}

func (*File) Add

func (p *File) Add(db core.PostgresAPI, files []FileParams) ([]File, error)

func (*File) UpdateBucket

func (p *File) UpdateBucket(db core.PostgresAPI, uploadId string, bucket string, s3Key string, organizationId int64) error

UpdateBucket updates the storage bucket as part of upload process and sets Status

type FileParams

type FileParams struct {
	PackageId  int                   `json:"package_id"`
	Name       string                `json:"name"`
	FileType   fileType.Type         `json:"file_type"`
	S3Bucket   string                `json:"s3_bucket"`
	S3Key      string                `json:"s3_key"`
	ObjectType objectType.ObjectType `json:"object_type"`
	Size       int64                 `json:"size"`
	CheckSum   string                `json:"checksum"`
	Sha256     string                `json:"sha256"`
	UUID       uuid.UUID             `json:"uuid"`
}

type ManifestFilePrimaryKey

type ManifestFilePrimaryKey struct {
	ManifestId string `dynamodbav:"ManifestId"`
	UploadId   string `dynamodbav:"UploadId"`
}

type ManifestFileTable

type ManifestFileTable struct {
	ManifestId     string `dynamodbav:"ManifestId"`
	UploadId       string `dynamodbav:"UploadId"`
	FilePath       string `dynamodbav:"FilePath,omitempty"`
	FileName       string `dynamodbav:"FileName"`
	MergePackageId string `dynamodbav:"MergePackageId,omitempty"`
	Status         string `dynamodbav:"Status"`
	FileType       string `dynamodbav:"FileType"`
	InProgress     string `dynamodbav:"InProgress"`
}

ManifestFileTable is a representation of a ManifestFile in DynamoDB

func (*ManifestFileTable) GetFilesForPath added in v1.2.0

func (f *ManifestFileTable) GetFilesForPath(client core.DynamoDBAPI, tableName string, manifestId string, path string, filter string,
	limit int32, startKey map[string]types.AttributeValue) (*dynamodb.QueryOutput, error)

GetFilesForPath returns files in path for a upload with optional filter.

func (*ManifestFileTable) GetFilesPaginated added in v1.2.0

func (f *ManifestFileTable) GetFilesPaginated(client core.DynamoDBAPI, tableName string, manifestId string, status sql.NullString,
	limit int32, startKey map[string]types.AttributeValue) ([]ManifestFileTable, map[string]types.AttributeValue, error)

GetFilesPaginated returns paginated list of files for a given manifestID and optional status.

func (*ManifestFileTable) GetManifestFile added in v1.2.0

func (f *ManifestFileTable) GetManifestFile(client core.DynamoDBAPI, tableName string, manifestId string, uploadId string) (*ManifestFileTable, error)

GetManifestFile returns a upload file from the ManifestFile Table.

func (*ManifestFileTable) SyncFiles added in v1.2.0

func (f *ManifestFileTable) SyncFiles(client core.DynamoDBAPI, tableName string, manifestId string, fileSlice []manifestFile.FileDTO, forceStatus *manifestFile.Status) (*manifest.AddFilesStats, error)

SyncFiles adds or updates files in the manifest file table

func (*ManifestFileTable) UpdateFileTableStatus added in v1.2.0

func (f *ManifestFileTable) UpdateFileTableStatus(client core.DynamoDBAPI, tableName string, manifestId string, uploadId string, status manifestFile.Status, msg string) error

UpdateFileTableStatus updates the status of the file in the file-table dynamodb

type ManifestTable

type ManifestTable struct {
	ManifestId     string `dynamodbav:"ManifestId"`
	DatasetId      int64  `dynamodbav:"DatasetId"`
	DatasetNodeId  string `dynamodbav:"DatasetNodeId"`
	OrganizationId int64  `dynamodbav:"OrganizationId"`
	UserId         int64  `dynamodbav:"UserId"`
	Status         string `dynamodbav:"Status"`
	DateCreated    int64  `dynamodbav:"DateCreated"`
}

ManifestTable is a representation of a Manifest in DynamoDB

func (*ManifestTable) CreateManifest added in v1.2.0

func (m *ManifestTable) CreateManifest(client core.DynamoDBAPI, manifestTableName string, item ManifestTable) error

CreateManifest creates a new Manifest in DynamoDB

func (*ManifestTable) GetFromManifest added in v1.2.0

func (m *ManifestTable) GetFromManifest(client core.DynamoDBAPI, manifestTableName string, manifestId string) (*ManifestTable, error)

GetFromManifest returns a Manifest item for a given upload ID.

func (*ManifestTable) GetManifestsForDataset added in v1.2.0

func (m *ManifestTable) GetManifestsForDataset(client core.DynamoDBAPI, manifestTableName string, datasetNodeId string) ([]ManifestTable, error)

GetManifestsForDataset returns all manifests for a given dataset.

func (*ManifestTable) UpdateManifestStatus added in v1.2.0

func (m *ManifestTable) UpdateManifestStatus(client core.DynamoDBAPI, tableName string, manifestId string, status manifest.Status) error

UpdateManifestStatus updates the status of the upload in dynamodb

type Organization

type Organization struct {
	Id            int64          `json:"id"`
	Name          string         `json:"name"`
	Slug          string         `json:"slug"`
	NodeId        string         `json:"node_id"`
	StorageBucket sql.NullString `json:"storage_bucket"`
	PublishBucket sql.NullString `json:"publish_bucket"`
	EmbargoBucket sql.NullString `json:"embargo_bucket"`
	CreatedAt     time.Time      `json:"created_at"`
	UpdatedAt     time.Time      `json:"updated_at"`
}

func (*Organization) Get

func (o *Organization) Get(db core.PostgresAPI, id int64) (*Organization, error)

type OrganizationStorage

type OrganizationStorage struct {
	OrganizationId int64 `json:"organization_id"`
	Size           int64 `json:"size"`
}

func (*OrganizationStorage) Increment

func (d *OrganizationStorage) Increment(db core.PostgresAPI, organizationId int64, size int64) error

Increment increases the storage associated with the provided organization.

type OrganizationUser

type OrganizationUser struct {
	OrganizationId int64        `json:"organization_id"`
	UserId         int64        `json:"user_id"`
	DbPermission   DbPermission `json:"permission_bit"`
	CreatedAt      time.Time    `json:"created_at"`
	UpdatedAt      time.Time    `json:"updated_at"`
}

func (*OrganizationUser) GetByUserId

func (o *OrganizationUser) GetByUserId(db core.PostgresAPI, id int64) (*OrganizationUser, error)

type Package

type Package struct {
	Id           int64                         `json:"id"`
	Name         string                        `json:"name"`
	PackageType  packageType.Type              `json:"type"`
	PackageState packageState.State            `json:"state"`
	NodeId       string                        `json:"node_id"`
	ParentId     sql.NullInt64                 `json:"parent_id"`
	DatasetId    int                           `json:"dataset_id"`
	OwnerId      int                           `json:"owner_id"`
	Size         sql.NullInt64                 `json:"size"`
	ImportId     sql.NullString                `json:"import_id"`
	Attributes   packageInfo.PackageAttributes `json:"attributes"`
	CreatedAt    time.Time                     `json:"created_at"`
	UpdatedAt    time.Time                     `json:"updated_at"`
}

Package is a representation of a container on Pennsieve that contains one or more sourceFiles

func (*Package) Add

func (p *Package) Add(db core.PostgresAPI, records []PackageParams) ([]Package, error)

Add adds multiple packages to the Pennsieve Postgres DB

func (*Package) Children

func (p *Package) Children(db core.PostgresAPI, organizationId int, parent *Package, datasetId int, onlyFolders bool) ([]Package, error)

Children returns an array of Packages that have a specific parent package or root.

type PackageMap

type PackageMap = map[string]Package

PackageMap maps path to models.Package

type PackageParams

type PackageParams struct {
	Name         string                        `json:"name"`
	PackageType  packageType.Type              `json:"type"`
	PackageState packageState.State            `json:"state"`
	NodeId       string                        `json:"node_id"`
	ParentId     int64                         `json:"parent_id"`
	DatasetId    int                           `json:"dataset_id"`
	OwnerId      int                           `json:"owner_id"`
	Size         int64                         `json:"size"`
	ImportId     sql.NullString                `json:"import_id"`
	Attributes   packageInfo.PackageAttributes `json:"attributes"`
}

PackageParams is used as the input to create a package

type PackageStorage

type PackageStorage struct {
	PackageId int64 `json:"package_id"`
	Size      int64 `json:"size"`
}

func (*PackageStorage) Increment

func (p *PackageStorage) Increment(db core.PostgresAPI, packageId int64, size int64) error

Increment increases the storage associated with the provided package.

func (*PackageStorage) IncrementAncestors

func (p *PackageStorage) IncrementAncestors(db core.PostgresAPI, parentId int64, size int64) error

IncrementAncestors increases the storage associated with the parents of the provided package.

type Token

type Token struct {
	Id             int64     `json:"id"`
	Name           string    `json:"name"`
	Token          string    `json:"token"`
	OrganizationId string    `json:"organization_id"`
	UserId         bool      `json:"user_id"`
	CognitoId      string    `json:"cognito_id"`
	LastUsed       int64     `json:"last_used"`
	CreatedAt      time.Time `json:"created_at"`
	UpdatedAt      time.Time `json:"updated_at"`
}

func (*Token) GetByCognitoId

func (t *Token) GetByCognitoId(db core.PostgresAPI, id string) (*Token, error)

GetByCognitoId returns a user from Postgress based on his/her cognito-id This function also returns the preferred org and whether the user is a super-admin.

func (*Token) GetUserByCognitoId

func (t *Token) GetUserByCognitoId(db core.PostgresAPI, id string) (*User, error)

GetUserByCognitoId returns a Pennsieve User based on the cognito id in the token pool.

type User

type User struct {
	Id           int64  `json:"id"`
	NodeId       string `json:"node_id"`
	Email        string `json:"email"`
	FirstName    string `json:"first_name"`
	LastName     string `json:"last_name"`
	IsSuperAdmin bool   `json:"is_super_admin"`
	PreferredOrg int64  `json:"preferred_org_id"`
}

func (*User) GetByCognitoId

func (u *User) GetByCognitoId(db core.PostgresAPI, id string) (*User, error)

GetByCognitoId returns a user from Postgress based on his/her cognito-id This function also returns the preferred org and whether the user is a super-admin.

Jump to

Keyboard shortcuts

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