Documentation
¶
Overview ¶
Package model defines the core domain types used across the Data Releaser, including ShareRecord, AccessRule, Manifest, and ResolvedLibrary.
Index ¶
Constants ¶
const MechanismAttribute = "mechanism"
MechanismAttribute is the ledger item attribute holding the mechanism. Its value is one of the Mechanism constants, and its absence means htsget — see StoredMechanism.
Variables ¶
var ErrInvalidTargetVpcArn = errors.New("invalid target VPC ARN")
ErrInvalidTargetVpcArn is the sentinel every ValidateTargetVpcArn failure wraps, so callers can tell a rejected ARN (the caller's mistake) from a genuine failure to write the share.
Functions ¶
func MechanismNames ¶
func MechanismNames() []string
MechanismNames returns every mechanism as the word used to name it on the command line, for reporting the available choices to an operator.
func ValidateTargetVpcArn ¶
ValidateTargetVpcArn checks that arn is a well-formed EC2 VPC ARN and, when accountID is non-empty, that it belongs to that account. Every failure wraps ErrInvalidTargetVpcArn.
Catching this matters because a malformed ARN produces no error downstream — it is simply written to the store and then never matches an authorization callout, so the mistake surfaces much later as an unexplained deny.
Types ¶
type AccessRule ¶
type AccessRule struct {
// ReferenceName restricts to a specific reference. Nil means all reference names.
ReferenceName *string `json:"referenceName,omitempty"`
// Format restricts to a specific format (BAM, CRAM, VCF, BCF). Nil means all formats.
Format *string `json:"format,omitempty"`
// Start is the 0-based inclusive start position. Nil means from the beginning.
Start *int64 `json:"start,omitempty"`
// End is the 0-based exclusive end position. Nil means to the end.
End *int64 `json:"end,omitempty"`
}
AccessRule describes one allowed access scope for a file, mirroring the htsget-rs ReferenceNameRestriction. It is shared by both the authorization service callout response (htsgetAuth[].rules) and the Manifest (files[].rules).
Semantics: an absent/nil field means that dimension is unrestricted (allow-all). Multiple AccessRules for the same file combine as a union. An absent or empty rules array means unrestricted access.
type Manifest ¶
type Manifest struct {
// HtsgetBaseUrl is the htsget-rs base URL for constructing request URLs.
HtsgetBaseUrl string `json:"htsgetBaseUrl"`
// GeneratedAt is the ISO 8601 UTC timestamp when the manifest was generated.
GeneratedAt time.Time `json:"generatedAt"`
// Libraries is the list of library entries the researcher can access.
Libraries []ManifestLibrary `json:"libraries"`
}
Manifest is the JSON document listing the library IDs and file references that a researcher has been granted access to. One manifest per researcher account. The manifest is tool-generated and descriptive only — it does not grant access.
type ManifestFile ¶
type ManifestFile struct {
// Request is the htsget request path relative to the base URL (e.g. "reads/<id>").
Request string `json:"request"`
// Rules is an optional array of AccessRules. Absent or empty means unrestricted access.
Rules []AccessRule `json:"rules,omitempty"`
}
ManifestFile represents a single file entry within a manifest library.
type ManifestLibrary ¶
type ManifestLibrary struct {
// LibraryID is the unique identifier for this library.
LibraryID string `json:"libraryId"`
// ExpiresAt is the effective expiry for this library (latest across shares, or nil if unlimited).
ExpiresAt *time.Time `json:"expiresAt"`
// Files is the list of accessible files for this library.
Files []ManifestFile `json:"files"`
}
ManifestLibrary represents a library entry within the manifest.
type Mechanism ¶
type Mechanism string
Mechanism names one of the two ways this tool grants access, and is the discriminator on records in the shared ledger table.
One table holds both kinds of record so that "what can account X read?" has a single answer. The records themselves have almost nothing in common: they carry different fields, enforce expiry by different means, and are read by different code. So every read of the table has to say which kind of record it wants, and this is the attribute that answers it.
const ( // MechanismHtsget grants range-limited reads through htsget, where each request is // authorized by a callout that reads the record. MechanismHtsget Mechanism = "htsget" // MechanismS3 grants whole-object reads directly from S3, where access is decided // by the bucket and key policies rather than by anything of ours. MechanismS3 Mechanism = "s3" )
func Mechanisms ¶
func Mechanisms() []Mechanism
Mechanisms returns every mechanism, for listing the available choices.
func ParseMechanism ¶
ParseMechanism converts an operator-supplied mechanism name, rejecting anything else including the empty string: which mechanism a mutating command acts on is never guessed, because granting the wrong kind of access does not announce itself.
func StoredMechanism ¶
StoredMechanism interprets the mechanism attribute of a ledger item.
An absent attribute means htsget. Every record written before the table was shared is an htsget share and none of them carry the attribute, so the absence has to keep meaning htsget — nothing rewrites those items, and reading one as anything else would lose a live share.
A value that is not recognised is returned as it stands rather than defaulted, so a record written by some later mechanism matches neither of today's and is left alone by both.
type ResolvedLibrary ¶
type ResolvedLibrary struct {
// LibraryID is the unique library identifier.
LibraryID string `json:"libraryId"`
// PortalRunID is the workflow run identifier that produced this file.
PortalRunID string `json:"portalRunId"`
// Bucket is the S3 bucket where the file is stored.
Bucket string `json:"bucket"`
// Key is the S3 object key of the file.
Key string `json:"key"`
// Format is the file format (e.g. "bam").
Format string `json:"format"`
// StorageClass is the S3 storage class (e.g. "STANDARD", "DEEP_ARCHIVE").
StorageClass string `json:"storageClass"`
}
ResolvedLibrary represents a library resolved from the OrcaVault Mart (mart.bam) via Athena. Each row corresponds to a single aligned-read file.
type ShareFile ¶
type ShareFile struct {
LibraryID string `json:"libraryId"`
// and without the format extension, e.g. "demo/L2400001/NA12878". Prefixing it
// with an endpoint gives the request path, e.g. "reads/demo/L2400001/NA12878".
HtsgetID string `json:"htsgetId"`
Format string `json:"format"`
}
ShareFile is a single file covered by a share, as resolved from the warehouse at share time.
type ShareRecord ¶
type ShareRecord struct {
ShareID string `json:"shareId"`
ResearcherAccountID string `json:"researcherAccountId"`
TargetVpcArn string `json:"targetVpcArn"`
LibraryIDs []string `json:"libraryIds"`
// These are what the authorization callout grants on; they are directories, so
// they cover co-located index files.
S3Prefixes []string `json:"s3Prefixes"`
// manifest can name each file's exact htsget request path. It is descriptive
// only — authorization is granted by S3Prefixes, never by this field. Records
// written before this field existed have none.
Files []ShareFile `json:"files,omitempty"`
CreatedAt time.Time `json:"createdAt"`
ExpiresAt *time.Time `json:"expiresAt"`
RevokedAt *time.Time `json:"revokedAt"`
}
ShareRecord represents a persistent record describing which library IDs are shared to which AWS account, including expiry and status. Stored in DynamoDB with shareId as the partition key.
func (*ShareRecord) EffectiveStatus ¶
func (s *ShareRecord) EffectiveStatus(now time.Time) ShareStatus
EffectiveStatus computes the current status of the share record based on the current time. The derivation logic is:
- If revokedAt is set → "revoked"
- If expiresAt is set and <= now → "expired"
- Otherwise → "active"
type ShareStatus ¶
type ShareStatus string
ShareStatus represents the effective status of a share record.
const ( )