models

package
v0.0.0-...-df394e8 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2022 License: Apache-2.0 Imports: 16 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeSha256HexString

func DecodeSha256HexString(shaString string) (sha []byte, err error)

DecodeSha256HexString decode sha string

func GetGarbageRemovalTime

func GetGarbageRemovalTime() (time.Time, error)

GetGarbageRemovalTime : Get Garbage Removal Time

func IsDeviceValid

func IsDeviceValid(DeviceID primitive.ObjectID) (
	result bool,
	err error,
)

IsDeviceValid : to check if a DeviceID is valid or not

func IsObjectGarbage

func IsObjectGarbage(ObjectID string) (
	result bool,
	err error,
)

IsObjectGarbage : to check if an object is garbage or not

func IsObjectValid

func IsObjectValid(ObjectID string) (
	result bool,
	err error,
)

IsObjectValid : to check if an object is valid or not

func MakeStorageID

func MakeStorageID(owner string, sha []byte) string

MakeStorageID crerate a new storage ID

func UnMarkObjectAsGarbage

func UnMarkObjectAsGarbage(ObjectID string) (
	err error,
)

UnMarkObjectAsGarbage : to unmark object as garbage

Types

type DeleteDeviceSummaryResponse

type DeleteDeviceSummaryResponse struct {
	Status         int      `json:"status"`
	StatusMessage  string   `json:"status_message"`
	DevicesRemoved int      `json:"devices_removed"`
	Warnings       []string `json:"warnings"`
}

DeleteDeviceSummaryResponse : response of deleteDeviceSummaryGarbage() function

type DeleteDevicesResponse

type DeleteDevicesResponse struct {
	Status         int      `json:"status"`
	StatusMessage  string   `json:"status_message"`
	DevicesRemoved int      `json:"devices_removed"`
	Warnings       []string `json:"warnings"`
}

DeleteDevicesResponse : response of deleteDeviceGarbage() function

type DeleteGarbagesResponse

type DeleteGarbagesResponse struct {
	Status        int                         `json:"status"`
	StatusMessage string                      `json:"status_message"`
	Devices       DeleteDevicesResponse       `json:"devices"`
	DeviceSummary DeleteDeviceSummaryResponse `json:"device_summary"`
	Trails        DeleteTrailsResponse        `json:"trails"`
	Steps         DeleteStepsResponse         `json:"steps"`
	Objects       DeleteObjectsResponse       `json:"objects"`
	Warnings      []string                    `json:"warnings"`
}

DeleteGarbagesResponse : Response of DeleteGarbages() function

type DeleteObjectsResponse

type DeleteObjectsResponse struct {
	Status         int      `json:"status"`
	StatusMessage  string   `json:"status_message"`
	ObjectsRemoved int      `json:"objects_removed"`
	Warnings       []string `json:"warnings"`
}

DeleteObjectsResponse : response of deleteAllObjectsGarbage() function

type DeleteStepsResponse

type DeleteStepsResponse struct {
	Status        int      `json:"status"`
	StatusMessage string   `json:"status_message"`
	StepsRemoved  int      `json:"steps_removed"`
	Warnings      []string `json:"warnings"`
}

DeleteStepsResponse : response of deleteStepsGarbage() function

type DeleteTrailsResponse

type DeleteTrailsResponse struct {
	Status        int      `json:"status"`
	StatusMessage string   `json:"status_message"`
	TrailsRemoved int      `json:"trails_removed"`
	Warnings      []string `json:"warnings"`
}

DeleteTrailsResponse : response of deleteTrailGarbage() function

type Device

type Device struct {
	ID               primitive.ObjectID     `json:"id" bson:"_id"`
	Prn              string                 `json:"prn"`
	Nick             string                 `json:"nick"`
	Owner            string                 `json:"owner"`
	OwnerNick        string                 `json:"owner-nick" bson:"-"`
	Secret           string                 `json:"secret,omitempty"`
	TimeCreated      time.Time              `json:"time-created" bson:"timecreated"`
	TimeModified     time.Time              `json:"time-modified" bson:"timemodified"`
	Challenge        string                 `json:"challenge,omitempty"`
	IsPublic         bool                   `json:"public"`
	UserMeta         map[string]interface{} `json:"user-meta" bson:"user-meta"`
	DeviceMeta       map[string]interface{} `json:"device-meta" bson:"device-meta"`
	Garbage          bool                   `json:"garbage" bson:"garbage"`
	GarbageRemovalAt time.Time              `bson:"garbage_removal_at" json:"garbage_removal_at"`
	GcProcessed      bool                   `json:"gc_processed" bson:"gc_processed"`
}

Device : Device model

func (*Device) DeleteGarbages

func (device *Device) DeleteGarbages() (
	response DeleteGarbagesResponse,
	err error,
)

DeleteGarbages : Delete Garbages of a device

func (*Device) MarkDeviceAsGarbage

func (device *Device) MarkDeviceAsGarbage() (
	result bool,
	err error,
)

MarkDeviceAsGarbage : Mark a device as garbage

func (*Device) MarkDeviceSummaryGarbages

func (device *Device) MarkDeviceSummaryGarbages() (
	response MarkDeviceSummaryResponse,
	err error,
)

MarkDeviceSummaryGarbages : Mark Deleted Devices As Garbage In DeviceSummary

func (*Device) MarkUnClaimedDevicesAsGarbage

func (device *Device) MarkUnClaimedDevicesAsGarbage() (
	response MarkUnclaimedDevicesResponse,
	err error,
)

MarkUnClaimedDevicesAsGarbage : Mark all unclaimed devices as garbage after a while(eg: after 5 days)

func (*Device) ProcessDeviceGarbages

func (device *Device) ProcessDeviceGarbages() (
	response ProcessDeviceGarbagesResponse,
	err error,
)

ProcessDeviceGarbages : Process Device Garbages

func (*Device) Validate

func (device *Device) Validate(r *http.Request) error

Validate : Validate PUT devices/{id} request

type MarkDeviceSummaryResponse

type MarkDeviceSummaryResponse struct {
	Status        int      `json:"status"`
	StatusMessage string   `json:"status_message"`
	DevicesMarked int      `json:"devices_marked"`
	Warnings      []string `json:"warnings"`
}

MarkDeviceSummaryResponse : response of MarkDeviceSummaryGarbages() function

type MarkTrailGarbagesResponse

type MarkTrailGarbagesResponse struct {
	Status        int      `json:"status"`
	StatusMessage string   `json:"status_message"`
	TrailsMarked  int      `json:"trails_marked"`
	Warnings      []string `json:"warnings"`
}

MarkTrailGarbagesResponse : response of MarkAllTrailGarbages() function

func MarkAllTrailGarbages

func MarkAllTrailGarbages() (
	response MarkTrailGarbagesResponse,
	err error,
)

MarkAllTrailGarbages : Mark all trail garbages

type MarkUnclaimedDevicesResponse

type MarkUnclaimedDevicesResponse struct {
	Status        int      `json:"status"`
	StatusMessage string   `json:"status_message"`
	DevicesMarked int      `json:"devices_marked"`
	Warnings      []string `json:"warnings"`
}

MarkUnclaimedDevicesResponse : response of MarkUnClaimedDevicesAsGarbage() function

type Object

type Object struct {
	ID         string `json:"id" bson:"id"`
	StorageID  string `json:"storage-id" bson:"_id"`
	Owner      string `json:"owner"`
	ObjectName string `json:"objectname"`
	Sha        string `json:"sha256sum"`
	Size       string `json:"size"`
	SizeInt    int64  `json:"sizeint"`
	MimeType   string `json:"mime-type"`

	Garbage          bool      `json:"garbage" bson:"garbage"`
	GarbageRemovalAt time.Time `bson:"garbage_removal_at" json:"garbage_removal_at"`
	// contains filtered or unexported fields
}

Object : Object model

type PopulateStepsUsedObjectsResponse

type PopulateStepsUsedObjectsResponse struct {
	Status                   int      `json:"status"`
	StatusMessage            string   `json:"status_message"`
	StepsPopulated           int      `json:"steps_populated"`
	StepsWithErrors          int      `json:"steps_with_errors"`
	ObjectsUnMarkedAsGarbage []string `json:"objects_unmarked_as_garbage"`
	Warnings                 []string `json:"warnings"`
}

PopulateStepsUsedObjectsResponse : Populate Steps Used Objects Response

type PopulateTrailsUsedObjectsResponse

type PopulateTrailsUsedObjectsResponse struct {
	Status                   int      `json:"status"`
	StatusMessage            string   `json:"status_message"`
	TrailsPopulated          int      `json:"trails_populated"`
	TrailsWithErrors         int      `json:"trails_with_errors"`
	ObjectsUnMarkedAsGarbage []string `json:"objects_unmarked_as_garbage"`
	Warnings                 []string `json:"warnings"`
}

PopulateTrailsUsedObjectsResponse : Populate Trails Used Objects Response

type PopulateUsedObjectsResponse

type PopulateUsedObjectsResponse struct {
	Status                   int      `json:"status"`
	StatusMessage            string   `json:"status_message"`
	ObjectList               []string `json:"object_list"`
	InvalidObjectCount       int      `json:"invalid_object_count"`
	InvalidState             bool     `json:"invalid_state"`
	ObjectsUnMarkedAsGarbage []string `json:"objects_unmarked_as_garbage"`
	Warnings                 []string `json:"warnings"`
}

PopulateUsedObjectsResponse : Populate UsedObject Response

type ProcessDeviceGarbagesResponse

type ProcessDeviceGarbagesResponse struct {
	Status                int      `json:"status"`
	StatusMessage         string   `json:"status_message"`
	DeviceProcessed       int      `json:"device_processed"`
	TrailsMarkedAsGarbage int      `json:"trails_marked_as_garbage"`
	TrailsWithErrors      int      `json:"trails_with_errors"`
	Warnings              []string `json:"warnings"`
}

ProcessDeviceGarbagesResponse : response of ProcessDeviceGarbages function

type ProcessStepGarbagesResponse

type ProcessStepGarbagesResponse struct {
	Status                 int      `json:"status"`
	StatusMessage          string   `json:"status_message"`
	StepsProcessed         int      `json:"steps_processed"`
	ObjectsMarkedAsGarbage int      `json:"objects_marked_as_garbage"`
	ObjectsWithErrors      int      `json:"objects_with_errors"`
	StepsWithErrors        int      `json:"steps_with_errors"`
	ObjectsIgnored         int      `json:"objects_ignored"`
	Warnings               []string `json:"warnings"`
}

ProcessStepGarbagesResponse : Response of ProcessStepGarbages() function

type ProcessTrailGarbagesResponse

type ProcessTrailGarbagesResponse struct {
	Status                 int      `json:"status"`
	StatusMessage          string   `json:"status_message"`
	TrailsProcessed        int      `json:"trails_processed"`
	StepsMarkedAsGarbage   int      `json:"steps_marked_as_garbage"`
	ObjectsMarkedAsGarbage int      `json:"objects_marked_as_garbage"`
	TrailsWithErrors       int      `json:"trails_with_errors"`
	ObjectsWithErrors      int      `json:"objects_with_errors"`
	ObjectsIgnored         int      `json:"objects_ignored"`
	StepsWithErrors        int      `json:"steps_with_errors"`
	Warnings               []string `json:"warnings"`
}

ProcessTrailGarbagesResponse : response of ProcessTrailGarbages() function

type Step

type Step struct {
	ID               string                 `json:"id" bson:"_id"` // XXX: make type
	Owner            string                 `json:"owner"`
	Device           string                 `json:"device"`
	Committer        string                 `json:"committer"`
	TrailID          primitive.ObjectID     `json:"trail-id" bson:"trail-id"` //parent id
	Rev              int                    `json:"rev"`
	CommitMsg        string                 `json:"commit-msg" bson:"commit-msg"`
	State            map[string]interface{} `json:"state"` // json blurb
	StateSha         string                 `json:"state-sha" bson:"statesha"`
	StepProgress     StepProgress           `json:"progress" bson:"progress"`
	StepTime         time.Time              `json:"step-time" bson:"step-time"`
	ProgressTime     time.Time              `json:"progress-time" bson:"progress-time"`
	Garbage          bool                   `json:"garbage" bson:"garbage"`
	GarbageRemovalAt time.Time              `bson:"garbage_removal_at" json:"garbage_removal_at"`
	GcProcessed      bool                   `json:"gc_processed" bson:"gc_processed"`
	UsedObjects      []string               `bson:"used_objects" json:"used_objects"`
}

step wanted can be added by the device owner or delegate. steps that were not reported can be deleted still. other steps cannot be deleted until the device gets deleted as well. Step: Step model

func (*Step) PopulateAllStepsUsedObjects

func (step *Step) PopulateAllStepsUsedObjects() (
	response PopulateStepsUsedObjectsResponse,
	err error,
)

PopulateAllStepsUsedObjects : Populate used_objects_field for all steps

func (*Step) ProcessStepGarbages

func (step *Step) ProcessStepGarbages() (
	response ProcessStepGarbagesResponse,
	err error,
)

ProcessStepGarbages : Process Step Garbages

type StepProgress

type StepProgress struct {
	Progress  int    `json:"progress"`                    // progress number. steps or 1-100
	StatusMsg string `json:"status-msg" bson:"statusmsg"` // message of progress status
	Status    string `json:"status"`                      // status code
	Log       string `json:"log"`                         // log if available
}

StepProgress : StepProgress model

type Trail

type Trail struct {
	ID     primitive.ObjectID `json:"id" bson:"_id"`
	Owner  string             `json:"owner"`
	Device string             `json:"device"`
	//  Admins   []string `json:"admins"`   // XXX: maybe this is best way to do delegating device access....
	LastInSync       time.Time              `json:"last-insync" bson:"last-insync"`
	LastTouched      time.Time              `json:"last-touched" bson:"last-touched"`
	FactoryState     map[string]interface{} `json:"factory-state" bson:"factory-state"`
	Garbage          bool                   `json:"garbage" bson:"garbage"`
	GarbageRemovalAt time.Time              `bson:"garbage_removal_at" json:"garbage_removal_at"`
	GcProcessed      bool                   `json:"gc_processed" bson:"gc_processed"`
	UsedObjects      []string               `bson:"used_objects" json:"used_objects"`
}

Trail : Trail model

func (*Trail) PopulateAllTrailsUsedObjects

func (trail *Trail) PopulateAllTrailsUsedObjects() (
	response PopulateTrailsUsedObjectsResponse,
	err error,
)

PopulateAllTrailsUsedObjects : Populate used_objects_field for all trails

func (*Trail) ProcessTrailGarbages

func (trail *Trail) ProcessTrailGarbages() (
	response ProcessTrailGarbagesResponse,
	err error,
)

ProcessTrailGarbages : Process Trail Garbages

Jump to

Keyboard shortcuts

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