model

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 2023 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Load

Load returns the types found in the specified descriptor set keyed by fully qualified name.

func SetSkipValidations

func SetSkipValidations(flag bool)

Types

type ContainerType

type ContainerType string

ContainerType indicates if the field is a container type with values none (empty string), "list", and "map"

const (
	ContainerTypeNone ContainerType = ""
	ContainerTypeList ContainerType = "list"
	ContainerTypeMap  ContainerType = "map"
)

type Enum

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

Enum is a protobuf enum definition.

func (*Enum) GetEnum

func (e *Enum) GetEnum() *Enum

GetEnum implements the Type interface.

func (*Enum) GetMessage

func (e *Enum) GetMessage() *Message

GetMessage implements the Type interface.

func (*Enum) IsTopLevel

func (b *Enum) IsTopLevel() bool

IsTopLevel returns true if the type definition is not nested under a message.

func (*Enum) Map

func (e *Enum) Map() map[string]string

Map returns a map of enum keys to keys.

func (*Enum) Name

func (b *Enum) Name() string

Name returns the base name of the type

func (*Enum) NameForFirstValue

func (e *Enum) NameForFirstValue() string

NameForFirstValue returns the name for the first value defined in the enum.

func (*Enum) NestedName

func (b *Enum) NestedName() string

NestedName returns the qualified name not including package.

func (*Enum) Package

func (b *Enum) Package() string

Package returns the package name in which the type is defined or the empty string if there is no package.

func (*Enum) QualifiedName

func (b *Enum) QualifiedName() string

QualifiedName returns the qualified name of the type including the package name.

func (*Enum) ReverseMap

func (e *Enum) ReverseMap() map[string]string

ReverseMap returns a map of names keyed by enum values converted to strings.

func (*Enum) ValueMap

func (e *Enum) ValueMap() map[string]string

ValueMap returns a map of enum values converted to string to keys.

type Field

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

Field is a field in a message.

func (*Field) AllowedNames

func (f *Field) AllowedNames() []string

AllowedNames returns the set of names allowed to refer to this field.

func (*Field) Constraints

func (f *Field) Constraints() map[string]interface{}

Constraints returns field rules as a JSON string.

func (*Field) ContainerType

func (f *Field) ContainerType() ContainerType

ContainerType returns the container type for the field.

func (*Field) FieldType

func (f *Field) FieldType() FieldType

FieldType returns the field type of the field.

func (*Field) IsList

func (f *Field) IsList() bool

IsList returns true if the field is a list.

func (*Field) IsMap

func (f *Field) IsMap() bool

IsMap returns true if the field is a map.

func (*Field) IsRequired

func (f *Field) IsRequired() bool

IsRequired returns true if the field is required to be present.

func (*Field) Name

func (f *Field) Name() string

Name returns the canonical name for the field.

func (*Field) OneOfGroup

func (f *Field) OneOfGroup() string

OneOfGroup returns the name of the one-of if the field participates in one.

func (*Field) SetterName

func (f *Field) SetterName() string

SetterName returns the name of the setter to be used for this type in generated code.

func (*Field) TypeName

func (f *Field) TypeName() string

TypeName returns the fully qualified type name for messages or a primitive type name. All numeric types are represented as a "number" string.

func (*Field) ValidationRules

func (f *Field) ValidationRules() *validate.FieldRules

ValidationRules returns any field rules defined for this type using the protoc-gen-validate package.

type FieldMeta

type FieldMeta struct {
	Type          string                 `json:"type"`                    // the type name of the field as returned by
	AllowedNames  []string               `json:"allowedNames"`            // the allowed names for the field
	ContainerType ContainerType          `json:"containerType,omitempty"` // the container type
	Required      bool                   `json:"required,omitempty"`      // whether it is required
	Constraints   map[string]interface{} `json:"constraints,omitempty"`   // type constraints associated with the field
}

FieldMeta returns the attributes for a field needed in generated code.

type FieldType

type FieldType string

FieldType indicates the type of field, "primitive", "enum" or "message".

const (
	FieldTypePrimitive FieldType = "primitive"
	FieldTypeEnum      FieldType = "enum"
	FieldTypeMessage   FieldType = "message"
)

type Message

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

Message represents a protobuf message.

func (*Message) FieldMeta

func (m *Message) FieldMeta() map[string]FieldMeta

FieldMeta returns a map of field metadata keyed by field name.

func (Message) Fields

func (m Message) Fields() []*Field

Fields returns the fields for this message.

func (*Message) GetEnum

func (m *Message) GetEnum() *Enum

GetEnum implements the Type interface.

func (*Message) GetMessage

func (m *Message) GetMessage() *Message

GetMessage implements the Type interface.

func (*Message) IsTopLevel

func (b *Message) IsTopLevel() bool

IsTopLevel returns true if the type definition is not nested under a message.

func (*Message) Name

func (b *Message) Name() string

Name returns the base name of the type

func (*Message) NestedEnums

func (m *Message) NestedEnums() []*Enum

NestedEnums returns the enums nested under this type.

func (*Message) NestedMessages

func (m *Message) NestedMessages() []*Message

NestedMessages returns the messages nested under this type.

func (*Message) NestedName

func (b *Message) NestedName() string

NestedName returns the qualified name not including package.

func (*Message) OneOfs

func (m *Message) OneOfs() []*OneOf

OneOfs returns the one-of defined for this message.

func (*Message) Package

func (b *Message) Package() string

Package returns the package name in which the type is defined or the empty string if there is no package.

func (*Message) QualifiedName

func (b *Message) QualifiedName() string

QualifiedName returns the qualified name of the type including the package name.

type OneOf

type OneOf struct {
	Fields   []string `json:"fields"`   // the field names that constitute the one-of
	Required bool     `json:"required"` // whether it is required in the enclosing message
	Group    string   `json:"group"`    // the name of the one-of field.
}

OneOf represents a one-of field.

type Type

type Type interface {
	Name() string          // Leaf name for the type
	Package() string       // Package in which type is declared
	IsTopLevel() bool      // returns true if this is a type not nested in a message
	NestedName() string    // the qualified name of the type not including package name
	QualifiedName() string // the qualified name of the type including package name
	GetMessage() *Message  // the underlying message if the type represents a message, or nil
	GetEnum() *Enum        // the underlying Enum if the type represents an enum, or nil
}

Type is an abstraction over a protobuf message or enum. It exposes the common attributes for each. The GetMessage and GetEnum methods respectively return a non-nil Message or Enum object based on what the underlying type is.

Jump to

Keyboard shortcuts

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