File tree Expand file tree Collapse file tree 1 file changed +19
-0
lines changed
Expand file tree Collapse file tree 1 file changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,9 @@ package openfga
1414
1515import (
1616 "encoding/json"
17+ "fmt"
1718 "net/url"
19+ "strings"
1820 "time"
1921)
2022
@@ -341,3 +343,20 @@ func IsWellFormedUri(uriString string) bool {
341343
342344 return true
343345}
346+
347+ func (o FgaObject ) String () string {
348+ return fmt .Sprintf ("%s:%s" , o .Type , o .Id )
349+ }
350+
351+ func FgaObjectFromString (objectString string ) (* FgaObject , error ) {
352+ if objectString == "" {
353+ return nil , fmt .Errorf ("failed parsing FgaObject, cannot build FgaObject from empty string" )
354+ }
355+ objectTokens := strings .Split (objectString , ":" )
356+ if len (objectTokens ) != 2 {
357+ return nil , fmt .Errorf ("failed parsing FgaObject, invalid FgaObject string" )
358+ }
359+ objectType := objectTokens [0 ]
360+ objectId := objectTokens [1 ]
361+ return NewFgaObject (objectType , objectId ), nil
362+ }
You can’t perform that action at this time.
0 commit comments