db

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Migrate

func Migrate() error

Types

type AddPortForwardParams

type AddPortForwardParams struct {
	ID           string
	PublicIp     string
	PublicPort   int64
	InternalHost string
	InternalPort int64
}

type AddPublicIPParams

type AddPublicIPParams struct {
	ID     string
	Ip     string
	Subnet string
	Router string
}

type AddRouterParams

type AddRouterParams struct {
	ID       string
	Instance string
	TrunkNic string
}

type CreateHostParams

type CreateHostParams struct {
	ID       string
	Tenant   string
	Instance string
	Mac      string
	Network  string
	Ipv4     string
	Trunk    bool
	UserData []byte
}

type CreateNetworkParams

type CreateNetworkParams struct {
	ID     string
	Router string
	Tenant string
	Subnet string
}

type CreatePublicSubnetParams

type CreatePublicSubnetParams struct {
	ID     string
	Subnet string
}

type CreateSystemNetworkParams

type CreateSystemNetworkParams struct {
	ID     string
	Router string
	Tenant string
	Subnet string
}

type DBTX

type DBTX interface {
	ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
	PrepareContext(context.Context, string) (*sql.Stmt, error)
	QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
	QueryRowContext(context.Context, string, ...interface{}) *sql.Row
}

type Host

type Host struct {
	ID       string
	Tenant   string
	Instance string
	Mac      string
	Network  string
	Ipv4     string
	Trunk    bool
	UserData []byte
}

func (Host) GetProto

func (h Host) GetProto() *protos.Host

type Network

type Network struct {
	ID     string
	Router string
	Tenant string
	Vlan   int64
	Subnet string
}

func (Network) GetProto

func (n Network) GetProto() *protos.Network

type PortForward

type PortForward struct {
	ID           string
	PublicIp     string
	PublicPort   int64
	InternalHost string
	InternalPort int64
}

func (PortForward) GetOpenAPI

func (p PortForward) GetOpenAPI() openapi.PortForward

func (PortForward) GetProto

func (p PortForward) GetProto(ctx context.Context, queries *Queries) (*protos.PortForward, error)

type PublicIp

type PublicIp struct {
	ID     string
	Ip     string
	Subnet string
	Router string
}

func (PublicIp) GetOpenAPI

func (i PublicIp) GetOpenAPI() openapi.PublicIP

func (PublicIp) GetProto

func (i PublicIp) GetProto(ctx context.Context, queries *Queries) (*protos.PublicIP, error)

type PublicSubnet

type PublicSubnet struct {
	ID     string
	Subnet string
}

func (PublicSubnet) GetOpenAPI

func (s PublicSubnet) GetOpenAPI() openapi.PublicSubnet

type Queries

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

func Get

func Get() (*Queries, *sql.DB, error)

Get the database and closable DB object example usage:

  queries, dbConn, err := db.Get()
  if err != nil {
	   return err
  }
  defer dbConn.Close()

func New

func New(db DBTX) *Queries

func (*Queries) AddPortForward

func (q *Queries) AddPortForward(ctx context.Context, arg AddPortForwardParams) (PortForward, error)

Copyright Entanglement Garden Developers SPDX-License-Identifier: AGPL-3.0-only

func (*Queries) AddPublicIP

func (q *Queries) AddPublicIP(ctx context.Context, arg AddPublicIPParams) (PublicIp, error)

func (*Queries) AddRouter

func (q *Queries) AddRouter(ctx context.Context, arg AddRouterParams) (Router, error)

func (*Queries) CreateHost

func (q *Queries) CreateHost(ctx context.Context, arg CreateHostParams) (Host, error)

Copyright Entanglement Garden Developers SPDX-License-Identifier: AGPL-3.0-only

func (*Queries) CreateNetwork

func (q *Queries) CreateNetwork(ctx context.Context, arg CreateNetworkParams) (Network, error)

func (*Queries) CreatePublicSubnet

func (q *Queries) CreatePublicSubnet(ctx context.Context, arg CreatePublicSubnetParams) (PublicSubnet, error)

Copyright Entanglement Garden Developers SPDX-License-Identifier: AGPL-3.0-only

func (*Queries) CreateSystemNetwork

func (q *Queries) CreateSystemNetwork(ctx context.Context, arg CreateSystemNetworkParams) (Network, error)

Copyright Entanglement Garden Developers SPDX-License-Identifier: AGPL-3.0-only

func (*Queries) DeletePortForward

func (q *Queries) DeletePortForward(ctx context.Context, id string) error

func (*Queries) GetAllRouters

func (q *Queries) GetAllRouters(ctx context.Context) ([]Router, error)

func (*Queries) GetHost

func (q *Queries) GetHost(ctx context.Context, id string) (Host, error)

func (*Queries) GetHostByMac

func (q *Queries) GetHostByMac(ctx context.Context, mac string) (Host, error)

func (*Queries) GetHostsByNetwork

func (q *Queries) GetHostsByNetwork(ctx context.Context, network string) ([]Host, error)

func (*Queries) GetNetwork

func (q *Queries) GetNetwork(ctx context.Context, id string) (Network, error)

func (*Queries) GetNetworks

func (q *Queries) GetNetworks(ctx context.Context, tenant string) ([]Network, error)

func (*Queries) GetNetworksByRouter

func (q *Queries) GetNetworksByRouter(ctx context.Context, router string) ([]Network, error)

func (*Queries) GetPortForwards

func (q *Queries) GetPortForwards(ctx context.Context) ([]PortForward, error)

func (*Queries) GetPortForwardsByIP

func (q *Queries) GetPortForwardsByIP(ctx context.Context, publicIp string) ([]PortForward, error)

func (*Queries) GetPortForwardsByInternalHost

func (q *Queries) GetPortForwardsByInternalHost(ctx context.Context, internalHost string) ([]PortForward, error)

func (*Queries) GetPortForwardsByRouter

func (q *Queries) GetPortForwardsByRouter(ctx context.Context, router string) ([]PortForward, error)

func (*Queries) GetPublicIPByIP

func (q *Queries) GetPublicIPByIP(ctx context.Context, ip string) (PublicIp, error)

func (*Queries) GetPublicIPsByRouter

func (q *Queries) GetPublicIPsByRouter(ctx context.Context, router string) ([]PublicIp, error)

func (*Queries) GetPublicIPsBySubnet

func (q *Queries) GetPublicIPsBySubnet(ctx context.Context, subnet string) ([]PublicIp, error)

func (*Queries) GetPublicSubnet

func (q *Queries) GetPublicSubnet(ctx context.Context, id string) (PublicSubnet, error)

func (*Queries) GetPublicSubnets

func (q *Queries) GetPublicSubnets(ctx context.Context) ([]PublicSubnet, error)

func (*Queries) GetRouter

func (q *Queries) GetRouter(ctx context.Context, instance string) (Router, error)

Copyright Entanglement Garden Developers SPDX-License-Identifier: AGPL-3.0-only

func (*Queries) GetRouterForPortForward

func (q *Queries) GetRouterForPortForward(ctx context.Context, id string) (string, error)

func (*Queries) WithTx

func (q *Queries) WithTx(tx *sql.Tx) *Queries

type Router

type Router struct {
	ID       string
	Instance string
	TrunkNic string
}

func (Router) GetOpenAPI

func (r Router) GetOpenAPI() openapi.Router

Jump to

Keyboard shortcuts

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