Skip to main content
Version: 2.0.0

permit.api.resources.create()

Creates a new resource.

Parameters

resourceData - An object that contains the information about the new resource. The payload is defined below.

Payload

key - A URL-friendly name of the resource (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the resource.
name - The name of the resource.
urn - optional - The URN(Uniform Resource Name) of the resource.
description - optional - An optional longer description of what this resource respresents in your system.
actions - A actions definition block, typically contained within a resource type definition block. The actions represents the ways you can interact with a protected resource.
attributes - optional - Attributes that each resource of this type defines, and can be used in your ABAC policies.

Implementation

import io.permit.sdk.openapi.models.ResourceRead;
import io.permit.sdk.openapi.models.ResourceCreate;

// create document resource
ResourceCreate resourceInput = ((
new ResourceCreate("document", "Document", actions)
)
.withUrn("prn:gdrive:document")
.withDescription("google drive document")
.withAttributes(attributes)
);

ResourceRead document = permit.api.resources.create(resourceInput);