schemas

package
v1.0.6-1 Latest Latest
Warning

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

Go to latest
Published: Jan 13, 2020 License: Apache-2.0 Imports: 10 Imported by: 2

Documentation

Index

Constants

View Source
const (
	JSON                   = "json"
	UnsupportedSchemaError = `Schema type can only be 'json'`
	GenericError           = "Could not load schema for topic"
)

Variables

This section is empty.

Functions

func Delete

func Delete(schemaUUID string, str stores.Store) error

Delete wraps the store's method for removing a schema

func ExistsWithName

func ExistsWithName(projectUUID string, schemaName string, str stores.Store) (bool, error)

ExistsWithName checks if a schema with the given name exists under the given project

func ExtractSchema

func ExtractSchema(schemaRef string) (string, string, error)

ExtractSchema gets a full schema ref and extracts project and schema the format of the schema ref should follow the pattern projects/{project}/schemas/schema

func FormatSchemaRef

func FormatSchemaRef(projectName, schemaName string) string

FormatSchemaRef formats the full resource reference for a schema format is projects/{project}/schemas/{schema}

func ValidateMessages

func ValidateMessages(schema Schema, msgList messages.MsgList) error

ValidateMessages validates a list of messages against the provided schema

Types

type Schema

type Schema struct {
	ProjectUUID string                 `json:"-"`
	UUID        string                 `json:"uuid"`
	Name        string                 `json:"-"`
	FullName    string                 `json:"name"`
	Type        string                 `json:"type"`
	RawSchema   map[string]interface{} `json:"schema"`
}

Schema holds information regarding a schema that will be used to validate a topic's published messages

func Create

func Create(projectUUID, schemaUUID, name, schemaType string, rawSchema map[string]interface{}, str stores.Store) (Schema, error)

Create checks the validity of the schema to be created and then saves it to the store

func Update

func Update(existingSchema Schema, newSchemaName, newSchemaType string, newRawSchema map[string]interface{}, str stores.Store) (Schema, error)

Update updates the provided schema , validates its content and saves it to the store

type SchemaList

type SchemaList struct {
	Schemas []Schema `json:"schemas"`
}

SchemaList is a wrapper for a slice of schemas

func Find

func Find(projectUUID, schemaUUID, schemaName string, str stores.Store) (SchemaList, error)

Find retrieves a specific schema or all the schemas under a project

func (*SchemaList) Empty

func (sl *SchemaList) Empty() bool

Empty returns weather or not there are any schemas inside the schema list

Jump to

Keyboard shortcuts

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