model

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2021 License: Apache-2.0 Imports: 4 Imported by: 35

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Condition

type Condition struct {
	// Pointer to the field of the model where the operation applies
	Field interface{}
	// Condition function
	Function ovsdb.ConditionFunction
	// Value to use in the condition
	Value interface{}
}

Condition is a model-based representation of an OVSDB Condition

type DBModel

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

DBModel is a Database model

func NewDBModel

func NewDBModel(name string, models map[string]Model) (*DBModel, error)

NewDBModel constructs a DBModel based on a database name and dictionary of models indexed by table name

func (DBModel) FindTable

func (db DBModel) FindTable(mType reflect.Type) string

FindTable returns the string associated with a reflect.Type or ""

func (DBModel) Name

func (db DBModel) Name() string

Name returns the database name

func (DBModel) NewModel

func (db DBModel) NewModel(table string) (Model, error)

NewModel returns a new instance of a model from a specific string

func (DBModel) Types

func (db DBModel) Types() map[string]reflect.Type

Types returns the DBModel Types the DBModel types is a map of reflect.Types indexed by string The reflect.Type is a pointer to a struct that contains 'ovs' tags as described above. Such pointer to struct also implements the Model interface

func (DBModel) Validate

func (db DBModel) Validate(schema *ovsdb.DatabaseSchema) []error

Validate validates the DatabaseModel against the input schema Returns all the errors detected

type Model

type Model interface{}

A Model is the base interface used to build Database Models. It is used to express how data from a specific Database Table shall be translated into structs A Model is a struct with at least one (most likely more) field tagged with the 'ovs' tag The value of 'ovs' field must be a valid column name in the OVS Database A field associated with the "_uuid" column mandatory. The rest of the columns are optional The struct may also have non-tagged fields (which will be ignored by the API calls) The Model interface must be implemented by the pointer to such type Example:

type MyLogicalRouter struct {
	UUID          string            `ovsdb:"_uuid"`
	Name          string            `ovsdb:"name"`
	ExternalIDs   map[string]string `ovsdb:"external_ids"`
	LoadBalancers []string          `ovsdb:"load_balancer"`
}

type Mutation

type Mutation struct {
	// Pointer to the field of the model that shall be mutated
	Field interface{}
	// String representing the mutator (as per RFC7047)
	Mutator ovsdb.Mutator
	// Value to use in the mutation
	Value interface{}
}

Mutation is a model-based representation of an OVSDB Mutation

Jump to

Keyboard shortcuts

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