flat-rose-25983
04/19/2023, 3:40 PMpackage main
import (
"context"
"fmt"
"os"
ory "<http://github.com/ory/keto-client-go|github.com/ory/keto-client-go>"
)
// Use this context to access Ory APIs which require an Ory API Key.
var namespace = "Blog"
var object = "secret_post"
var relation = "view"
var subjectId = "Bob"
func main() {
payload := ory.CreateRelationshipBody{
Namespace: &namespace,
Object: &object,
Relation: &relation,
SubjectId: &subjectId,
}
configuration := ory.NewConfiguration()
configuration.Servers = []ory.ServerConfiguration{
{
URL: "<http://127.0.0.1:4467>", // Write API
},
}
writeClient := ory.NewAPIClient(configuration)
_, r, err := writeClient.RelationshipApi.CreateRelationship(context.Background()).CreateRelationshipBody(payload).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
panic("Encountered error: " + err.Error())
}
fmt.Println("Successfully created tuple")
configuration.Servers = []client.ServerConfiguration{
{
URL: "<http://127.0.0.1:4466>", // Read API
},
}
readClient := client.NewAPIClient(configuration)
check, r, err := readClient.PermissionApi.CheckPermission(context.Background()).
Namespace(*&namespace).
Object(*&object).
Relation(*&relation).
SubjectId(*&subjectId).Execute()
if err != nil {
fmt.Fprintf(os.Stderr, "Full HTTP response: %v\n", r)
panic("Encountered error: " + err.Error())
}
if check.Allowed {
fmt.Println(*&subjectId + " can " + *&relation + " the " + *&object)
}
}
magnificent-energy-493
flat-rose-25983
04/20/2023, 7:20 AMgo mod init main
Create main.go
-go mod tidy
2. Run the command go run main.go
to execute the program
3. I got 404 not found
I have checked the url that the sdk is using but is not the one am using: <http://localhost:4466/relation-tuples/check/openapi>
if i do i get the response
curl --request POST \
--url <http://localhost:4466/check> \
--header 'Content-Type: application/json' \
--data ' {
"namespace": "ukama",
"object": "billing",
"relation": "owner",
"subject_id": "user"
}'
steep-lamp-91158
flat-rose-25983
04/20/2023, 1:37 PMsteep-lamp-91158
steep-lamp-91158
/relation-tuples/check/openapi
steep-lamp-91158
flat-rose-25983
04/20/2023, 4:18 PMmagnificent-energy-493