transformer

package
v0.0.0-...-9d13292 Latest Latest
Warning

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

Go to latest
Published: May 28, 2024 License: Apache-2.0 Imports: 15 Imported by: 11

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LoadJSONStringToProto

func LoadJSONStringToProto(modelString string) (*pb.AuthorizationModel, error)

LoadJSONStringToProto - Converts models authored in OpenFGA JSON syntax to the protobuf representation.

func MustTransformDSLToJSON

func MustTransformDSLToJSON(data string) string

MustTransformDSLToJSON - Calls TransformDSLToJSON - panics if the error fails.

func MustTransformDSLToProto

func MustTransformDSLToProto(data string) *pb.AuthorizationModel

MustTransformDSLToProto - Calls TransformDSLToProto - panics if the error fails.

func ParseExpression

func ParseExpression(rewrites []*pb.Userset, operator RelationDefinitionOperator) *pb.Userset

func TransformDSLToJSON

func TransformDSLToJSON(data string) (string, error)

TransformDSLToJSON - Converts models authored in FGA DSL syntax to the json syntax accepted by the OpenFGA API.

func TransformDSLToProto

func TransformDSLToProto(data string) (*pb.AuthorizationModel, error)

TransformDSLToProto - Converts models authored in FGA DSL syntax to the OpenFGA Authorization Model Protobuf format.

func TransformJSONProtoToDSL

func TransformJSONProtoToDSL(model *pb.AuthorizationModel, opts ...TransformOption) (string, error)

TransformJSONProtoToDSL - Converts models from the protobuf representation of the JSON syntax to the OpenFGA DSL.

func TransformJSONStringToDSL

func TransformJSONStringToDSL(modelString string, opts ...TransformOption) (*string, error)

TransformJSONStringToDSL - Converts models authored in OpenFGA JSON syntax to the DSL syntax.

func TransformModularDSLToProto

func TransformModularDSLToProto(data string) (*pb.AuthorizationModel, map[string]*pb.TypeDefinition, error)

TransformModularDSLToProto - Converts a part of a modular model in DSL syntax to the json syntax accepted by OpenFGA API and also returns the type definitions that are extended in the DSL if any are.

func TransformModuleFilesToModel

func TransformModuleFilesToModel(
	modules []ModuleFile,
	schemaVersion string,
) (*pb.AuthorizationModel, error)

TransformModuleFilesToModel transforms the provided modules into a singular authorization model.

Types

type DirectAssignmentValidator

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

type ModFile

type ModFile struct {
	Schema   ModFileStringProperty `json:"schema"`
	Contents ModFileArrayProperty  `json:"contents"`
}

func TransformModFile

func TransformModFile(data string) (*ModFile, error)

TransformModFile transforms a mod.fga and validates the fields are correct.

type ModFileArrayProperty

type ModFileArrayProperty struct {
	Value  []ModFileStringProperty `json:"value"`
	Line   int                     `json:"line"`
	Column int                     `json:"column"`
}

type ModFileStringProperty

type ModFileStringProperty struct {
	Value  string `json:"value"`
	Line   int    `json:"line"`
	Column int    `json:"column"`
}

type ModFileValidationError

type ModFileValidationError struct {
	Line, Column int
	Msg          string
}

ModFileValidationError is an error occurred during validation of the mod.fga file. Line and column number provided are one based.

func (*ModFileValidationError) Error

func (e *ModFileValidationError) Error() string

type ModFileValidationErrorMetadata

type ModFileValidationErrorMetadata struct{}

type ModFileValidationMultipleError

type ModFileValidationMultipleError multierror.Error

func (*ModFileValidationMultipleError) Error

type ModuleFile

type ModuleFile struct {
	Name     string
	Contents string
}

type ModuleTransformationSingleError

type ModuleTransformationSingleError struct {
	Msg  string
	File string
	Line struct {
		Start int
		End   int
	}
	Column struct {
		Start int
		End   int
	}
}

ModuleTransformationSingleError is an error occurred during transformation of a module. Line and column number provided are one based.

func (*ModuleTransformationSingleError) Error

type ModuleTransformationSingleMetadata

type ModuleTransformationSingleMetadata struct{}

type ModuleValidationMultipleError

type ModuleValidationMultipleError multierror.Error

func (*ModuleValidationMultipleError) Error

type OpenFgaDslErrorListener

type OpenFgaDslErrorListener struct {
	*antlr.DefaultErrorListener // Embed default which ensures we fit the interface
	Errors                      *multierror.Error
}

func (*OpenFgaDslErrorListener) SyntaxError

func (c *OpenFgaDslErrorListener) SyntaxError(
	_ antlr.Recognizer,
	offendingSymbol interface{},
	line,
	column int,
	msg string,
	_ antlr.RecognitionException,
)

type OpenFgaDslListener

type OpenFgaDslListener struct {
	*parser.BaseOpenFGAParserListener
	// contains filtered or unexported fields
}

func (*OpenFgaDslListener) EnterCondition

func (l *OpenFgaDslListener) EnterCondition(ctx *parser.ConditionContext)

func (*OpenFgaDslListener) EnterConditions

func (l *OpenFgaDslListener) EnterConditions(_ *parser.ConditionsContext)

func (*OpenFgaDslListener) EnterMain

func (l *OpenFgaDslListener) EnterMain(_ *parser.MainContext)

func (*OpenFgaDslListener) EnterRelationDeclaration

func (l *OpenFgaDslListener) EnterRelationDeclaration(_ *parser.RelationDeclarationContext)

func (*OpenFgaDslListener) EnterRelationDefDirectAssignment

func (l *OpenFgaDslListener) EnterRelationDefDirectAssignment(_ *parser.RelationDefDirectAssignmentContext)

func (*OpenFgaDslListener) EnterRelationDefPartials

func (l *OpenFgaDslListener) EnterRelationDefPartials(ctx *parser.RelationDefPartialsContext)

func (*OpenFgaDslListener) EnterRelationRecurseNoDirect

func (l *OpenFgaDslListener) EnterRelationRecurseNoDirect(_ *parser.RelationRecurseNoDirectContext)

func (*OpenFgaDslListener) EnterTypeDef

func (l *OpenFgaDslListener) EnterTypeDef(ctx *parser.TypeDefContext)

func (*OpenFgaDslListener) ExitCondition

func (l *OpenFgaDslListener) ExitCondition(_ *parser.ConditionContext)

func (*OpenFgaDslListener) ExitConditionExpression

func (l *OpenFgaDslListener) ExitConditionExpression(ctx *parser.ConditionExpressionContext)

func (*OpenFgaDslListener) ExitConditionParameter

func (l *OpenFgaDslListener) ExitConditionParameter(ctx *parser.ConditionParameterContext)

func (*OpenFgaDslListener) ExitModelHeader

func (l *OpenFgaDslListener) ExitModelHeader(ctx *parser.ModelHeaderContext)

func (*OpenFgaDslListener) ExitModuleHeader

func (l *OpenFgaDslListener) ExitModuleHeader(ctx *parser.ModuleHeaderContext)

func (*OpenFgaDslListener) ExitRelationDeclaration

func (l *OpenFgaDslListener) ExitRelationDeclaration(ctx *parser.RelationDeclarationContext)

func (*OpenFgaDslListener) ExitRelationDefDirectAssignment

func (l *OpenFgaDslListener) ExitRelationDefDirectAssignment(_ *parser.RelationDefDirectAssignmentContext)

func (*OpenFgaDslListener) ExitRelationDefRewrite

func (l *OpenFgaDslListener) ExitRelationDefRewrite(ctx *parser.RelationDefRewriteContext)

func (*OpenFgaDslListener) ExitRelationDefTypeRestriction

func (l *OpenFgaDslListener) ExitRelationDefTypeRestriction(ctx *parser.RelationDefTypeRestrictionContext)

func (*OpenFgaDslListener) ExitRelationRecurse

func (l *OpenFgaDslListener) ExitRelationRecurse(_ *parser.RelationRecurseContext)

func (*OpenFgaDslListener) ExitRelationRecurseNoDirect

func (l *OpenFgaDslListener) ExitRelationRecurseNoDirect(_ *parser.RelationRecurseNoDirectContext)

func (*OpenFgaDslListener) ExitTypeDef

func (l *OpenFgaDslListener) ExitTypeDef(ctx *parser.TypeDefContext)

type OpenFgaDslSyntaxError

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

func (*OpenFgaDslSyntaxError) Error

func (err *OpenFgaDslSyntaxError) Error() string

type OpenFgaDslSyntaxErrorMetadata

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

type OpenFgaDslSyntaxMultipleError

type OpenFgaDslSyntaxMultipleError multierror.Error

func (*OpenFgaDslSyntaxMultipleError) Error

type RelationDefinitionOperator

type RelationDefinitionOperator string
const (
	RELATION_DEFINITION_OPERATOR_NONE    RelationDefinitionOperator = ""        //nolint:stylecheck,revive
	RELATION_DEFINITION_OPERATOR_OR      RelationDefinitionOperator = "or"      //nolint:stylecheck,revive
	RELATION_DEFINITION_OPERATOR_AND     RelationDefinitionOperator = "and"     //nolint:stylecheck,revive
	RELATION_DEFINITION_OPERATOR_BUT_NOT RelationDefinitionOperator = "but not" //nolint:stylecheck,revive
)

type TransformOption

type TransformOption func(t *transformOptions)

func WithIncludeSourceInformation

func WithIncludeSourceInformation(includeSourceInformation bool) TransformOption

WithIncludeSourceInformation - Configures whether to append file and module information to types, relations, and conditions.

type YAMLModFile

type YAMLModFile struct {
	Schema   yaml.Node `yaml:"schema"`
	Contents yaml.Node `yaml:"contents"`
}

Jump to

Keyboard shortcuts

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