model

package
v0.0.0-...-ee3d319 Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2018 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Overview

Adding Models

Each model is kept in the model package of the REST v2 API in its own file. To create a new model, define a struct containing all of the fields that it will return and implement its two main interface methods BuildFromService and ToService. Be sure to include struct tags to the define the names the fields will have when serialized to JSON.

Guidlines for Creating Models

Include as much data as a user is likely to want when inspecting this resource. This is likely to be more information than seems directly needed, but there is little penalty to its inclusion.

Use APIString instead of Golang's string type. APIString serializes empty strings as JSON null instead of Go's zero type of '""'.

Use APITime instead of go's time type. APITime is a type that wraps Go's time.Time and automatically and correctly serializes it to ISO-8601 UTC time.

Return an error when type casting fails.

Model Methods

The Model type is an interface with two methods.

BuildFromService(in interface{}) error

BuildFromService fetches all needed data from the passed in object and sets them on the model. BuildFromService may sometimes be called multiple times with different types that all contain data to build up the model object. In this case, a type switch is likely necessary to determine what has been passed in.

ToService()(interface{}, error)

ToService creates an as-complete-as-possible version of the service layer's version of this model. For example, if this is is a REST v2 Task model, the ToService method creates a service layer Task and sets all of the fields it is able to and returns it.

Index

Constants

View Source
const (
	// This string defines ISO-8601 UTC with 3 fractional seconds behind a dot
	// specified by the API spec document.
	APITimeFormat = "\"2006-01-02T15:04:05.000Z\""
)
View Source
const (
	LogLinkFormat = "%s/task_log_raw/%s/%d?type=%s"
)

Variables

This section is empty.

Functions

func FromAPIString

func FromAPIString(in APIString) string

Types

type APIAWSConfig

type APIAWSConfig struct {
	Secret APIString `json:"aws_secret"`
	Id     APIString `json:"aws_id"`
}

func (*APIAWSConfig) BuildFromService

func (a *APIAWSConfig) BuildFromService(h interface{}) error

func (*APIAWSConfig) ToService

func (a *APIAWSConfig) ToService() (interface{}, error)

type APIAdminEvent

type APIAdminEvent struct {
	Timestamp time.Time `json:"ts"`
	User      string    `json:"user"`
	Section   string    `json:"section"`
	Before    Model     `json:"before"`
	After     Model     `json:"after"`
	Guid      string    `json:"guid"`
}

func (*APIAdminEvent) BuildFromService

func (e *APIAdminEvent) BuildFromService(h interface{}) error

func (*APIAdminEvent) ToService

func (e *APIAdminEvent) ToService() (interface{}, error)

type APIAdminSettings

type APIAdminSettings struct {
	Alerts             *APIAlertsConfig                  `json:"alerts,omitempty"`
	Amboy              *APIAmboyConfig                   `json:"amboy,omitempty"`
	Api                *APIapiConfig                     `json:"api,omitempty"`
	ApiUrl             APIString                         `json:"api_url,omitempty"`
	AuthConfig         *APIAuthConfig                    `json:"auth,omitempty"`
	Banner             APIString                         `json:"banner,omitempty"`
	BannerTheme        APIString                         `json:"banner_theme,omitempty"`
	ClientBinariesDir  APIString                         `json:"client_binaries_dir,omitempty"`
	ConfigDir          APIString                         `json:"configdir,omitempty"`
	Credentials        map[string]string                 `json:"credentials,omitempty"`
	Expansions         map[string]string                 `json:"expansions,omitempty"`
	GithubPRCreatorOrg APIString                         `json:"github_pr_creator_org,omitempty"`
	HostInit           *APIHostInitConfig                `json:"hostinit,omitempty"`
	IsNonProd          *bool                             `json:"isnonprod,omitempty"`
	Jira               *APIJiraConfig                    `json:"jira,omitempty"`
	Keys               map[string]string                 `json:"keys,omitempty"`
	LoggerConfig       *APILoggerConfig                  `json:"logger_config,omitempty"`
	LogPath            APIString                         `json:"log_path,omitempty"`
	NewRelic           *APINewRelicConfig                `json:"new_relic,omitempty"`
	Notify             *APINotifyConfig                  `json:"notify,omitempty"`
	Plugins            map[string]map[string]interface{} `json:"plugins,omitempty"`
	PprofPort          APIString                         `json:"pprof_port,omitempty"`
	Providers          *APICloudProviders                `json:"providers,omitempty"`
	RepoTracker        *APIRepoTrackerConfig             `json:"repotracker,omitempty"`
	Scheduler          *APISchedulerConfig               `json:"scheduler,omitempty"`
	ServiceFlags       *APIServiceFlags                  `json:"service_flags,omitempty"`
	Slack              *APISlackConfig                   `json:"slack,omitempty"`
	Splunk             *APISplunkConnectionInfo          `json:"splunk,omitempty"`
	SuperUsers         []string                          `json:"superusers,omitempty"`
	Ui                 *APIUIConfig                      `json:"ui,omitempty"`
}

APIAdminSettings is the structure of a response to the admin route

func NewConfigModel

func NewConfigModel() *APIAdminSettings

func (*APIAdminSettings) BuildFromService

func (as *APIAdminSettings) BuildFromService(h interface{}) error

BuildFromService builds a model from the service layer

func (*APIAdminSettings) ToService

func (as *APIAdminSettings) ToService() (interface{}, error)

ToService returns a service model from an API model

type APIAlertsConfig

type APIAlertsConfig struct {
	SMTP *APISMTPConfig `json:"smtp"`
}

func (*APIAlertsConfig) BuildFromService

func (a *APIAlertsConfig) BuildFromService(h interface{}) error

func (*APIAlertsConfig) ToService

func (a *APIAlertsConfig) ToService() (interface{}, error)

type APIAlias

type APIAlias struct {
	Alias   APIString `json:"alias"`
	Variant APIString `json:"variant"`
	Task    APIString `json:"task"`
}

APIAlias is the model to be returned by the API whenever aliass are fetched.

func (*APIAlias) BuildFromService

func (apiAlias *APIAlias) BuildFromService(h interface{}) error

BuildFromService converts from service level structs to an APIAlias.

func (*APIAlias) ToService

func (apiAlias *APIAlias) ToService() (interface{}, error)

ToService returns a service layer alias using the data from APIAlias.

type APIAmboyConfig

type APIAmboyConfig struct {
	Name           APIString `json:"name"`
	DB             APIString `json:"database"`
	PoolSizeLocal  int       `json:"pool_size_local"`
	PoolSizeRemote int       `json:"pool_size_remote"`
	LocalStorage   int       `json:"local_storage_size"`
}

func (*APIAmboyConfig) BuildFromService

func (a *APIAmboyConfig) BuildFromService(h interface{}) error

func (*APIAmboyConfig) ToService

func (a *APIAmboyConfig) ToService() (interface{}, error)

type APIAuthConfig

type APIAuthConfig struct {
	Crowd  *APICrowdConfig      `json:"crowd"`
	Naive  *APINaiveAuthConfig  `json:"naive"`
	Github *APIGithubAuthConfig `json:"github"`
}

func (*APIAuthConfig) BuildFromService

func (a *APIAuthConfig) BuildFromService(h interface{}) error

func (*APIAuthConfig) ToService

func (a *APIAuthConfig) ToService() (interface{}, error)

type APIAuthUser

type APIAuthUser struct {
	Username    APIString `json:"username"`
	DisplayName APIString `json:"display_name"`
	Password    APIString `json:"password"`
	Email       APIString `json:"email"`
}

func (*APIAuthUser) BuildFromService

func (a *APIAuthUser) BuildFromService(h interface{}) error

func (*APIAuthUser) ToService

func (a *APIAuthUser) ToService() (interface{}, error)

type APIBanner

type APIBanner struct {
	Text  APIString `json:"banner"`
	Theme APIString `json:"theme"`
}

APIBanner is a public structure representing the banner part of the admin settings

func (*APIBanner) BuildFromService

func (ab *APIBanner) BuildFromService(h interface{}) error

BuildFromService builds a model from the service layer

func (*APIBanner) ToService

func (ab *APIBanner) ToService() (interface{}, error)

ToService is not yet implemented

type APIBuild

type APIBuild struct {
	Id                  APIString      `json:"_id"`
	ProjectId           APIString      `json:"project_id"`
	CreateTime          APITime        `json:"create_time"`
	StartTime           APITime        `json:"start_time"`
	FinishTime          APITime        `json:"finish_time"`
	Version             APIString      `json:"version"`
	Branch              APIString      `json:"branch"`
	Revision            APIString      `json:"git_hash"`
	BuildVariant        APIString      `json:"build_variant"`
	Status              APIString      `json:"status"`
	Activated           bool           `json:"activated"`
	ActivatedBy         APIString      `json:"activated_by"`
	ActivatedTime       APITime        `json:"activated_time"`
	RevisionOrderNumber int            `json:"order"`
	TaskCache           []APITaskCache `json:"task_cache"`
	// Tasks is the build's task cache with just the names
	Tasks             []string             `json:"tasks"`
	TimeTaken         APIDuration          `json:"time_taken_ms"`
	DisplayName       APIString            `json:"display_name"`
	PredictedMakespan APIDuration          `json:"predicted_makespan_ms"`
	ActualMakespan    APIDuration          `json:"actual_makespan_ms"`
	Origin            APIString            `json:"origin"`
	StatusCounts      task.TaskStatusCount `json:"status_counts"`
}

APIBuild is the model to be returned by the API whenever builds are fetched.

func (*APIBuild) BuildFromService

func (apiBuild *APIBuild) BuildFromService(h interface{}) error

BuildFromService converts from service level structs to an APIBuild. APIBuild.ProjectId is set in the route builder's Execute method.

func (*APIBuild) ToService

func (apiBuild *APIBuild) ToService() (interface{}, error)

ToService returns a service layer build using the data from the APIBuild.

type APICLIUpdate

type APICLIUpdate struct {
	ClientConfig APIClientConfig `json:"client_config"`
	IgnoreUpdate bool            `json:"ignore_update"`
}

func (*APICLIUpdate) BuildFromService

func (a *APICLIUpdate) BuildFromService(h interface{}) error

func (*APICLIUpdate) ToService

func (a *APICLIUpdate) ToService() (interface{}, error)

type APICPUMetrics

type APICPUMetrics struct {
	CPU       APIString `json:"cpu"`
	User      float64   `json:"user"`
	System    float64   `json:"system"`
	Idle      float64   `json:"idle"`
	Nice      float64   `json:"nice"`
	Iowait    float64   `json:"iowait"`
	Irq       float64   `json:"irq"`
	Softirq   float64   `json:"softirq"`
	Steal     float64   `json:"steal"`
	Guest     float64   `json:"guest"`
	GuestNice float64   `json:"guestNice"`
	Stolen    float64   `json:"stolen"`
}

type APIClientBinary

type APIClientBinary struct {
	Arch APIString `json:"arch"`
	OS   APIString `json:"os"`
	URL  APIString `json:"url"`
}

func (*APIClientBinary) BuildFromService

func (a *APIClientBinary) BuildFromService(h interface{}) error

func (*APIClientBinary) ToService

func (a *APIClientBinary) ToService() (interface{}, error)

type APIClientConfig

type APIClientConfig struct {
	ClientBinaries []APIClientBinary `json:"client_binaries,omitempty"`
	LatestRevision APIString         `json:"latest_revision"`
}

func (*APIClientConfig) BuildFromService

func (a *APIClientConfig) BuildFromService(h interface{}) error

func (*APIClientConfig) ToService

func (a *APIClientConfig) ToService() (interface{}, error)

type APICloudProviders

type APICloudProviders struct {
	AWS       *APIAWSConfig       `json:"aws"`
	Docker    *APIDockerConfig    `json:"docker"`
	GCE       *APIGCEConfig       `json:"gce"`
	OpenStack *APIOpenStackConfig `json:"openstack"`
	VSphere   *APIVSphereConfig   `json:"vsphere"`
}

func (*APICloudProviders) BuildFromService

func (a *APICloudProviders) BuildFromService(h interface{}) error

func (*APICloudProviders) ToService

func (a *APICloudProviders) ToService() (interface{}, error)

type APICrowdConfig

type APICrowdConfig struct {
	Username APIString `json:"username"`
	Password APIString `json:"password"`
	Urlroot  APIString `json:"url_root"`
}

func (*APICrowdConfig) BuildFromService

func (a *APICrowdConfig) BuildFromService(h interface{}) error

func (*APICrowdConfig) ToService

func (a *APICrowdConfig) ToService() (interface{}, error)

type APIDistro

type APIDistro struct {
	Name             APIString `json:"name"`
	UserSpawnAllowed bool      `json:"user_spawn_allowed"`
}

APIDistro is the model to be returned by the API whenever distros are fetched. EVG-1717 will implement the remainder of the distro model.

func (*APIDistro) BuildFromService

func (apiDistro *APIDistro) BuildFromService(h interface{}) error

BuildFromService converts from service level structs to an APIDistro.

func (*APIDistro) ToService

func (apiDistro *APIDistro) ToService() (interface{}, error)

ToService returns a service layer distro using the data from APIDistro.

type APIDistroCost

type APIDistroCost struct {
	DistroId      APIString   `json:"distro_id"`
	SumTimeTaken  APIDuration `json:"sum_time_taken"`
	Provider      APIString   `json:"provider"`
	InstanceType  APIString   `json:"instance_type,omitempty"`
	EstimatedCost float64     `json:"estimated_cost"`
	NumTasks      int         `json:"num_tasks"`
}

APIDistroCost is the model to be returned by the API whenever cost data is fetched by distro id.

func (*APIDistroCost) BuildFromService

func (apiDistroCost *APIDistroCost) BuildFromService(h interface{}) error

BuildFromService converts from a service level task by loading the data into the appropriate fields of the APIDistroCost.

func (*APIDistroCost) ToService

func (apiDistroCost *APIDistroCost) ToService() (interface{}, error)

ToService returns a service layer distro cost using the data from APIDistroCost.

type APIDockerConfig

type APIDockerConfig struct {
	APIVersion APIString `json:"api_version"`
}

func (*APIDockerConfig) BuildFromService

func (a *APIDockerConfig) BuildFromService(h interface{}) error

func (*APIDockerConfig) ToService

func (a *APIDockerConfig) ToService() (interface{}, error)

type APIDuration

type APIDuration uint64

Represents duration in milliseconds

func NewAPIDuration

func NewAPIDuration(d time.Duration) APIDuration

func (APIDuration) ToDuration

func (i APIDuration) ToDuration() time.Duration

type APIGCEConfig

type APIGCEConfig struct {
	ClientEmail  APIString `json:"client_email"`
	PrivateKey   APIString `json:"private_key"`
	PrivateKeyID APIString `json:"private_key_id"`
	TokenURI     APIString `json:"token_uri"`
}

func (*APIGCEConfig) BuildFromService

func (a *APIGCEConfig) BuildFromService(h interface{}) error

func (*APIGCEConfig) ToService

func (a *APIGCEConfig) ToService() (interface{}, error)

type APIGithubAuthConfig

type APIGithubAuthConfig struct {
	ClientId     APIString   `json:"client_id"`
	ClientSecret APIString   `json:"client_secret"`
	Users        []APIString `json:"users"`
	Organization APIString   `json:"organization"`
}

func (*APIGithubAuthConfig) BuildFromService

func (a *APIGithubAuthConfig) BuildFromService(h interface{}) error

func (*APIGithubAuthConfig) ToService

func (a *APIGithubAuthConfig) ToService() (interface{}, error)

type APIGithubHook

type APIGithubHook struct {
	HookID int       `json:"hook_id"`
	Owner  APIString `json:"owner"`
	Repo   APIString `json:"repo"`
}

func (*APIGithubHook) BuildFromService

func (a *APIGithubHook) BuildFromService(h interface{}) error

func (*APIGithubHook) ToService

func (*APIGithubHook) ToService() (interface{}, error)

ToService returns a service layer build using the data from the APIBuild.

type APIHost

type APIHost struct {
	Id          APIString  `json:"host_id"`
	HostURL     APIString  `json:"host_url"`
	Distro      DistroInfo `json:"distro"`
	Provisioned bool       `json:"provisioned"`
	StartedBy   APIString  `json:"started_by"`
	Type        APIString  `json:"host_type"`
	User        APIString  `json:"user"`
	Status      APIString  `json:"status"`
	RunningTask taskInfo   `json:"running_task"`
	UserHost    bool       `json:"user_host"`
}

APIHost is the model to be returned by the API whenever hosts are fetched.

func (*APIHost) BuildFromService

func (apiHost *APIHost) BuildFromService(h interface{}) error

BuildFromService converts from service level structs to an APIHost. It can be called multiple times with different data types, a service layer host and a service layer task, which are each loaded into the data structure.

func (*APIHost) ToService

func (apiHost *APIHost) ToService() (interface{}, error)

ToService returns a service layer host using the data from the APIHost.

type APIHostInitConfig

type APIHostInitConfig struct {
	SSHTimeoutSeconds int64 `json:"ssh_timeout_secs"`
}

func (*APIHostInitConfig) BuildFromService

func (a *APIHostInitConfig) BuildFromService(h interface{}) error

func (*APIHostInitConfig) ToService

func (a *APIHostInitConfig) ToService() (interface{}, error)

type APIHostStatsByDistro

type APIHostStatsByDistro struct {
	Distros []apiHostStatsForDistro `json:"distros"`
}

APIHostStatsByDistro is a slice of host stats for a distro the 3 structs below are nested within it

func (*APIHostStatsByDistro) BuildFromService

func (s *APIHostStatsByDistro) BuildFromService(h interface{}) error

BuildFromService takes the slice of stats returned by GetHostStatsByDistro and embeds them so that the return value is a slice of distros

func (*APIHostStatsByDistro) ToService

func (s *APIHostStatsByDistro) ToService() (interface{}, error)

ToService is not implemented for APIHostStatsByDistro

type APIJiraConfig

type APIJiraConfig struct {
	Host           APIString `json:"host"`
	Username       APIString `json:"username"`
	Password       APIString `json:"password"`
	DefaultProject APIString `json:"default_project"`
}

func (*APIJiraConfig) BuildFromService

func (a *APIJiraConfig) BuildFromService(h interface{}) error

func (*APIJiraConfig) ToService

func (a *APIJiraConfig) ToService() (interface{}, error)

type APILogBuffering

type APILogBuffering struct {
	DurationSeconds int `json:"duration_seconds"`
	Count           int `json:"count"`
}

func (*APILogBuffering) BuildFromService

func (a *APILogBuffering) BuildFromService(h interface{}) error

func (*APILogBuffering) ToService

func (a *APILogBuffering) ToService() (interface{}, error)

type APILoggerConfig

type APILoggerConfig struct {
	Buffer         *APILogBuffering `json:"buffer"`
	DefaultLevel   APIString        `json:"default_level"`
	ThresholdLevel APIString        `json:"threshold_level"`
}

func (*APILoggerConfig) BuildFromService

func (a *APILoggerConfig) BuildFromService(h interface{}) error

func (*APILoggerConfig) ToService

func (a *APILoggerConfig) ToService() (interface{}, error)

type APINaiveAuthConfig

type APINaiveAuthConfig struct {
	Users []*APIAuthUser `json:"users"`
}

func (*APINaiveAuthConfig) BuildFromService

func (a *APINaiveAuthConfig) BuildFromService(h interface{}) error

func (*APINaiveAuthConfig) ToService

func (a *APINaiveAuthConfig) ToService() (interface{}, error)

type APINetStatMetrics

type APINetStatMetrics struct {
	Name        APIString `json:"name"`
	BytesSent   uint64    `json:"bytesSent"`
	BytesRecv   uint64    `json:"bytesRecv"`
	PacketsSent uint64    `json:"packetsSent"`
	PacketsRecv uint64    `json:"packetsRecv"`
	Errin       uint64    `json:"errin"`
	Errout      uint64    `json:"errout"`
	Dropin      uint64    `json:"dropin"`
	Dropout     uint64    `json:"dropout"`
	Fifoin      uint64    `json:"fifoin"`
	Fifoout     uint64    `json:"fifoout"`
}

type APINewRelicConfig

type APINewRelicConfig struct {
	ApplicationName APIString `json:"application_name"`
	LicenseKey      APIString `json:"license_key"`
}

func (*APINewRelicConfig) BuildFromService

func (a *APINewRelicConfig) BuildFromService(h interface{}) error

func (*APINewRelicConfig) ToService

func (a *APINewRelicConfig) ToService() (interface{}, error)

type APINotifyConfig

type APINotifyConfig struct {
	SMTP *APISMTPConfig `json:"smtp"`
}

func (*APINotifyConfig) BuildFromService

func (a *APINotifyConfig) BuildFromService(h interface{}) error

func (*APINotifyConfig) ToService

func (a *APINotifyConfig) ToService() (interface{}, error)

type APIOpenStackConfig

type APIOpenStackConfig struct {
	IdentityEndpoint APIString `json:"identity_endpoint"`

	Username   APIString `json:"username"`
	Password   APIString `json:"password"`
	DomainName APIString `json:"domain_name"`

	ProjectName APIString `json:"project_name"`
	ProjectID   APIString `json:"project_id"`

	Region APIString `json:"region"`
}

func (*APIOpenStackConfig) BuildFromService

func (a *APIOpenStackConfig) BuildFromService(h interface{}) error

func (*APIOpenStackConfig) ToService

func (a *APIOpenStackConfig) ToService() (interface{}, error)

type APIPatch

type APIPatch struct {
	Id              APIString     `json:"patch_id"`
	Description     APIString     `json:"description"`
	ProjectId       APIString     `json:"project_id"`
	Branch          APIString     `json:"branch"`
	Githash         APIString     `json:"git_hash"`
	PatchNumber     int           `json:"patch_number"`
	Author          APIString     `json:"author"`
	Version         APIString     `json:"version"`
	Status          APIString     `json:"status"`
	CreateTime      APITime       `json:"create_time"`
	StartTime       APITime       `json:"start_time"`
	FinishTime      APITime       `json:"finish_time"`
	Variants        []APIString   `json:"builds"`
	Tasks           []APIString   `json:"tasks"`
	VariantsTasks   []variantTask `json:"variants_tasks"`
	Activated       bool          `json:"activated"`
	Alias           APIString     `json:"alias,omitempty"`
	GithubPatchData githubPatch   `json:"github_patch_data,omitempty"`
}

APIPatch is the model to be returned by the API whenever patches are fetched.

func (*APIPatch) BuildFromService

func (apiPatch *APIPatch) BuildFromService(h interface{}) error

BuildFromService converts from service level structs to an APIPatch

func (*APIPatch) ToService

func (apiPatch *APIPatch) ToService() (interface{}, error)

ToService converts a service layer patch using the data from APIPatch

type APIProcessMetrics

type APIProcessMetrics []APIProcessStat

func (*APIProcessMetrics) BuildFromService

func (m *APIProcessMetrics) BuildFromService(in interface{}) error

func (*APIProcessMetrics) ToService

func (m *APIProcessMetrics) ToService() (interface{}, error)

type APIProcessStat

type APIProcessStat struct {
	Pid     int32         `json:"pid"`
	Parent  int32         `json:"parent"`
	Threads int           `json:"num_threads"`
	Command APIString     `json:"command"`
	CPU     APICPUMetrics `json:"cpu"`
	IOStat  struct {
		ReadCount  uint64 `json:"readCount"`
		WriteCount uint64 `json:"writeCount"`
		ReadBytes  uint64 `json:"readBytes"`
		WriteBytes uint64 `json:"writeBytes"`
	} `json:"iostat"`
	NetStat []APINetStatMetrics `json:"netstat"`
	Memory  struct {
		RSS  uint64 `json:"rss"`
		VMS  uint64 `json:"vms"`
		Swap uint64 `json:"swap"`
	} `json:"memory"`
	MemoryExtended interface{} `json:"memory_extended"`
}

type APIProject

type APIProject struct {
	BatchTime          int                      `json:"batch_time"`
	Branch             APIString                `json:"branch_name"`
	DisplayName        APIString                `json:"display_name"`
	Enabled            bool                     `json:"enabled"`
	Identifier         APIString                `json:"identifier"`
	Owner              APIString                `json:"owner_name"`
	Private            bool                     `json:"private"`
	RemotePath         APIString                `json:"remote_path"`
	Repo               APIString                `json:"repo_name"`
	Tracked            bool                     `json:"tracked"`
	AlertSettings      map[string][]alertConfig `json:"alert_settings"`
	DeactivatePrevious bool                     `json:"deactivate_previous"`
	Admins             []APIString              `json:"admins"`
	Vars               map[string]string        `json:"vars"`
	TracksPushEvents   bool                     `json:"tracks_push_events"`
	PRTestingEnabled   bool                     `json:"pr_testing_enabled"`
}

func (*APIProject) BuildFromService

func (apiProject *APIProject) BuildFromService(p interface{}) error

func (*APIProject) ToService

func (apiProject *APIProject) ToService() (interface{}, error)

type APIPubKey

type APIPubKey struct {
	Name APIString `json:"name"`
	Key  APIString `json:"key"`
}

func (*APIPubKey) BuildFromService

func (apiPubKey *APIPubKey) BuildFromService(h interface{}) error

BuildFromService converts from service level structs to an APIPubKey.

func (*APIPubKey) ToService

func (apiPubKey *APIPubKey) ToService() (interface{}, error)

ToService returns a service layer public key using the data from APIPubKey.

type APIRepoTrackerConfig

type APIRepoTrackerConfig struct {
	NumNewRepoRevisionsToFetch int `json:"revs_to_fetch"`
	MaxRepoRevisionsToSearch   int `json:"max_revs_to_search"`
	MaxConcurrentRequests      int `json:"max_con_requests"`
}

func (*APIRepoTrackerConfig) BuildFromService

func (a *APIRepoTrackerConfig) BuildFromService(h interface{}) error

func (*APIRepoTrackerConfig) ToService

func (a *APIRepoTrackerConfig) ToService() (interface{}, error)

type APISMTPConfig

type APISMTPConfig struct {
	Server     APIString   `json:"server"`
	Port       int         `json:"port"`
	UseSSL     bool        `json:"use_ssl"`
	Username   APIString   `json:"username"`
	Password   APIString   `json:"password"`
	From       APIString   `json:"from"`
	AdminEmail []APIString `json:"admin_email"`
}

func (*APISMTPConfig) BuildFromService

func (a *APISMTPConfig) BuildFromService(h interface{}) error

func (*APISMTPConfig) ToService

func (a *APISMTPConfig) ToService() (interface{}, error)

type APISchedulerConfig

type APISchedulerConfig struct {
	MergeToggle int       `json:"merge_toggle"`
	TaskFinder  APIString `json:"task_finder"`
}

func (*APISchedulerConfig) BuildFromService

func (a *APISchedulerConfig) BuildFromService(h interface{}) error

func (*APISchedulerConfig) ToService

func (a *APISchedulerConfig) ToService() (interface{}, error)

type APIServiceFlags

type APIServiceFlags struct {
	TaskDispatchDisabled         bool `json:"task_dispatch_disabled"`
	HostinitDisabled             bool `json:"hostinit_disabled"`
	MonitorDisabled              bool `json:"monitor_disabled"`
	AlertsDisabled               bool `json:"alerts_disabled"`
	TaskrunnerDisabled           bool `json:"taskrunner_disabled"`
	RepotrackerDisabled          bool `json:"repotracker_disabled"`
	SchedulerDisabled            bool `json:"scheduler_disabled"`
	GithubPRTestingDisabled      bool `json:"github_pr_testing_disabled"`
	RepotrackerPushEventDisabled bool `json:"repotracker_push_event_disabled"`
	CLIUpdatesDisabled           bool `json:"cli_updates_disabled"`
	GithubStatusAPIDisabled      bool `bson:"github_status_api_disabled" json:"github_status_api_disabled"`
	BackgroundStatsDisabled      bool `bson:"background_stats_disabled" json:"background_stats_disabled"`
}

APIServiceFlags is a public structure representing the admin service flags

func (*APIServiceFlags) BuildFromService

func (as *APIServiceFlags) BuildFromService(h interface{}) error

BuildFromService builds a model from the service layer

func (*APIServiceFlags) ToService

func (as *APIServiceFlags) ToService() (interface{}, error)

ToService returns a service model from an API model

type APISlackConfig

type APISlackConfig struct {
	Options *APISlackOptions `json:"options"`
	Token   APIString        `json:"token"`
	Level   APIString        `json:"level"`
}

func (*APISlackConfig) BuildFromService

func (a *APISlackConfig) BuildFromService(h interface{}) error

func (*APISlackConfig) ToService

func (a *APISlackConfig) ToService() (interface{}, error)

type APISlackOptions

type APISlackOptions struct {
	Channel       APIString       `json:"channel"`
	Hostname      APIString       `json:"hostname"`
	Name          APIString       `json:"name"`
	BasicMetadata bool            `json:"add_basic_metadata"`
	Fields        bool            `json:"use_fields"`
	AllFields     bool            `json:"all_fields"`
	FieldsSet     map[string]bool `json:"fields"`
}

func (*APISlackOptions) BuildFromService

func (a *APISlackOptions) BuildFromService(h interface{}) error

func (*APISlackOptions) ToService

func (a *APISlackOptions) ToService() (interface{}, error)

type APISpawnHostModify

type APISpawnHostModify struct {
	Action   APIString `json:"action"`
	HostID   APIString `json:"host_id"`
	RDPPwd   APIString `json:"rdp_pwd"`
	AddHours APIString `json:"add_hours"`
}

type APISplunkConnectionInfo

type APISplunkConnectionInfo struct {
	ServerURL APIString `json:"url"`
	Token     APIString `json:"token"`
	Channel   APIString `json:"channel"`
}

func (*APISplunkConnectionInfo) BuildFromService

func (a *APISplunkConnectionInfo) BuildFromService(h interface{}) error

func (*APISplunkConnectionInfo) ToService

func (a *APISplunkConnectionInfo) ToService() (interface{}, error)

type APIString

type APIString *string

func ToAPIString

func ToAPIString(in string) APIString

type APISystemMetrics

type APISystemMetrics struct {
	CPU        APICPUMetrics                `json:"cpu"`
	NumCPU     int                          `json:"num_cpus"`
	NetStat    APINetStatMetrics            `json:"netstat"`
	Partitions []APISystemMetricsPartitions `json:"partitions"`
	Usage      []APISystemMetricsDiskUsage  `json:"usage"`
	IOStat     []APISystemMetricsIOStat     `json:"iostat"`
	VMStat     struct {
		Total        uint64  `json:"total"`
		Available    uint64  `json:"available"`
		Used         uint64  `json:"used"`
		UsedPercent  float64 `json:"usedPercent"`
		Free         uint64  `json:"free"`
		Active       uint64  `json:"active"`
		Inactive     uint64  `json:"inactive"`
		Wired        uint64  `json:"wired"`
		Buffers      uint64  `json:"buffers"`
		Cached       uint64  `json:"cached"`
		Writeback    uint64  `json:"writeback"`
		Dirty        uint64  `json:"dirty"`
		WritebackTmp uint64  `json:"writebacktmp"`
		Shared       uint64  `json:"shared"`
		Slab         uint64  `json:"slab"`
		PageTables   uint64  `json:"pagetables"`
		SwapCached   uint64  `json:"swapcached"`
	} `json:"vmstat"`
}

func (*APISystemMetrics) BuildFromService

func (m *APISystemMetrics) BuildFromService(in interface{}) error

func (*APISystemMetrics) ToService

func (m *APISystemMetrics) ToService() (interface{}, error)

type APISystemMetricsDiskUsage

type APISystemMetricsDiskUsage struct {
	Path              APIString `json:"path"`
	Fstype            APIString `json:"fstype"`
	Total             uint64    `json:"total"`
	Free              uint64    `json:"free"`
	Used              uint64    `json:"used"`
	UsedPercent       float64   `json:"usedPercent"`
	InodesTotal       uint64    `json:"inodesTotal"`
	InodesUsed        uint64    `json:"inodesUsed"`
	InodesFree        uint64    `json:"inodesFree"`
	InodesUsedPercent float64   `json:"inodesUsedPercent"`
}

type APISystemMetricsIOStat

type APISystemMetricsIOStat struct {
	Name             APIString `json:"name"`
	ReadCount        uint64    `json:"readCount"`
	MergedReadCount  uint64    `json:"mergedReadCount"`
	WriteCount       uint64    `json:"writeCount"`
	MergedWriteCount uint64    `json:"mergedWriteCount"`
	ReadBytes        uint64    `json:"readBytes"`
	WriteBytes       uint64    `json:"writeBytes"`
	ReadTime         uint64    `json:"readTime"`
	WriteTime        uint64    `json:"writeTime"`
	IopsInProgress   uint64    `json:"iopsInProgress"`
	IoTime           uint64    `json:"ioTime"`
	WeightedIO       uint64    `json:"weightedIO"`
}

type APISystemMetricsPartitions

type APISystemMetricsPartitions struct {
	Device     APIString `json:"device"`
	Mountpoint APIString `json:"mountpoint"`
	Fstype     APIString `json:"fstype"`
	Opts       APIString `json:"opts"`
}

type APITask

type APITask struct {
	Id                 APIString        `json:"task_id"`
	ProjectId          APIString        `json:"project_id"`
	CreateTime         APITime          `json:"create_time"`
	DispatchTime       APITime          `json:"dispatch_time"`
	ScheduledTime      APITime          `json:"scheduled_time"`
	StartTime          APITime          `json:"start_time"`
	FinishTime         APITime          `json:"finish_time"`
	Version            APIString        `json:"version_id"`
	Revision           APIString        `json:"revision"`
	Priority           int64            `json:"priority"`
	Activated          bool             `json:"activated"`
	ActivatedBy        APIString        `json:"activated_by"`
	BuildId            APIString        `json:"build_id"`
	DistroId           APIString        `json:"distro_id"`
	BuildVariant       APIString        `json:"build_variant"`
	DependsOn          []string         `json:"depends_on"`
	DisplayName        APIString        `json:"display_name"`
	HostId             APIString        `json:"host_id"`
	Restarts           int              `json:"restarts"`
	Execution          int              `json:"execution"`
	Order              int              `json:"order"`
	Status             APIString        `json:"status"`
	Details            apiTaskEndDetail `json:"status_details"`
	Logs               logLinks         `json:"logs"`
	TimeTaken          APIDuration      `json:"time_taken_ms"`
	ExpectedDuration   APIDuration      `json:"expected_duration_ms"`
	EstimatedCost      float64          `json:"estimated_cost"`
	PreviousExecutions []APITask        `json:"previous_executions,omitempty"`
}

APITask is the model to be returned by the API whenever tasks are fetched.

func (*APITask) BuildFromService

func (at *APITask) BuildFromService(t interface{}) error

BuildFromService converts from a service level task by loading the data into the appropriate fields of the APITask.

func (*APITask) BuildPreviousExecutions

func (at *APITask) BuildPreviousExecutions(tasks []task.Task) error

func (*APITask) ToService

func (ad *APITask) ToService() (interface{}, error)

ToService returns a service layer task using the data from the APITask.

type APITaskCache

type APITaskCache struct {
	Id              string                  `json:"id"`
	DisplayName     string                  `json:"display_name"`
	Status          string                  `json:"status"`
	StatusDetails   apimodels.TaskEndDetail `json:"task_end_details"`
	StartTime       time.Time               `json:"start_time"`
	TimeTaken       time.Duration           `json:"time_taken"`
	Activated       bool                    `json:"activated"`
	FailedTestNames []string                `json:"failed_test_names,omitempty"`
}

type APITaskCost

type APITaskCost struct {
	Id            APIString   `json:"task_id"`
	DisplayName   APIString   `json:"display_name"`
	DistroId      APIString   `json:"distro"`
	BuildVariant  APIString   `json:"build_variant"`
	TimeTaken     APIDuration `json:"time_taken"`
	Githash       APIString   `json:"githash"`
	EstimatedCost float64     `json:"estimated_cost"`
}

APITaskCost is the model to be returned by the API whenever tasks for the cost route are fetched.

func (*APITaskCost) BuildFromService

func (atc *APITaskCost) BuildFromService(t interface{}) error

BuildFromService converts from a service level task by loading the data into the appropriate fields of the APITaskCost. (It leaves out fields unnecessary for the route.)

func (*APITaskCost) ToService

func (atc *APITaskCost) ToService() (interface{}, error)

ToService returns a service layer version cost using the data from APIVersionCost.

type APITaskStats

type APITaskStats struct {
	Total              int `json:"total"`
	Inactive           int `json:"inactive"`
	Unstarted          int `json:"unstarted"`
	Started            int `json:"started"`
	Succeeded          int `json:"succeeded"`
	Failed             int `json:"failed"`
	SystemFailed       int `json:"system-failed"`
	SystemUnresponsive int `json:"system-unresponsive"`
	SystemTimedOut     int `json:"system-timed-out"`
	TestTimedOut       int `json:"test-timed-out"`
}

APITaskStats is the model to be returned by the API whenever recent tasks are fetched.

func (*APITaskStats) BuildFromService

func (apiStatus *APITaskStats) BuildFromService(h interface{}) error

BuildFromService converts from service level structs to an APITaskStats.

func (*APITaskStats) ToService

func (apiStatus *APITaskStats) ToService() (interface{}, error)

ToService returns a service layer distro using the data from APITaskStats.

type APITest

type APITest struct {
	TaskId    APIString `json:"task_id"`
	Status    APIString `json:"status"`
	TestFile  APIString `json:"test_file"`
	Logs      TestLogs  `json:"logs"`
	ExitCode  int       `json:"exit_code"`
	StartTime APITime   `json:"start_time"`
	EndTime   APITime   `json:"end_time"`
}

APITest contains the data to be returned whenever a test is used in the API.

func (*APITest) BuildFromService

func (at *APITest) BuildFromService(st interface{}) error

func (*APITest) ToService

func (at *APITest) ToService() (interface{}, error)

type APITime

type APITime time.Time
var APIZeroTime APITime = APITime(util.ZeroTime.UTC())

func NewTime

func NewTime(t time.Time) APITime

NewTime creates a new APITime from an existing time.Time. It handles changing converting from the times time zone to UTC.

func (APITime) MarshalJSON

func (at APITime) MarshalJSON() ([]byte, error)

MarshalJSON implements the custom marshalling of this type so that it can be correctly written out in an API response.

func (APITime) String

func (at APITime) String() string

func (*APITime) UnmarshalJSON

func (at *APITime) UnmarshalJSON(b []byte) error

UnmarshalJSON implements the custom unmarshalling of this type so that it can be correctly parsed from an API request.

type APIUIConfig

type APIUIConfig struct {
	Url            APIString `json:"url"`
	HelpUrl        APIString `json:"help_url"`
	HttpListenAddr APIString `json:"http_listen_addr"`
	Secret         APIString `json:"secret"`
	DefaultProject APIString `json:"default_project"`
	CacheTemplates bool      `json:"cache_templates"`
	SecureCookies  bool      `json:"secure_cookies"`
	CsrfKey        APIString `json:"csrf_key"`
}

func (*APIUIConfig) BuildFromService

func (a *APIUIConfig) BuildFromService(h interface{}) error

func (*APIUIConfig) ToService

func (a *APIUIConfig) ToService() (interface{}, error)

type APIVSphereConfig

type APIVSphereConfig struct {
	Host     APIString `json:"host"`
	Username APIString `json:"username"`
	Password APIString `json:"password"`
}

func (*APIVSphereConfig) BuildFromService

func (a *APIVSphereConfig) BuildFromService(h interface{}) error

func (*APIVSphereConfig) ToService

func (a *APIVSphereConfig) ToService() (interface{}, error)

type APIVersion

type APIVersion struct {
	Id         APIString `json:"version_id"`
	CreateTime APITime   `json:"create_time"`
	StartTime  APITime   `json:"start_time"`
	FinishTime APITime   `json:"finish_time"`
	Revision   APIString `json:"revision"`
	Order      int       `json:"order"`

	Author        APIString     `json:"author"`
	AuthorEmail   APIString     `json:"author_email"`
	Message       APIString     `json:"message"`
	Status        APIString     `json:"status"`
	Repo          APIString     `json:"repo"`
	Branch        APIString     `json:"branch"`
	BuildVariants []buildDetail `json:"build_variants_status"`

	Errors   []APIString `json:"errors"`
	Warnings []APIString `json:"warnings"`
	Ignored  bool        `json:"ignored"`
}

APIVersion is the model to be returned by the API whenever versions are fetched.

func (*APIVersion) BuildFromService

func (apiVersion *APIVersion) BuildFromService(h interface{}) error

BuildFromService converts from service level structs to an APIVersion.

func (*APIVersion) ToService

func (apiVersion *APIVersion) ToService() (interface{}, error)

ToService returns a service layer build using the data from the APIVersion.

type APIVersionCost

type APIVersionCost struct {
	VersionId     APIString   `json:"version_id"`
	SumTimeTaken  APIDuration `json:"sum_time_taken"`
	EstimatedCost float64     `json:"estimated_cost"`
}

APIVersionCost is the model to be returned by the API whenever cost data is fetched by version id.

func (*APIVersionCost) BuildFromService

func (apiVersionCost *APIVersionCost) BuildFromService(h interface{}) error

BuildFromService converts from a service level task by loading the data into the appropriate fields of the APIVersionCost.

func (*APIVersionCost) ToService

func (apiVersionCost *APIVersionCost) ToService() (interface{}, error)

ToService returns a service layer version cost using the data from APIVersionCost.

type APIVersions

type APIVersions struct {
	// whether or not the version element actually consists of multiple inactive
	// versions rolled up into one
	RolledUp bool `json:"rolled_up"`

	Versions []APIVersion `json:"versions"`
}

type APIapiConfig

type APIapiConfig struct {
	HttpListenAddr      APIString `json:"http_listen_addr"`
	GithubWebhookSecret APIString `json:"github_webhook_secret"`
}

func (*APIapiConfig) BuildFromService

func (a *APIapiConfig) BuildFromService(h interface{}) error

func (*APIapiConfig) ToService

func (a *APIapiConfig) ToService() (interface{}, error)

type BuildList

type BuildList struct {
	BuildVariant string              `json:"build_variant"`
	Builds       map[string]APIBuild `json:"builds"`
}

type DistroInfo

type DistroInfo struct {
	Id       APIString `json:"distro_id"`
	Provider APIString `json:"provider"`
}

type HostPostRequest

type HostPostRequest struct {
	DistroID string `json:"distro"`
	KeyName  string `json:"keyname"`
}

HostPostRequest is a struct that holds the format of a POST request to /hosts

type MockModel

type MockModel struct {
	FieldId   string
	FieldInt1 int
	FieldInt2 int
	FieldMap  map[string]string

	FieldStruct *MockSubStruct
}

func (*MockModel) BuildFromService

func (m *MockModel) BuildFromService(in interface{}) error

func (*MockModel) ToService

func (m *MockModel) ToService() (interface{}, error)

type MockSubStruct

type MockSubStruct struct {
	SubInt int
}

type Model

type Model interface {
	BuildFromService(interface{}) error
	ToService() (interface{}, error)
}

Model defines how an API resource which will be both taken from requests and turned into service layer models and taken from service layer models and turned into api models to be returned.

func AdminDbToRestModel

func AdminDbToRestModel(in evergreen.ConfigSection) (Model, error)

type RestartTasksResponse

type RestartTasksResponse struct {
	TasksRestarted []string `json:"tasks_restarted"`
	TasksErrored   []string `json:"tasks_errored"`
}

RestartTasksResponse is the response model returned from the /admin/restart route

func (*RestartTasksResponse) BuildFromService

func (rtr *RestartTasksResponse) BuildFromService(h interface{}) error

BuildFromService builds a model from the service layer

func (*RestartTasksResponse) ToService

func (rtr *RestartTasksResponse) ToService() (interface{}, error)

ToService is not implemented for /admin/restart

type TestLogs

type TestLogs struct {
	URL     APIString `json:"url"`
	LineNum int       `json:"line_num"`
	URLRaw  APIString `json:"url_raw"`
	LogId   APIString `json:"log_id"`
}

TestLogs is a struct for storing the information about logs that will be written out as part of an APITest.

type VersionVariantData

type VersionVariantData struct {
	Rows          map[string]BuildList `json:"rows"`
	Versions      []APIVersions        `json:"versions"`
	BuildVariants []string             `json:"build_variants"`
}

func (*VersionVariantData) BuildFromService

func (v *VersionVariantData) BuildFromService(h interface{}) error

func (*VersionVariantData) ToService

func (v *VersionVariantData) ToService() (interface{}, error)

Jump to

Keyboard shortcuts

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