directory

package
v0.6.1 Latest Latest
Warning

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

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadFarmMiddleware added in v0.4.8

func LoadFarmMiddleware(next http.Handler) http.Handler

LoadFarmMiddleware verifies if the farmer who wants to update information about it's farm is indeed that farmer

func Setup

func Setup(parent *mux.Router, db *mongo.Database) error

Setup injects and initializes directory package

Types

type FarmAPI

type FarmAPI struct {
	// contains filtered or unexported fields
}

FarmAPI holds farm releated handlers

func (*FarmAPI) Add

func (s *FarmAPI) Add(ctx context.Context, db *mongo.Database, farm directory.Farm) (schema.ID, error)

Add add farm to store

func (FarmAPI) Delete

func (s FarmAPI) Delete(ctx context.Context, db *mongo.Database, id int64) error

Delete deletes a farm by ID

func (*FarmAPI) DeleteFarmThreebotCustomPrice added in v0.5.0

func (s *FarmAPI) DeleteFarmThreebotCustomPrice(ctx context.Context, db *mongo.Database, farmID, threebotID int64) error

DeleteFarmThreebotCustomPrice Delete FarmThreebotCustomPrice deletes a deal between farm and a threebot

func (*FarmAPI) FarmThreebotPriceCreateOrUpdate added in v0.5.0

func (s *FarmAPI) FarmThreebotPriceCreateOrUpdate(ctx context.Context, db *mongo.Database, farmThreebotPrice directory.FarmThreebotPrice) error

FarmThreebotPriceCreateOrUpdate creates or updates a new farm deal with a threebot

func (*FarmAPI) GetByID

func (s *FarmAPI) GetByID(ctx context.Context, db *mongo.Database, id int64) (directory.Farm, error)

GetByID gets a farm by ID

func (*FarmAPI) GetByName

func (s *FarmAPI) GetByName(ctx context.Context, db *mongo.Database, name string) (directory.Farm, error)

GetByName gets a farm by name

func (*FarmAPI) GetFarmCustomPriceForThreebot added in v0.5.0

func (s *FarmAPI) GetFarmCustomPriceForThreebot(ctx context.Context, db *mongo.Database, farmID, threebotID int64) (directory.FarmThreebotPrice, error)

GetFarmCustomPriceForThreebot gets a farm deal with a specific threebot

func (*FarmAPI) GetFarmCustomPrices added in v0.5.0

func (s *FarmAPI) GetFarmCustomPrices(ctx context.Context, db *mongo.Database, farmID int64) ([]directory.FarmThreebotPrice, int64, error)

GetFarmCustomPrices gets the farm deals

func (*FarmAPI) List

func (s *FarmAPI) List(ctx context.Context, db *mongo.Database, filter directory.FarmFilter, opts ...*options.FindOptions) ([]directory.Farm, int64, error)

List farms TODO: add paging arguments

func (*FarmAPI) PushIP added in v0.4.8

func (s *FarmAPI) PushIP(ctx context.Context, db *mongo.Database, id schema.ID, ip schema.IPCidr, gw net.IP) error

PushIP push ip

func (*FarmAPI) RemoveIP added in v0.4.8

func (s *FarmAPI) RemoveIP(ctx context.Context, db *mongo.Database, id schema.ID, ip schema.IPCidr) error

RemoveIP removes ip

func (*FarmAPI) Update

func (s *FarmAPI) Update(ctx context.Context, db *mongo.Database, id schema.ID, farm directory.Farm) error

Update farm information

type GatewayAPI

type GatewayAPI struct{}

GatewayAPI holds api for gateways

func (*GatewayAPI) Add

Add a node to the store

func (*GatewayAPI) Count

func (s *GatewayAPI) Count(ctx context.Context, db *mongo.Database, filter directory.GatewayFilter) (int64, error)

Count counts the number of document in the collection

func (*GatewayAPI) Exists

func (s *GatewayAPI) Exists(ctx context.Context, db *mongo.Database, gwID string) (bool, error)

Exists tests if node exists

func (*GatewayAPI) Get

func (s *GatewayAPI) Get(ctx context.Context, db *mongo.Database, gwID string) (directory.Gateway, error)

Get a single gateway

func (*GatewayAPI) List

func (s *GatewayAPI) List(ctx context.Context, db *mongo.Database, q gatewayQuery, opts ...*options.FindOptions) ([]directory.Gateway, int64, error)

List all gateways

func (*GatewayAPI) Requires

func (s *GatewayAPI) Requires(key string, handler mw.Action) mw.Action

Requires is a wrapper that makes sure gateway with that key exists before running the handler

type NodeAPI

type NodeAPI struct{}

NodeAPI holds api for nodes

func (*NodeAPI) Add

func (s *NodeAPI) Add(ctx context.Context, db *mongo.Database, node directory.Node) (schema.ID, error)

Add a node to the store

func (*NodeAPI) Count

func (s *NodeAPI) Count(ctx context.Context, db *mongo.Database, filter directory.NodeFilter) (int64, error)

Count counts the number of document in the collection

func (*NodeAPI) Delete

func (s *NodeAPI) Delete(ctx context.Context, db *mongo.Database, nodeID string) error

Delete a single node

func (*NodeAPI) Exists

func (s *NodeAPI) Exists(ctx context.Context, db *mongo.Database, nodeID string) (bool, error)

Exists tests if node exists

func (*NodeAPI) Get

func (s *NodeAPI) Get(ctx context.Context, db *mongo.Database, nodeID string, includeProofs bool) (directory.Node, error)

Get a single node

func (*NodeAPI) List

func (s *NodeAPI) List(ctx context.Context, db *mongo.Database, q nodeQuery, opts ...*options.FindOptions) ([]directory.Node, int64, error)

List farms TODO: add paging arguments

func (*NodeAPI) Requires

func (s *NodeAPI) Requires(key string, handler mw.Action) mw.Action

Requires is a wrapper that makes sure node with that case exists before running the handler

func (*NodeAPI) SetInterfaces

func (s *NodeAPI) SetInterfaces(ctx context.Context, db *mongo.Database, nodeID string, ifaces []generated.Iface) error

SetInterfaces updates node interfaces

func (*NodeAPI) SetPublicConfig

func (s *NodeAPI) SetPublicConfig(ctx context.Context, db *mongo.Database, nodeID string, cfg generated.PublicIface) error

SetPublicConfig sets node public config

func (*NodeAPI) SetWGPorts

func (s *NodeAPI) SetWGPorts(ctx context.Context, db *mongo.Database, nodeID string, ports []uint) error

SetWGPorts sets node gateway ports

func (*NodeAPI) StoreProof

func (s *NodeAPI) StoreProof(ctx context.Context, db *mongo.Database, nodeID string, dmi dmi.DMI, disks capacity.Disks, hypervisor []string) error

StoreProof stores node hardware proof

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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