Documentation ¶
Index ¶
- func LoadJSONStringToProto(modelString string) (*pb.AuthorizationModel, error)
- func MustTransformDSLToJSON(data string) string
- func MustTransformDSLToProto(data string) *pb.AuthorizationModel
- func ParseDSL(data string) (*OpenFgaDslListener, *OpenFgaDslErrorListener)
- func ParseExpression(rewrites []*pb.Userset, operator RelationDefinitionOperator) *pb.Userset
- func TransformDSLToJSON(data string) (string, error)
- func TransformDSLToProto(data string) (*pb.AuthorizationModel, error)
- func TransformJSONProtoToDSL(model *pb.AuthorizationModel, opts ...TransformOption) (string, error)
- func TransformJSONStringToDSL(modelString string, opts ...TransformOption) (*string, error)
- func TransformModularDSLToProto(data string) (*pb.AuthorizationModel, map[string]*pb.TypeDefinition, error)
- func TransformModuleFilesToModel(modules []ModuleFile, schemaVersion string) (*pb.AuthorizationModel, error)
- type DirectAssignmentValidator
- type ModFile
- type ModFileArrayProperty
- type ModFileStringProperty
- type ModFileValidationError
- type ModFileValidationErrorMetadata
- type ModFileValidationMultipleError
- type ModuleFile
- type ModuleTransformationSingleError
- type ModuleTransformationSingleMetadata
- type ModuleValidationMultipleError
- type OpenFgaDslErrorListener
- type OpenFgaDslListener
- func (l *OpenFgaDslListener) EnterCondition(ctx *parser.ConditionContext)
- func (l *OpenFgaDslListener) EnterConditions(_ *parser.ConditionsContext)
- func (l *OpenFgaDslListener) EnterMain(_ *parser.MainContext)
- func (l *OpenFgaDslListener) EnterRelationDeclaration(_ *parser.RelationDeclarationContext)
- func (l *OpenFgaDslListener) EnterRelationDefDirectAssignment(_ *parser.RelationDefDirectAssignmentContext)
- func (l *OpenFgaDslListener) EnterRelationDefPartials(ctx *parser.RelationDefPartialsContext)
- func (l *OpenFgaDslListener) EnterRelationRecurseNoDirect(_ *parser.RelationRecurseNoDirectContext)
- func (l *OpenFgaDslListener) EnterTypeDef(ctx *parser.TypeDefContext)
- func (l *OpenFgaDslListener) ExitCondition(_ *parser.ConditionContext)
- func (l *OpenFgaDslListener) ExitConditionExpression(ctx *parser.ConditionExpressionContext)
- func (l *OpenFgaDslListener) ExitConditionParameter(ctx *parser.ConditionParameterContext)
- func (l *OpenFgaDslListener) ExitModelHeader(ctx *parser.ModelHeaderContext)
- func (l *OpenFgaDslListener) ExitModuleHeader(ctx *parser.ModuleHeaderContext)
- func (l *OpenFgaDslListener) ExitRelationDeclaration(ctx *parser.RelationDeclarationContext)
- func (l *OpenFgaDslListener) ExitRelationDefDirectAssignment(_ *parser.RelationDefDirectAssignmentContext)
- func (l *OpenFgaDslListener) ExitRelationDefRewrite(ctx *parser.RelationDefRewriteContext)
- func (l *OpenFgaDslListener) ExitRelationDefTypeRestriction(ctx *parser.RelationDefTypeRestrictionContext)
- func (l *OpenFgaDslListener) ExitRelationRecurse(_ *parser.RelationRecurseContext)
- func (l *OpenFgaDslListener) ExitRelationRecurseNoDirect(_ *parser.RelationRecurseNoDirectContext)
- func (l *OpenFgaDslListener) ExitTypeDef(ctx *parser.TypeDefContext)
- type OpenFgaDslSyntaxError
- type OpenFgaDslSyntaxErrorMetadata
- type OpenFgaDslSyntaxMultipleError
- type RelationDefinitionOperator
- type TransformOption
- type YAMLModFile
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 ¶
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 ParseDSL ¶
func ParseDSL(data string) (*OpenFgaDslListener, *OpenFgaDslErrorListener)
func ParseExpression ¶
func ParseExpression(rewrites []*pb.Userset, operator RelationDefinitionOperator) *pb.Userset
func TransformDSLToJSON ¶
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 ¶
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 ModFileValidationError ¶
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 ¶
func (e *ModFileValidationMultipleError) Error() string
type ModuleFile ¶
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 ¶
func (e *ModuleTransformationSingleError) Error() string
type ModuleTransformationSingleMetadata ¶
type ModuleTransformationSingleMetadata struct{}
type ModuleValidationMultipleError ¶
type ModuleValidationMultipleError multierror.Error
func (*ModuleValidationMultipleError) Error ¶
func (e *ModuleValidationMultipleError) Error() string
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 ¶
func (err *OpenFgaDslSyntaxMultipleError) Error() string
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"` }