MCPcopy Create free account
hub / github.com/Permify/permify / GetTypeOfReferenceByNameInEntityDefinition

Function GetTypeOfReferenceByNameInEntityDefinition

internal/schema/schema.go:117–125  ·  view source on GitHub ↗

GetTypeOfReferenceByNameInEntityDefinition retrieves the type of reference in an `EntityDefinition` by its name. It returns the type of the relational reference if it is found in the `EntityDefinition`. If the relational reference is not found, it returns an error with error code `ERROR_CODE_RELATIO

(entityDefinition *base.EntityDefinition, name string)

Source from the content-addressed store, hash-verified

115// It returns the type of the relational reference if it is found in the `EntityDefinition`.
116// If the relational reference is not found, it returns an error with error code `ERROR_CODE_RELATION_DEFINITION_NOT_FOUND`.
117func GetTypeOfReferenceByNameInEntityDefinition(entityDefinition *base.EntityDefinition, name string) (relationalDefinitionType base.EntityDefinition_Reference, err error) {
118 // Look up the relational reference in the entity definition's References map
119 if re, ok := entityDefinition.GetReferences()[name]; ok {
120 // If the relational reference is found, return its type and a nil error
121 return re, nil
122 }
123 // If the relational reference is not found, return the default type and an error
124 return base.EntityDefinition_REFERENCE_UNSPECIFIED, errors.New(base.ErrorCode_ERROR_CODE_RELATION_DEFINITION_NOT_FOUND.String())
125}
126
127// GetPermissionByNameInEntityDefinition retrieves an `PermissionDefinition` from an `EntityDefinition` by its name.
128// It returns a pointer to the `PermissionDefinition` if it is found in the `EntityDefinition`.

Callers 5

subjectFilterMethod · 0.92
expandMethod · 0.92
IsRelationalFunction · 0.92
checkMethod · 0.92
schema_test.goFile · 0.85

Calls 2

StringMethod · 0.65
GetReferencesMethod · 0.45

Tested by

no test coverage detected