dmfr

package
v1.0.0-rc0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2024 License: GPL-3.0 Imports: 18 Imported by: 3

Documentation

Overview

Package dmfr provides tool and utilities for working with DMFR files and database representations of feeds and feed versions.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Feed

type Feed struct {
	FeedID            string            `json:"id" db:"onestop_id"`
	SupersedesIDs     tt.Strings        `json:"supersedes_ids,omitempty" db:"-"`
	Name              tt.String         `json:"name,omitempty"`
	Description       tt.String         `json:"description,omitempty"`
	Spec              string            `json:"spec,omitempty"`
	URLs              FeedUrls          `json:"urls,omitempty" db:"urls"`
	Languages         FeedLanguages     `json:"languages,omitempty"`
	License           FeedLicense       `json:"license,omitempty"`
	Authorization     FeedAuthorization `json:"authorization,omitempty" db:"auth"`
	Tags              tt.Tags           `json:"tags,omitempty" db:"feed_tags" `
	File              string            `json:"-"` // internal
	DeletedAt         tt.Time           `json:"-"` // internal
	tt.DatabaseEntity `json:"-"`        // internal
	tt.Timestamps     `json:"-"`        // internal
}

Feed listed in a parsed DMFR file

func (*Feed) EntityID added in v0.18.0

func (ent *Feed) EntityID() string

EntityID .

func (*Feed) Equal added in v0.18.0

func (ent *Feed) Equal(other *Feed) bool

Equal compares the JSON representation of two feeds

func (*Feed) MatchSecrets added in v0.18.0

func (ent *Feed) MatchSecrets(secrets []Secret, urltype string) (Secret, error)

func (Feed) TableName added in v0.18.0

func (Feed) TableName() string

TableName .

type FeedAssociatedFeeds added in v0.18.0

type FeedAssociatedFeeds []string

FeedAssociatedFeeds .

func (*FeedAssociatedFeeds) Scan added in v0.18.0

func (a *FeedAssociatedFeeds) Scan(value interface{}) error

Scan .

func (FeedAssociatedFeeds) Value added in v0.18.0

func (a FeedAssociatedFeeds) Value() (driver.Value, error)

Value .

type FeedAuthorization added in v0.18.0

type FeedAuthorization struct {
	Type      string `json:"type,omitempty"` // ["header", "basic_auth", "query_param", "path_segment", "replace_url"]
	ParamName string `json:"param_name,omitempty"`
	InfoURL   string `json:"info_url,omitempty"`
}

FeedAuthorization contains details about how to access a Feed.

func (*FeedAuthorization) Scan added in v0.18.0

func (a *FeedAuthorization) Scan(value interface{}) error

Scan .

func (FeedAuthorization) Value added in v0.18.0

func (a FeedAuthorization) Value() (driver.Value, error)

Value .

type FeedFetch added in v0.10.1

type FeedFetch struct {
	FeedID        int
	URLType       string
	URL           string
	Success       bool
	FetchedAt     tt.Time
	FetchError    tt.String
	ResponseSize  tt.Int
	ResponseCode  tt.Int
	ResponseSHA1  tt.String
	FeedVersionID tt.Int // optional field, don't use FeedVersionEntity
	tt.Timestamps
	tt.DatabaseEntity
}

FeedFetch is a record of when feed data was fetched via a URL

func (*FeedFetch) TableName added in v0.10.1

func (ent *FeedFetch) TableName() string

type FeedLanguages

type FeedLanguages []string

FeedLanguages .

func (*FeedLanguages) Scan added in v0.18.0

func (a *FeedLanguages) Scan(value interface{}) error

Scan .

func (FeedLanguages) Value added in v0.18.0

func (a FeedLanguages) Value() (driver.Value, error)

Value .

type FeedLicense added in v0.18.0

type FeedLicense struct {
	SpdxIdentifier          string `json:"spdx_identifier,omitempty"`
	URL                     string `json:"url,omitempty"`
	UseWithoutAttribution   string `json:"use_without_attribution,omitempty"`
	CreateDerivedProduct    string `json:"create_derived_product,omitempty"`
	RedistributionAllowed   string `json:"redistribution_allowed,omitempty"`
	CommercialUseAllowed    string `json:"commercial_use_allowed,omitempty"`
	ShareAlikeOptional      string `json:"share_alike_optional,omitempty"`
	AttributionText         string `json:"attribution_text,omitempty"`
	AttributionInstructions string `json:"attribution_instructions,omitempty"`
}

FeedLicense describes the license and usage information for a Feed.

func (*FeedLicense) Scan added in v0.18.0

func (a *FeedLicense) Scan(value interface{}) error

Scan .

func (FeedLicense) Value added in v0.18.0

func (a FeedLicense) Value() (driver.Value, error)

Value .

type FeedState

type FeedState struct {
	FeedID              int
	FeedVersionID       tt.Int
	FeedPriority        tt.Int
	FetchWait           tt.Int
	FeedRealtimeEnabled bool
	Public              bool
	tt.DatabaseEntity
	tt.Timestamps
}

FeedState stores a pointer to the active FeedVersion and values that control feed fetch and permissions.

func (*FeedState) EntityID

func (ent *FeedState) EntityID() string

EntityID .

func (*FeedState) TableName

func (ent *FeedState) TableName() string

TableName .

type FeedUrls

type FeedUrls struct {
	StaticCurrent            string   `json:"static_current,omitempty"`
	StaticPlanned            string   `json:"static_planner,omitempty"`
	StaticHistoric           []string `json:"static_historic,omitempty"`
	RealtimeVehiclePositions string   `json:"realtime_vehicle_positions,omitempty"`
	RealtimeTripUpdates      string   `json:"realtime_trip_updates,omitempty"`
	RealtimeAlerts           string   `json:"realtime_alerts,omitempty"`
	GbfsAutoDiscovery        string   `json:"gbfs_auto_discovery,omitempty"`
	GbfsSystemAlerts         string   `json:"gbfs_system_alerts,omitempty"`
	MdsProvider              string   `json:"mds_provider,omitempty"`
}

FeedUrls contains URL values for a Feed.

func (*FeedUrls) Scan added in v0.18.0

func (a *FeedUrls) Scan(value interface{}) error

Scan .

func (FeedUrls) Value added in v0.18.0

func (a FeedUrls) Value() (driver.Value, error)

Value .

type FeedVersion added in v0.18.0

type FeedVersion struct {
	FeedID               int
	SHA1                 string
	SHA1Dir              string
	File                 string
	URL                  string
	EarliestCalendarDate tt.Date
	LatestCalendarDate   tt.Date
	FetchedAt            time.Time
	Fragment             tt.String
	Name                 tt.String
	Description          tt.String
	CreatedBy            tt.String
	UpdatedBy            tt.String
	tt.DatabaseEntity
	tt.Timestamps
}

FeedVersion represents a single version of a GTFS data source.

func (*FeedVersion) EntityID added in v0.18.0

func (ent *FeedVersion) EntityID() string

EntityID .

func (*FeedVersion) TableName added in v0.18.0

func (ent *FeedVersion) TableName() string

TableName sets the table name prefix.

type FeedVersionAgencyOnestopID added in v0.18.0

type FeedVersionAgencyOnestopID struct {
	EntityID  string
	OnestopID string
	tt.FeedVersionEntity
}

func (FeedVersionAgencyOnestopID) TableName added in v0.18.0

func (ent FeedVersionAgencyOnestopID) TableName() string

type FeedVersionFileInfo

type FeedVersionFileInfo struct {
	Name         string
	Size         int64
	Rows         int64
	Columns      int
	Header       string
	CSVLike      bool
	SHA1         string
	ValuesUnique tt.Counts
	ValuesCount  tt.Counts
	tt.FeedVersionEntity
	tt.DatabaseEntity
	tt.Timestamps
}

FeedVersionFileInfo describes the individual files in a static GTFS feed

func (*FeedVersionFileInfo) EntityID

func (fvi *FeedVersionFileInfo) EntityID() string

EntityID .

func (FeedVersionFileInfo) TableName

func (FeedVersionFileInfo) TableName() string

TableName .

type FeedVersionImport

type FeedVersionImport struct {
	ImportLog                 string
	ExceptionLog              string
	ImportLevel               int  // deprecated
	Success                   bool // Finished, Success Yes/No
	InProgress                bool // In Progress
	ScheduleRemoved           bool // Stop times and trips have been uimported
	InterpolatedStopTimeCount int
	EntityCount               tt.Counts
	WarningCount              tt.Counts
	GeneratedCount            tt.Counts
	SkipEntityErrorCount      tt.Counts
	SkipEntityReferenceCount  tt.Counts
	SkipEntityFilterCount     tt.Counts
	SkipEntityMarkedCount     tt.Counts
	tt.DatabaseEntity
	tt.FeedVersionEntity
	tt.Timestamps
}

FeedVersionImport is a record of when a feed version was imported into the database.

func NewFeedVersionImport added in v0.8.0

func NewFeedVersionImport() *FeedVersionImport

NewFeedVersionImport returns an initialized FeedVersionImport.

func (*FeedVersionImport) EntityID

func (fvi *FeedVersionImport) EntityID() string

EntityID .

func (FeedVersionImport) TableName

func (FeedVersionImport) TableName() string

TableName .

type FeedVersionRouteOnestopID added in v0.18.0

type FeedVersionRouteOnestopID struct {
	EntityID  string
	OnestopID string
	tt.FeedVersionEntity
}

func (FeedVersionRouteOnestopID) TableName added in v0.18.0

func (ent FeedVersionRouteOnestopID) TableName() string

type FeedVersionServiceLevel added in v0.7.1

type FeedVersionServiceLevel struct {
	StartDate tt.Date
	EndDate   tt.Date
	Monday    int
	Tuesday   int
	Wednesday int
	Thursday  int
	Friday    int
	Saturday  int
	Sunday    int
	tt.FeedVersionEntity
	tt.DatabaseEntity
}

FeedVersionServiceLevel is a cached summary of the number of seconds of scheduled service for a GTFS feed on a week-by-week basis.

func (*FeedVersionServiceLevel) EntityID added in v0.7.1

func (fvi *FeedVersionServiceLevel) EntityID() string

EntityID .

func (FeedVersionServiceLevel) TableName added in v0.7.1

func (FeedVersionServiceLevel) TableName() string

TableName .

func (*FeedVersionServiceLevel) Total added in v0.12.0

func (fvsl *FeedVersionServiceLevel) Total() int

type FeedVersionServiceWindow added in v0.12.0

type FeedVersionServiceWindow struct {
	FeedStartDate        tt.Date
	FeedEndDate          tt.Date
	EarliestCalendarDate tt.Date
	LatestCalendarDate   tt.Date
	FallbackWeek         tt.Date
	DefaultTimezone      tt.String
	tt.FeedVersionEntity
	tt.DatabaseEntity
	tt.Timestamps
}

FeedVersionServiceWindow is a cached summary of the overall start and end dates for a feed version, sourced from feed_info.txt and calendar.txt.

func (*FeedVersionServiceWindow) EntityID added in v0.12.0

func (fvi *FeedVersionServiceWindow) EntityID() string

func (FeedVersionServiceWindow) TableName added in v0.12.0

func (FeedVersionServiceWindow) TableName() string

type FeedVersionStopOnestopID added in v0.18.0

type FeedVersionStopOnestopID struct {
	EntityID  string
	OnestopID string
	tt.FeedVersionEntity
}

func (FeedVersionStopOnestopID) TableName added in v0.18.0

func (ent FeedVersionStopOnestopID) TableName() string

type FeedVersionTables added in v0.18.0

type FeedVersionTables struct {
	FetchStatDerivedTables []string
	ImportDerivedTables    []string
	SystemTables           []string
	GtfsAnonTables         []string
	GtfsEntityTables       []string
	GtfsExtTables          []string
}

func GetFeedVersionTables added in v0.18.0

func GetFeedVersionTables() FeedVersionTables

func (FeedVersionTables) AllTables added in v0.18.0

func (t FeedVersionTables) AllTables() []string

func (FeedVersionTables) ImportedTables added in v0.18.0

func (t FeedVersionTables) ImportedTables() []string

func (FeedVersionTables) ScheduleTables added in v0.18.0

func (t FeedVersionTables) ScheduleTables() []string

type Operator added in v0.18.0

type Operator struct {
	OnestopID         tt.String               `json:"onestop_id"`
	SupersedesIDs     tt.Strings              `json:"supersedes_ids,omitempty" db:"-"`
	Name              tt.String               `json:"name,omitempty"`
	ShortName         tt.String               `json:"short_name,omitempty"`
	Website           tt.String               `json:"website,omitempty"`
	AssociatedFeeds   OperatorAssociatedFeeds `json:"associated_feeds,omitempty"`
	Tags              tt.Tags                 `json:"tags,omitempty" db:"operator_tags"`
	File              tt.String               `json:"-"` // internal
	DeletedAt         tt.Time                 `json:"-"` // internal
	tt.DatabaseEntity `json:"-"`
	tt.Timestamps     `json:"-"`
}

func (*Operator) Equal added in v0.18.0

func (ent *Operator) Equal(other *Operator) bool

Equal compares the JSON representation of two operators.

func (Operator) TableName added in v0.18.0

func (Operator) TableName() string

TableName .

type OperatorAssociatedFeed added in v0.18.0

type OperatorAssociatedFeed struct {
	GtfsAgencyID         tt.String  `json:"gtfs_agency_id,omitempty" db:"gtfs_agency_id"`
	FeedOnestopID        tt.String  `json:"feed_onestop_id,omitempty" db:"-"`
	ResolvedOnestopID    tt.String  `json:"-"` // internal
	ResolvedGtfsAgencyID tt.String  `json:"-"` // internal
	ResolvedName         tt.String  `json:"-"` // internal
	ResolvedShortName    tt.String  `json:"-"` // internal
	ResolvedPlaces       tt.String  `json:"-"` // internal
	OperatorID           tt.Int     `json:"-"` // internal
	FeedID               int        `json:"-"` // internal
	tt.DatabaseEntity    `json:"-"` // internal
}

func (OperatorAssociatedFeed) TableName added in v0.18.0

func (o OperatorAssociatedFeed) TableName() string

type OperatorAssociatedFeeds added in v0.18.0

type OperatorAssociatedFeeds []OperatorAssociatedFeed

OperatorAssociatedFeeds is necessary to scan correctly from database

func (OperatorAssociatedFeeds) MarshalGQL added in v0.18.0

func (r OperatorAssociatedFeeds) MarshalGQL(w io.Writer)

MarshalGQL implements the graphql.Marshaler interface

func (*OperatorAssociatedFeeds) Scan added in v0.18.0

func (a *OperatorAssociatedFeeds) Scan(value interface{}) error

Scan .

func (*OperatorAssociatedFeeds) UnmarshalGQL added in v0.18.0

func (r *OperatorAssociatedFeeds) UnmarshalGQL(v interface{}) error

UnmarshalGQL implements the graphql.Unmarshaler interface

func (OperatorAssociatedFeeds) Value added in v0.18.0

Value .

type RawRegistry added in v0.10.1

type RawRegistry struct {
	Schema                string            `json:"$schema,omitempty"`
	Feeds                 []RawRegistryFeed `json:"feeds,omitempty"`
	Operators             []Operator        `json:"operators,omitempty"`
	Secrets               []Secret          `json:"secrets,omitempty"`
	LicenseSpdxIdentifier string            `json:"license_spdx_identifier,omitempty"`
}

func ReadRawRegistry added in v0.10.1

func ReadRawRegistry(reader io.Reader) (*RawRegistry, error)

func (*RawRegistry) Write added in v0.10.1

func (r *RawRegistry) Write(w io.Writer) error

Format raw registry, before additional processing is applied

type RawRegistryFeed added in v0.10.1

type RawRegistryFeed struct {
	Feed
	Operators []Operator `json:"operators"`
}

feed.Operators should be loaded but not exported

type Registry

type Registry struct {
	Schema                string     `json:"$schema,omitempty"`
	Feeds                 []Feed     `json:"feeds,omitempty"`
	Operators             []Operator `json:"operators,omitempty"`
	Secrets               []Secret   `json:"secrets,omitempty"`
	LicenseSpdxIdentifier string     `json:"license_spdx_identifier,omitempty"`
}

Registry represents a parsed Distributed Mobility Feed Registry (DMFR) file

func LoadAndParseRegistry

func LoadAndParseRegistry(path string) (*Registry, error)

LoadAndParseRegistry loads and parses a Distributed Mobility Feed Registry (DMFR) file from either a file system path or a URL

func ReadRegistry added in v0.10.1

func ReadRegistry(reader io.Reader) (*Registry, error)

ReadRegistry TODO

func (*Registry) Write added in v0.10.1

func (r *Registry) Write(w io.Writer) error

Format raw registry, before additional processing is applied

type Secret

type Secret struct {
	Key                string `json:"key"`
	Username           string `json:"username"`
	Password           string `json:"password"`
	AWSAccessKeyID     string `json:"aws_access_key_id"`
	AWSSecretAccessKey string `json:"aws_secret_access_key"`
	FeedID             string `json:"feed_id"`
	Filename           string `json:"filename"`
	URLType            string `json:"url_type"`
	ReplaceUrl         string `json:"replace_url"`
}

Secret .

func (Secret) MatchFeed added in v0.18.0

func (s Secret) MatchFeed(feedid string) bool

MatchFeed finds secrets associated with a DMFR FeedID.

func (Secret) MatchFilename added in v0.18.0

func (s Secret) MatchFilename(filename string) bool

MatchFilename finds secrets associated with a DMFR filename.

Jump to

Keyboard shortcuts

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