diff --git a/.gitignore b/.gitignore index c2a34a8..b671201 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,6 @@ # Ignore Gradle build output directory build + +# Ignore stg schemas +stg-schemas/ diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..144fa2c --- /dev/null +++ b/Makefile @@ -0,0 +1,17 @@ +.PHONY: help + +.DEFAULT_GOAL := help + +# ENVIRONMENT?=dev + +## generate openapi models +generate-openapi: + openapi-generator generate -i https://api.permit.io/v2/openapi.json -g java -o generated/ -c openapi-config.json + +clean-openapi: + rm -rf generated/ + +## generate open api models from json schema +generate-jsonschema: + openapi2jsonschema https://api.permit.io/v2/openapi.json -o schemas/ + diff --git a/README.md b/README.md index 7e68aa7..6a88f28 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,140 @@ -# Permit.io client for Java +# Java SDK for Permit.io -Java client library for the Permit.io full-stack permissions platform. +Java SDK for interacting with the Permit.io full-stack permissions platform. +## Overview + +This guide will walk you through the steps of installing the Permit.io Java SDK and integrating it into your code. + +## Installation + +For [Maven](https://maven.apache.org/) projects, use: +```xml + + io.permit + permit-sdk-java + 1.0.0-RC + +``` + +For [Gradle](https://gradle.org/) projects, configure `permit-sdk-java` as a dependency in your `build.gradle` file: +```groovy +dependencies { + // ... + + implementation 'io.permit:permit-sdk-java:1.0.0-RC' +} +``` + +## Usage + +### Initializing the SDK +To init the SDK, you need to create a new Permit client with the API key you got from the Permit.io dashboard. + +First we will create a new `PermitConfig` object so we can pass it to the Permit client. + +Second, we will create a new `Permit` client with the `PermitConfig` object we created. + +```java +import io.permit.sdk.Permit; +import io.permit.sdk.PermitConfig; + +// This line initializes the SDK and connects your Java app +// to the Permit.io PDP container you've set up in the previous step. +Permit permit = new Permit( + new PermitConfig.Builder("[YOUR_API_KEY]") + // in production, you might need to change this url to fit your deployment + .withPdpAddress("http://localhost:7766") + // optionally, if you wish to get more debug messages to your log, set this to true + .withDebugMode(false) + .build() + ); +``` + +### Checking permissions +To check permissions using our `permit.check()` method, you will have to create User and Resource models as input to the permission check. +The models are located in `` + +Follow the example below: + +```java +import io.permit.sdk.enforcement.Resource; +import io.permit.sdk.enforcement.User; +import io.permit.sdk.Permit; + +boolean permitted = permit.check( + // building the user object using User.fromString() + // the user key (this is the unique identifier of the user in the permission system). + User.fromString("[USER KEY]"), + // the action key (string) + "create", + // the resource object, can be initialized from string if the "default" tenant is used. + Resource.fromString("document") +); + +if (permitted) { + System.out.println("User is PERMITTED to create a document in the 'default' tenant"); +} else { + System.out.println("User is NOT PERMITTED to create a document in the 'default' tenant"); +} +``` + +A more complicated example (passing attributes on the user object, using an explicit tenant in the resource): +```java +import io.permit.sdk.enforcement.Resource; +import io.permit.sdk.enforcement.User; +import java.util.HashMap; + + +HashMap userAttributes = new HashMap<>(); +userAttributes.put("age", Integer.valueOf(20)); +userAttributes.put("favorite_color", "yellow"); + +boolean permitted = permit.check( + // building the user object using the User.Builder class + new User.Builder("[USER KEY]").withAttributes(userAttributes).build(), + // the action key (string) + "create", + // building the resource object using the Resource.Builder in order to pass an explicit tenant key: "awesome-inc" + new Resource.Builder("document").withTenant("awesome-inc").build() +); + +if (permitted) { + System.out.println("User is PERMITTED to create a document in the 'awesome-inc' tenant"); +} else { + System.out.println("User is NOT PERMITTED to create a document in the 'awesome-inc' tenant"); +} +``` + +### Syncing users +When the user first logins, and after you check if he authenticated successfully (i.e: **by checking the JWT access token**) - +you need to declare the user in the permission system so you can run `permit.check()` on that user. + +To declare (or "sync") a user in the Permit.io API, use the `permit.api.users.sync()` method. + +Follow the example below: +```java +import io.permit.sdk.api.models.CreateOrUpdateResult; +import io.permit.sdk.enforcement.User; + +HashMap userAttributes = new HashMap<>(); +userAttributes.put("age", Integer.valueOf(50)); +userAttributes.put("fav_color", "red"); + +CreateOrUpdateResult result = permit.api.users.sync( + (new User.Builder("auth0|elon")) + .withEmail("elonmusk@tesla.com") + .withFirstName("Elon") + .withLastName("Musk") + .withAttributes(userAttributes) + .build() +); +UserRead user = result.getResult(); +assertTrue(result.wasCreated()); +``` + +Most params to UserCreates are optional, and only the unique user key is needed. This is valid: + +```java +CreateOrUpdateResult result = permit.api.users.sync(new UserCreate("[USER KEY]")); +``` \ No newline at end of file diff --git a/build.gradle b/build.gradle index 8173add..49a2664 100644 --- a/build.gradle +++ b/build.gradle @@ -17,6 +17,8 @@ plugins { id 'com.palantir.git-version' version '0.13.0' // auto release to maven central (skip sonatype manual nexus release process) id("io.github.gradle-nexus.publish-plugin") version "1.1.0" + // translate json schemas to java classes + id "org.jsonschema2pojo" version "1.1.3" } // It is important to set the group and the version to the root project @@ -41,20 +43,107 @@ java { // package dependencies dependencies { + // swagger + implementation 'io.swagger:swagger-annotations:1.6.5' + + // http client + implementation 'com.squareup.okhttp3:okhttp:4.9.3' + implementation 'com.squareup.okhttp3:logging-interceptor:4.9.3' + + // json serialization and deserialization + implementation 'com.google.code.gson:gson:2.9.0' + implementation 'io.gsonfire:gson-fire:1.8.5' + + // openapi annotations + implementation 'javax.ws.rs:jsr311-api:1.1.1' + implementation 'javax.ws.rs:javax.ws.rs-api:2.1.1' + implementation 'org.openapitools:jackson-databind-nullable:0.2.3' + implementation group: 'org.apache.commons', name: 'commons-lang3', version: '3.12.0' + implementation "jakarta.annotation:jakarta.annotation-api:1.3.5" + + // logger implementation 'ch.qos.logback:logback-classic:1.2.10' implementation 'ch.qos.logback:logback-core:1.2.10' implementation 'org.slf4j:slf4j-api:1.7.33' + + // Use JUnit Jupiter for testing. testImplementation 'org.junit.jupiter:junit-jupiter:5.7.2' // These dependencies are used internally, and not exposed to consumers on their own compile classpath. // google standard java library implementation 'com.google.guava:guava:30.1.1-jre' - // json serialization and deserialization - implementation 'com.google.code.gson:gson:2.8.9' - // http client - implementation 'com.squareup.okhttp3:okhttp:4.9.3' + + +} + +jsonSchema2Pojo { + // Location of the JSON Schema file(s). This may refer to a single file or a directory of files. + source = files("schemas/") + + // Target directory for generated Java source files. The plugin will add this directory to the + // java source set so the compiler will find and compile the newly generated source files. + targetDirectory = file("src/main/java") + + // Package name used for generated Java classes (for types where a fully qualified name has not + // been supplied in the schema using the 'javaType' property). + targetPackage = 'io.permit.sdk.openapi.models' + + // Whether to allow 'additional' properties to be supported in classes by adding a map to + // hold these. This is true by default, meaning that the schema rule 'additionalProperties' + // controls whether the map is added. Set this to false to globally disable additional properties. + includeAdditionalProperties = false + + // Whether to include a javax.annotation.Generated (Java 8 and lower) or + // javax.annotation.processing.Generated (Java 9+) in on generated types (default true). + // See also: targetVersion. + includeGeneratedAnnotation = true + + // Whether to use the 'title' property of the schema to decide the class name (if not + // set to true, the filename and property names are used). + useTitleAsClassname = true + + // Whether to empty the target directory before generation occurs, to clear out all source files + // that have been generated previously. Be warned, when activated this option + // will cause jsonschema2pojo to indiscriminately delete the entire contents of the target + // directory (all files and folders) before it begins generating sources. + removeOldOutput = false + + // Whether to generate builder-style methods of the form withXxx(value) (that return this), + // alongside the standard, void-return setters. + generateBuilders = true + + // If set to true, then the gang of four builder pattern will be used to generate builders on + // generated classes. Note: This property works in collaboration with generateBuilders. + // If generateBuilders is false then this property will not do anything. + useInnerClassBuilders = false + + // Whether to include hashCode and equals methods in generated Java types. + includeHashcodeAndEquals = false + + // Whether to include a toString method in generated Java types. + includeToString = false + + // Whether to include getters or to omit these accessor methods and create public fields instead. + includeGetters = false + + // Whether to include setters or to omit these accessor methods and create public fields instead. + includeSetters = false + + // Whether to use java.util.Optional for getters on properties that are not required + useOptionalForGetters = true + + // Whether to generate constructors or not. + includeConstructors = true + + // Whether to include only 'required' fields in generated constructors + constructorsRequiredPropertiesOnly = true + + annotationStyle = 'gson' + + // Whether to initialize Set and List fields as empty collections, or leave them as null. + initializeCollections = false } publishing { diff --git a/openapi-config.json b/openapi-config.json new file mode 100644 index 0000000..8498e7b --- /dev/null +++ b/openapi-config.json @@ -0,0 +1,7 @@ +{ + "apiPackage": "io.permit.sdk.openapi.api", + "invokerPackage": "io.permit.sdk.openapi.client", + "modelPackage": "io.permit.sdk.openapi.model", + "serializationLibrary": "gson", + "legacyDiscriminatorBehavior": "true" +} \ No newline at end of file diff --git a/schemas/actionblockeditable.json b/schemas/actionblockeditable.json new file mode 100644 index 0000000..98d5bfd --- /dev/null +++ b/schemas/actionblockeditable.json @@ -0,0 +1,18 @@ +{ + "title": "ActionBlockEditable", + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "a more descriptive name for the action" + }, + "description": { + "title": "Description", + "type": "string", + "description": "optional description string explaining what this action represents in your system" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/actionblockread.json b/schemas/actionblockread.json new file mode 100644 index 0000000..053d47a --- /dev/null +++ b/schemas/actionblockread.json @@ -0,0 +1,31 @@ +{ + "title": "ActionBlockRead", + "required": [ + "id" + ], + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "a more descriptive name for the action" + }, + "description": { + "title": "Description", + "type": "string", + "description": "optional description string explaining what this action represents in your system" + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the action" + }, + "key": { + "title": "Key", + "type": "string", + "description": "action key" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/addrolepermissions.json b/schemas/addrolepermissions.json new file mode 100644 index 0000000..4ec4b6e --- /dev/null +++ b/schemas/addrolepermissions.json @@ -0,0 +1,24 @@ +{ + "title": "AddRolePermissions", + "required": [ + "permissions" + ], + "type": "object", + "properties": { + "permissions": { + "title": "Permissions", + "type": "array", + "items": { + "type": "string" + }, + "description": "List of permissions to assign to the role. If a permission is already granted to the role it is skipped. Each permission can be either a resource action id, or `{resource_key}:{action_key}`, i.e: the \"permission name\"." + } + }, + "additionalProperties": false, + "example": { + "permissions": [ + "document:write" + ] + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/apikeyscoperead.json b/schemas/apikeyscoperead.json new file mode 100644 index 0000000..2eeed49 --- /dev/null +++ b/schemas/apikeyscoperead.json @@ -0,0 +1,26 @@ +{ + "title": "APIKeyScopeRead", + "required": [ + "organization_id" + ], + "type": "object", + "properties": { + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the api_key belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the api_key belongs to." + }, + "environment_id": { + "title": "Environment Id", + "type": "string", + "description": "Unique id of the environment that the api_key belongs to." + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/attributeblockeditable.json b/schemas/attributeblockeditable.json new file mode 100644 index 0000000..d545666 --- /dev/null +++ b/schemas/attributeblockeditable.json @@ -0,0 +1,19 @@ +{ + "title": "AttributeBlockEditable", + "required": [ + "type" + ], + "type": "object", + "properties": { + "type": { + "existingJavaType": "io.permit.sdk.openapi.models.AttributeType" + }, + "description": { + "title": "Description", + "type": "string", + "description": "optional description string explaining what data this attribute will store" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/attributeblockread.json b/schemas/attributeblockread.json new file mode 100644 index 0000000..15195c9 --- /dev/null +++ b/schemas/attributeblockread.json @@ -0,0 +1,30 @@ +{ + "title": "AttributeBlockRead", + "required": [ + "type", + "id" + ], + "type": "object", + "properties": { + "type": { + "existingJavaType": "io.permit.sdk.openapi.models.AttributeType" + }, + "description": { + "title": "Description", + "type": "string", + "description": "optional description string explaining what data this attribute will store" + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the attribute" + }, + "key": { + "title": "Key", + "type": "string", + "description": "action key" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/attributetype.json b/schemas/attributetype.json new file mode 100644 index 0000000..89d299a --- /dev/null +++ b/schemas/attributetype.json @@ -0,0 +1,14 @@ +{ + "title": "AttributeType", + "enum": [ + "bool", + "number", + "string", + "time", + "array", + "json" + ], + "type": "string", + "description": "The type of the attribute, we currently support: `bool`, `number` (ints, floats), `time` (a timestamp), `string`, and `json`.", + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/conditionsetcreate.json b/schemas/conditionsetcreate.json new file mode 100644 index 0000000..467cc76 --- /dev/null +++ b/schemas/conditionsetcreate.json @@ -0,0 +1,74 @@ +{ + "title": "ConditionSetCreate", + "required": [ + "key", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "minLength": 1, + "pattern": "^[A-Za-z0-9\\-_]+$", + "type": "string", + "description": "A unique id by which Permit will identify the condition set. The key will be used as the generated rego rule name." + }, + "type": { + "existingJavaType": "io.permit.sdk.openapi.models.ConditionSetType", + "description": "the type of the set: UserSet or ResourceSet" + }, + "autogenerated": { + "title": "Autogenerated", + "type": "boolean", + "description": "whether the set was autogenerated by the system.", + "default": false + }, + "resource_id": { + "title": "Resource Id", + "type": "string", + "description": "For ResourceSets, the id of the base resource." + }, + "name": { + "title": "Name", + "minLength": 1, + "type": "string", + "description": "A descriptive name for the set, i.e: 'US based employees' or 'Users behind VPN'" + }, + "description": { + "title": "Description", + "type": "string", + "description": "an optional longer description of the set" + }, + "conditions": { + "title": "Conditions", + "type": "object", + "description": "a boolean expression that consists of multiple conditions, with and/or logic.", + "default": {}, + "existingJavaType": "java.util.HashMap" + } + }, + "additionalProperties": false, + "example": { + "key": "na_based_employees", + "name": "US or Canada based employees", + "type": "userset", + "conditions": { + "allOf": [ + { + "user.role": { + "equals": "employee" + } + }, + { + "user.location": { + "in": [ + "US", + "Canada" + ] + } + } + ] + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/conditionsetread.json b/schemas/conditionsetread.json new file mode 100644 index 0000000..00ce5cc --- /dev/null +++ b/schemas/conditionsetread.json @@ -0,0 +1,122 @@ +{ + "title": "ConditionSetRead", + "required": [ + "key", + "id", + "organization_id", + "project_id", + "environment_id", + "created_at", + "updated_at", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "type": "string", + "description": "A unique id by which Permit will identify the condition set. The key will be used as the generated rego rule name." + }, + "type": { + "existingJavaType": "io.permit.sdk.openapi.models.ConditionSetType", + "description": "the type of the set: UserSet or ResourceSet" + }, + "autogenerated": { + "title": "Autogenerated", + "type": "boolean", + "description": "whether the set was autogenerated by the system.", + "default": false + }, + "resource_id": { + "title": "Resource Id", + "type": "string", + "description": "For ResourceSets, the id of the base resource." + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the condition set" + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the condition set belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the condition set belongs to." + }, + "environment_id": { + "title": "Environment Id", + "type": "string", + "description": "Unique id of the environment that the condition set belongs to." + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the condition set was created (ISO_8601 format).", + "format": "date-time" + }, + "updated_at": { + "title": "Updated At", + "type": "string", + "description": "Date and time when the condition set was last updated/modified (ISO_8601 format).", + "format": "date-time" + }, + "resource": { + "$ref": "ResourceRead.json" + }, + "name": { + "title": "Name", + "minLength": 1, + "type": "string", + "description": "A descriptive name for the set, i.e: 'US based employees' or 'Users behind VPN'" + }, + "description": { + "title": "Description", + "type": "string", + "description": "an optional longer description of the set" + }, + "conditions": { + "title": "Conditions", + "type": "object", + "description": "a boolean expression that consists of multiple conditions, with and/or logic.", + "default": {}, + "existingJavaType": "java.util.HashMap" + } + }, + "additionalProperties": false, + "example": { + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "resource_id": "e05f8571-f31e-20b2-2c45-15ae74cfb0f1", + "environment_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z", + "key": "na_based_employees", + "name": "US or Canada based employees", + "description": "All employees based in the US or Canada", + "type": "userset", + "autogenerated": false, + "conditions": { + "allOf": [ + { + "user.role": { + "equals": "employee" + } + }, + { + "user.location": { + "in": [ + "US", + "Canada" + ] + } + } + ] + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/conditionsetrulecreate.json b/schemas/conditionsetrulecreate.json new file mode 100644 index 0000000..aba2094 --- /dev/null +++ b/schemas/conditionsetrulecreate.json @@ -0,0 +1,45 @@ +{ + "title": "ConditionSetRuleCreate", + "required": [ + "user_set", + "permission", + "resource_set" + ], + "type": "object", + "properties": { + "user_set": { + "title": "User Set", + "type": "string", + "description": "The userset that will be given permission, i.e: all the users matching this rule will be given the specified permission" + }, + "permission": { + "title": "Permission", + "type": "string", + "description": "The permission that will be granted to the userset *on* the resourceset. The permission can be either a resource action id, or `{resource_key}:{action_key}`, i.e: the \"permission name\"." + }, + "resource_set": { + "title": "Resource Set", + "type": "string", + "description": "The resourceset that represents the resources that are granted for access, i.e: all the resources matching this rule can be accessed by the userset to perform the granted *permission*" + }, + "is_role": { + "title": "Is Role", + "type": "boolean", + "description": "if True, will set the condition set rule to the role's autogen user-set.", + "default": false + }, + "is_resource": { + "title": "Is Resource", + "type": "boolean", + "description": "if True, will set the condition set rule to the resource's autogen resource-set.", + "default": false + } + }, + "additionalProperties": false, + "example": { + "user_set": "us_based_employees", + "permission": "repository:clone", + "resource_set": "private_repos" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/conditionsetruleread.json b/schemas/conditionsetruleread.json new file mode 100644 index 0000000..d0aa06f --- /dev/null +++ b/schemas/conditionsetruleread.json @@ -0,0 +1,84 @@ +{ + "title": "ConditionSetRuleRead", + "required": [ + "id", + "key", + "user_set", + "permission", + "resource_set", + "organization_id", + "project_id", + "environment_id", + "created_at", + "updated_at" + ], + "type": "object", + "properties": { + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the condition set rule" + }, + "key": { + "title": "Key", + "type": "string", + "description": "A unique id by which Permit will identify this condition set rule." + }, + "user_set": { + "title": "User Set", + "type": "string", + "description": "the userset that is currently granted permissions, i.e: all the users matching this rule are granted the permission on the resourceset" + }, + "permission": { + "title": "Permission", + "type": "string", + "description": "a permission that is currently granted to the userset *on* the resourceset." + }, + "resource_set": { + "title": "Resource Set", + "type": "string", + "description": "the resourceset that represents the resources that are currently granted for access, i.e: all the resources matching this rule can be accessed by the userset to perform the granted *permission*" + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the condition set rule belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the condition set rule belongs to." + }, + "environment_id": { + "title": "Environment Id", + "type": "string", + "description": "Unique id of the environment that the condition set rule belongs to." + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the condition set rule was created (ISO_8601 format).", + "format": "date-time" + }, + "updated_at": { + "title": "Updated At", + "type": "string", + "description": "Date and time when the condition set rule was last updated/modified (ISO_8601 format).", + "format": "date-time" + } + }, + "additionalProperties": false, + "example": { + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "key": "us_based_employees_can_repository_clone_private_repos", + "user_set": "us_based_employees", + "permission": "repository:clone", + "resource_set": "private_repos", + "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "environment_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:16:22Z" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/conditionsetruleremove.json b/schemas/conditionsetruleremove.json new file mode 100644 index 0000000..58c57b3 --- /dev/null +++ b/schemas/conditionsetruleremove.json @@ -0,0 +1,45 @@ +{ + "title": "ConditionSetRuleRemove", + "required": [ + "user_set", + "permission", + "resource_set" + ], + "type": "object", + "properties": { + "user_set": { + "title": "User Set", + "type": "string", + "description": "The userset that will be unassigned these permission, i.e: all the users matching this rule will lose the specified permission" + }, + "permission": { + "title": "Permission", + "type": "string", + "description": "The permission that will be removed from the userset *on* the resourceset. The permission can be either a resource action id, or `{resource_key}:{action_key}`, i.e: the \"permission name\"." + }, + "resource_set": { + "title": "Resource Set", + "type": "string", + "description": "The resourceset that represents the resources that are no longer granted for access, i.e: all the resources matching this rule can no longer be accessed by the userset, and will be revoked the specified *permission*" + }, + "is_role": { + "title": "Is Role", + "type": "boolean", + "description": "if True, will set the condition set rule to the role's autogen user-set.", + "default": false + }, + "is_resource": { + "title": "Is Resource", + "type": "boolean", + "description": "if True, will set the condition set rule to the resource's autogen resource-set.", + "default": false + } + }, + "additionalProperties": false, + "example": { + "user_set": "us_based_employees", + "permission": "repository:clone", + "resource_set": "private_repos" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/conditionsettype.json b/schemas/conditionsettype.json new file mode 100644 index 0000000..680caf6 --- /dev/null +++ b/schemas/conditionsettype.json @@ -0,0 +1,10 @@ +{ + "title": "ConditionSetType", + "enum": [ + "userset", + "resourceset" + ], + "type": "string", + "description": "the type of the set: UserSet or ResourceSet", + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/conditionsetupdate.json b/schemas/conditionsetupdate.json new file mode 100644 index 0000000..e0bf729 --- /dev/null +++ b/schemas/conditionsetupdate.json @@ -0,0 +1,45 @@ +{ + "title": "ConditionSetUpdate", + "type": "object", + "properties": { + "name": { + "title": "Name", + "minLength": 1, + "type": "string", + "description": "A descriptive name for the set, i.e: 'US based employees' or 'Users behind VPN'" + }, + "description": { + "title": "Description", + "type": "string", + "description": "an optional longer description of the set" + }, + "conditions": { + "title": "Conditions", + "type": "object", + "description": "a boolean expression that consists of multiple conditions, with and/or logic.", + "default": {}, + "existingJavaType": "java.util.HashMap" + } + }, + "additionalProperties": false, + "example": { + "name": "US based managers", + "conditions": { + "allOf": [ + { + "user.role": { + "equals": "manager" + } + }, + { + "user.location": { + "in": [ + "US" + ] + } + } + ] + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/embeddedloginrequestoutput.json b/schemas/embeddedloginrequestoutput.json new file mode 100644 index 0000000..82bcf08 --- /dev/null +++ b/schemas/embeddedloginrequestoutput.json @@ -0,0 +1,35 @@ +{ + "title": "EmbeddedLoginRequestOutput", + "required": [ + "redirect_url" + ], + "type": "object", + "properties": { + "error": { + "title": "Error", + "type": "string", + "description": "If the login request failed, this field will contain the error message" + }, + "error_code": { + "title": "Error Code", + "type": "integer", + "description": "If the login request failed, this field will contain the error code" + }, + "token": { + "title": "Token", + "type": "string", + "description": "The auth token that lets your users login into permit elements" + }, + "extra": { + "title": "Extra", + "type": "string", + "description": "Extra data that you can pass to the login request" + }, + "redirect_url": { + "title": "Redirect Url", + "type": "string", + "description": "The full URL to which the user should be redirected in order to complete the login process" + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/environmentcreate.json b/schemas/environmentcreate.json new file mode 100644 index 0000000..ba4fb24 --- /dev/null +++ b/schemas/environmentcreate.json @@ -0,0 +1,33 @@ +{ + "title": "EnvironmentCreate", + "required": [ + "key", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "pattern": "^[A-Za-z0-9\\-_]+$", + "type": "string", + "description": "A URL-friendly name of the environment (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the environment." + }, + "name": { + "title": "Name", + "type": "string", + "description": "The name of the environment" + }, + "description": { + "title": "Description", + "type": "string", + "description": "an optional longer description of the environment" + }, + "custom_branch_name": { + "title": "Custom Branch Name", + "type": "string", + "description": "when using gitops feature, an optional branch name for the environment" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/environmentread.json b/schemas/environmentread.json new file mode 100644 index 0000000..05cabd5 --- /dev/null +++ b/schemas/environmentread.json @@ -0,0 +1,64 @@ +{ + "title": "EnvironmentRead", + "required": [ + "key", + "id", + "organization_id", + "project_id", + "created_at", + "updated_at", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "type": "string", + "description": "A URL-friendly name of the environment (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the environment." + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the environment" + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the environment belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the environment belongs to." + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the environment was created (ISO_8601 format).", + "format": "date-time" + }, + "updated_at": { + "title": "Updated At", + "type": "string", + "description": "Date and time when the environment was last updated/modified (ISO_8601 format).", + "format": "date-time" + }, + "name": { + "title": "Name", + "type": "string", + "description": "The name of the environment" + }, + "description": { + "title": "Description", + "type": "string", + "description": "an optional longer description of the environment" + }, + "custom_branch_name": { + "title": "Custom Branch Name", + "type": "string", + "description": "when using gitops feature, an optional branch name for the environment" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/environmentstats.json b/schemas/environmentstats.json new file mode 100644 index 0000000..82b883a --- /dev/null +++ b/schemas/environmentstats.json @@ -0,0 +1,76 @@ +{ + "title": "EnvironmentStats", + "required": [ + "key", + "id", + "organization_id", + "project_id", + "created_at", + "updated_at", + "name", + "pdp_configs", + "stats" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "type": "string", + "description": "A URL-friendly name of the environment (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the environment." + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the environment" + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the environment belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the environment belongs to." + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the environment was created (ISO_8601 format).", + "format": "date-time" + }, + "updated_at": { + "title": "Updated At", + "type": "string", + "description": "Date and time when the environment was last updated/modified (ISO_8601 format).", + "format": "date-time" + }, + "name": { + "title": "Name", + "type": "string", + "description": "The name of the environment" + }, + "description": { + "title": "Description", + "type": "string", + "description": "an optional longer description of the environment" + }, + "custom_branch_name": { + "title": "Custom Branch Name", + "type": "string", + "description": "when using gitops feature, an optional branch name for the environment" + }, + "pdp_configs": { + "title": "Pdp Configs", + "type": "array", + "items": { + "$ref": "PDPConfigRead.json" + } + }, + "stats": { + "$ref": "Statistics.json" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/environmentupdate.json b/schemas/environmentupdate.json new file mode 100644 index 0000000..235b38e --- /dev/null +++ b/schemas/environmentupdate.json @@ -0,0 +1,23 @@ +{ + "title": "EnvironmentUpdate", + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "The name of the environment" + }, + "description": { + "title": "Description", + "type": "string", + "description": "an optional longer description of the environment" + }, + "custom_branch_name": { + "title": "Custom Branch Name", + "type": "string", + "description": "when using gitops feature, an optional branch name for the environment" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/httpvalidationerror.json b/schemas/httpvalidationerror.json new file mode 100644 index 0000000..56673a2 --- /dev/null +++ b/schemas/httpvalidationerror.json @@ -0,0 +1,14 @@ +{ + "title": "HTTPValidationError", + "type": "object", + "properties": { + "detail": { + "title": "Detail", + "type": "array", + "items": { + "$ref": "ValidationError.json" + } + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/organizationcreate.json b/schemas/organizationcreate.json new file mode 100644 index 0000000..067db8b --- /dev/null +++ b/schemas/organizationcreate.json @@ -0,0 +1,29 @@ +{ + "title": "OrganizationCreate", + "required": [ + "key", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "pattern": "^[A-Za-z0-9\\-_]+$", + "type": "string", + "description": "A URL-friendly name of the organization (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the organization." + }, + "name": { + "title": "Name", + "pattern": "^[A-Za-z0-9\\.\\-\\_\\ ]+$", + "type": "string", + "description": "The name of the organization, usually it's your company's name." + }, + "settings": { + "title": "Settings", + "type": "object", + "description": "the settings for this project" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/organizationread.json b/schemas/organizationread.json new file mode 100644 index 0000000..a8d72d5 --- /dev/null +++ b/schemas/organizationread.json @@ -0,0 +1,47 @@ +{ + "title": "OrganizationRead", + "required": [ + "key", + "id", + "created_at", + "updated_at", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "type": "string", + "description": "A URL-friendly name of the organization (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the organization." + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the organization" + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the organization was created (ISO_8601 format).", + "format": "date-time" + }, + "updated_at": { + "title": "Updated At", + "type": "string", + "description": "Date and time when the organization was last updated/modified (ISO_8601 format).", + "format": "date-time" + }, + "name": { + "title": "Name", + "type": "string", + "description": "The name of the organization, usually it's your company's name." + }, + "settings": { + "title": "Settings", + "type": "object", + "description": "the settings for this project" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/organizationreadwithapikey.json b/schemas/organizationreadwithapikey.json new file mode 100644 index 0000000..b75e711 --- /dev/null +++ b/schemas/organizationreadwithapikey.json @@ -0,0 +1,55 @@ +{ + "title": "OrganizationReadWithAPIKey", + "required": [ + "key", + "id", + "created_at", + "updated_at", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "type": "string", + "description": "A URL-friendly name of the organization (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the organization." + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the organization" + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the organization was created (ISO_8601 format).", + "format": "date-time" + }, + "updated_at": { + "title": "Updated At", + "type": "string", + "description": "Date and time when the organization was last updated/modified (ISO_8601 format).", + "format": "date-time" + }, + "name": { + "title": "Name", + "type": "string", + "description": "The name of the organization, usually it's your company's name." + }, + "settings": { + "title": "Settings", + "type": "object", + "description": "the settings for this project" + }, + "api_key_id": { + "title": "Api Key Id", + "type": "string" + }, + "api_key_secret": { + "title": "Api Key Secret", + "type": "string" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/organizationupdate.json b/schemas/organizationupdate.json new file mode 100644 index 0000000..e33a232 --- /dev/null +++ b/schemas/organizationupdate.json @@ -0,0 +1,19 @@ +{ + "title": "OrganizationUpdate", + "type": "object", + "properties": { + "name": { + "title": "Name", + "pattern": "^[A-Za-z0-9\\.\\-\\_\\ ]+$", + "type": "string", + "description": "The name of the organization, usually it's your company's name." + }, + "settings": { + "title": "Settings", + "type": "object", + "description": "the settings for this project" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/paginatedresult_userread_.json b/schemas/paginatedresult_userread_.json new file mode 100644 index 0000000..3d33a09 --- /dev/null +++ b/schemas/paginatedresult_userread_.json @@ -0,0 +1,30 @@ +{ + "title": "PaginatedResult[UserRead]", + "required": [ + "data", + "total_count" + ], + "type": "object", + "properties": { + "data": { + "title": "Data", + "type": "array", + "items": { + "$ref": "UserRead.json" + } + }, + "total_count": { + "title": "Total Count", + "minimum": 0.0, + "type": "integer" + }, + "page_count": { + "title": "Page Count", + "minimum": 0.0, + "type": "integer", + "default": 0 + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/pdpconfigread.json b/schemas/pdpconfigread.json new file mode 100644 index 0000000..9d8d4f7 --- /dev/null +++ b/schemas/pdpconfigread.json @@ -0,0 +1,42 @@ +{ + "title": "PDPConfigRead", + "required": [ + "id", + "organization_id", + "project_id", + "environment_id", + "client_secret" + ], + "type": "object", + "properties": { + "id": { + "title": "Id", + "type": "string" + }, + "name": { + "title": "Name", + "type": "string" + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the pdp_config belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the pdp_config belongs to." + }, + "environment_id": { + "title": "Environment Id", + "type": "string", + "description": "Unique id of the environment that the pdp_config belongs to." + }, + "client_secret": { + "title": "Client Secret", + "type": "string" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/projectcreate.json b/schemas/projectcreate.json new file mode 100644 index 0000000..21652ca --- /dev/null +++ b/schemas/projectcreate.json @@ -0,0 +1,44 @@ +{ + "title": "ProjectCreate", + "required": [ + "key", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "pattern": "^[A-Za-z0-9\\-_]+$", + "type": "string", + "description": "A URL-friendly name of the project (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the project." + }, + "urn_namespace": { + "title": "Urn Namespace", + "pattern": "[a-z0-9-]{2,}", + "type": "string", + "description": "Optional namespace for URNs. If empty, URNs will be generated from project key." + }, + "name": { + "title": "Name", + "type": "string", + "description": "The name of the project" + }, + "description": { + "title": "Description", + "type": "string", + "description": "a longer description outlining the project objectives" + }, + "settings": { + "title": "Settings", + "type": "object", + "description": "the settings for this project" + }, + "active_policy_repo_id": { + "title": "Active Policy Repo Id", + "type": "string", + "description": "the id of the policy repo to use for this project" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/projectread.json b/schemas/projectread.json new file mode 100644 index 0000000..d41005a --- /dev/null +++ b/schemas/projectread.json @@ -0,0 +1,69 @@ +{ + "title": "ProjectRead", + "required": [ + "key", + "id", + "organization_id", + "created_at", + "updated_at", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "type": "string", + "description": "A URL-friendly name of the project (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the project." + }, + "urn_namespace": { + "title": "Urn Namespace", + "pattern": "[a-z0-9-]{2,}", + "type": "string", + "description": "Optional namespace for URNs. If empty, URNs will be generated from project key." + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the project" + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the project belongs to." + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the project was created (ISO_8601 format).", + "format": "date-time" + }, + "updated_at": { + "title": "Updated At", + "type": "string", + "description": "Date and time when the project was last updated/modified (ISO_8601 format).", + "format": "date-time" + }, + "name": { + "title": "Name", + "type": "string", + "description": "The name of the project" + }, + "description": { + "title": "Description", + "type": "string", + "description": "a longer description outlining the project objectives" + }, + "settings": { + "title": "Settings", + "type": "object", + "description": "the settings for this project" + }, + "active_policy_repo_id": { + "title": "Active Policy Repo Id", + "type": "string", + "description": "the id of the policy repo to use for this project" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/projectupdate.json b/schemas/projectupdate.json new file mode 100644 index 0000000..300f0d9 --- /dev/null +++ b/schemas/projectupdate.json @@ -0,0 +1,28 @@ +{ + "title": "ProjectUpdate", + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "The name of the project" + }, + "description": { + "title": "Description", + "type": "string", + "description": "a longer description outlining the project objectives" + }, + "settings": { + "title": "Settings", + "type": "object", + "description": "the settings for this project" + }, + "active_policy_repo_id": { + "title": "Active Policy Repo Id", + "type": "string", + "description": "the id of the policy repo to use for this project" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/relationsblock.json b/schemas/relationsblock.json new file mode 100644 index 0000000..01db265 --- /dev/null +++ b/schemas/relationsblock.json @@ -0,0 +1,7 @@ +{ + "title": "RelationsBlock", + "type": "object", + "additionalProperties": false, + "description": "A actions definition block, typically contained within a resource type definition block.\nThe actions represents the ways you can interact with a protected resource.", + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/removerolepermissions.json b/schemas/removerolepermissions.json new file mode 100644 index 0000000..b9f4f1f --- /dev/null +++ b/schemas/removerolepermissions.json @@ -0,0 +1,24 @@ +{ + "title": "RemoveRolePermissions", + "required": [ + "permissions" + ], + "type": "object", + "properties": { + "permissions": { + "title": "Permissions", + "type": "array", + "items": { + "type": "string" + }, + "description": "List of permissions to remove from the role. If a permission is not found it is skipped. Each permission can be either a resource action id, or `{resource_key}:{action_key}`,i.e: the \"permission name\"." + } + }, + "additionalProperties": false, + "example": { + "permissions": [ + "document:share" + ] + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourceactioncreate.json b/schemas/resourceactioncreate.json new file mode 100644 index 0000000..6aa5bc3 --- /dev/null +++ b/schemas/resourceactioncreate.json @@ -0,0 +1,33 @@ +{ + "title": "ResourceActionCreate", + "required": [ + "key", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "pattern": "^[A-Za-z0-9\\-_]+$", + "type": "string", + "description": "A URL-friendly name of the action (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the action." + }, + "name": { + "title": "Name", + "type": "string", + "description": "The name of the action" + }, + "description": { + "title": "Description", + "type": "string", + "description": "An optional longer description of what this action respresents in your system" + } + }, + "additionalProperties": false, + "example": { + "key": "read", + "name": "read", + "description": "read a document" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourceactionread.json b/schemas/resourceactionread.json new file mode 100644 index 0000000..169cf87 --- /dev/null +++ b/schemas/resourceactionread.json @@ -0,0 +1,90 @@ +{ + "title": "ResourceActionRead", + "required": [ + "name", + "key", + "id", + "permission_name", + "organization_id", + "project_id", + "environment_id", + "resource_id", + "created_at", + "updated_at" + ], + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "The name of the action" + }, + "description": { + "title": "Description", + "type": "string", + "description": "An optional longer description of what this action respresents in your system" + }, + "key": { + "title": "Key", + "type": "string", + "description": "A URL-friendly name of the action (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the action." + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the action" + }, + "permission_name": { + "title": "Permission Name", + "type": "string", + "description": "The name of the action, prefixed by the resource the action is acting upon." + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the action belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the action belongs to." + }, + "environment_id": { + "title": "Environment Id", + "type": "string", + "description": "Unique id of the environment that the action belongs to." + }, + "resource_id": { + "title": "Resource Id", + "type": "string", + "description": "Unique id of the resource that the action belongs to." + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the action was created (ISO_8601 format).", + "format": "date-time" + }, + "updated_at": { + "title": "Updated At", + "type": "string", + "description": "Date and time when the action was last updated/modified (ISO_8601 format).", + "format": "date-time" + } + }, + "additionalProperties": false, + "example": { + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "key": "read", + "name": "read", + "permission_name": "document:read", + "description": "read a document", + "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "environment_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "resource_id": "40ef0e48-a11f-4963-a229-e396c9f7e7dd", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourceactionupdate.json b/schemas/resourceactionupdate.json new file mode 100644 index 0000000..1d3d033 --- /dev/null +++ b/schemas/resourceactionupdate.json @@ -0,0 +1,21 @@ +{ + "title": "ResourceActionUpdate", + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "The name of the action" + }, + "description": { + "title": "Description", + "type": "string", + "description": "An optional longer description of what this action respresents in your system" + } + }, + "additionalProperties": false, + "example": { + "description": "read a document" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourceattributecreate.json b/schemas/resourceattributecreate.json new file mode 100644 index 0000000..53d767e --- /dev/null +++ b/schemas/resourceattributecreate.json @@ -0,0 +1,31 @@ +{ + "title": "ResourceAttributeCreate", + "required": [ + "key", + "type" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "pattern": "^[A-Za-z0-9\\-_]+$", + "type": "string", + "description": "A URL-friendly name of the attribute (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the attribute." + }, + "type": { + "existingJavaType": "io.permit.sdk.openapi.models.AttributeType" + }, + "description": { + "title": "Description", + "type": "string", + "description": "An optional longer description of what this attribute respresents in your system" + } + }, + "additionalProperties": false, + "example": { + "key": "private", + "type": "bool", + "description": "whether or not the github repository is private" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourceattributeread.json b/schemas/resourceattributeread.json new file mode 100644 index 0000000..23dec7e --- /dev/null +++ b/schemas/resourceattributeread.json @@ -0,0 +1,88 @@ +{ + "title": "ResourceAttributeRead", + "required": [ + "type", + "key", + "id", + "resource_id", + "resource_key", + "organization_id", + "project_id", + "environment_id", + "created_at", + "updated_at" + ], + "type": "object", + "properties": { + "type": { + "existingJavaType": "io.permit.sdk.openapi.models.AttributeType" + }, + "description": { + "title": "Description", + "type": "string", + "description": "An optional longer description of what this attribute respresents in your system" + }, + "key": { + "title": "Key", + "type": "string", + "description": "A URL-friendly name of the attribute (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the attribute." + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the attribute" + }, + "resource_id": { + "title": "Resource Id", + "type": "string", + "description": "Unique id of the resource that the attribute belongs to." + }, + "resource_key": { + "title": "Resource Key", + "type": "string", + "description": "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." + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the attribute belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the attribute belongs to." + }, + "environment_id": { + "title": "Environment Id", + "type": "string", + "description": "Unique id of the environment that the attribute belongs to." + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the attribute was created (ISO_8601 format).", + "format": "date-time" + }, + "updated_at": { + "title": "Updated At", + "type": "string", + "description": "Date and time when the attribute was last updated/modified (ISO_8601 format).", + "format": "date-time" + } + }, + "additionalProperties": false, + "example": { + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "key": "private", + "type": "bool", + "description": "whether or not the github repository is private", + "resource_id": "40ef0e48-a11f-4963-a229-e396c9f7e7dd", + "resource_key": "repository", + "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "environment_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourceattributeupdate.json b/schemas/resourceattributeupdate.json new file mode 100644 index 0000000..021e82e --- /dev/null +++ b/schemas/resourceattributeupdate.json @@ -0,0 +1,19 @@ +{ + "title": "ResourceAttributeUpdate", + "type": "object", + "properties": { + "type": { + "existingJavaType": "io.permit.sdk.openapi.models.AttributeType" + }, + "description": { + "title": "Description", + "type": "string", + "description": "An optional longer description of what this attribute respresents in your system" + } + }, + "additionalProperties": false, + "example": { + "description": "whether or not the github repository is private" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourcecreate.json b/schemas/resourcecreate.json new file mode 100644 index 0000000..f298ebf --- /dev/null +++ b/schemas/resourcecreate.json @@ -0,0 +1,82 @@ +{ + "title": "ResourceCreate", + "required": [ + "key", + "name", + "actions" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "pattern": "^[A-Za-z0-9\\-_]+$", + "type": "string", + "description": "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": { + "title": "Name", + "type": "string", + "description": "The name of the resource" + }, + "urn": { + "title": "Urn", + "type": "string", + "description": "The [URN](https://en.wikipedia.org/wiki/Uniform_Resource_Name) (Uniform Resource Name) of the resource" + }, + "description": { + "title": "Description", + "type": "string", + "description": "An optional longer description of what this resource respresents in your system" + }, + "actions": { + "title": "Actions", + "existingJavaType": "java.util.HashMap", + "description": "\n A actions definition block, typically contained within a resource type definition block.\n The actions represents the ways you can interact with a protected resource.\n " + }, + "attributes": { + "title": "Attributes", + "existingJavaType": "java.util.HashMap", + "description": "Attributes that each resource of this type defines, and can be used in your ABAC policies." + } + }, + "additionalProperties": false, + "example": { + "key": "repository", + "name": "Repository", + "actions": { + "clone": {}, + "read": {}, + "push": {} + }, + "roles": { + "contributor": { + "permissions": [ + "read" + ], + "description": "the contributor role can only read from the repo" + }, + "maintainer": { + "permissions": [ + "push" + ], + "extends": [ + "contributor" + ] + } + }, + "relations": { + "parent": "Organization" + }, + "attributes": { + "created": { + "type": "time", + "description": "the time (timestamp) the repository was created" + }, + "private": { + "type": "bool", + "description": "whether the repo is private (if false, the repo is public)" + } + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourceinstancecreate.json b/schemas/resourceinstancecreate.json new file mode 100644 index 0000000..9079c4e --- /dev/null +++ b/schemas/resourceinstancecreate.json @@ -0,0 +1,44 @@ +{ + "title": "ResourceInstanceCreate", + "required": [ + "key", + "resource" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "pattern": "^[A-Za-z0-9\\-_]+$", + "type": "string", + "description": "A unique identifier by which Permit will identify the resource instance for permission checks. You will later pass this identifier to the `permit.check()` API. A key can be anything: for example the resource db id, a url slug, a UUID or anything else as long as it's unique on your end. The resource instance key must be url-friendly." + }, + "tenant": { + "title": "Tenant", + "type": "string", + "description": "the *key* of the tenant that this resource belongs to, used to enforce tenant boundaries in multi-tenant apps." + }, + "resource": { + "title": "Resource", + "type": "string", + "description": "the *key* of the resource (type) of this resource instance. For example: if this resource instance is the annual budget document, the key of the resource might be `document`." + }, + "attributes": { + "title": "Attributes", + "type": "object", + "description": "Arbitraty resource attributes that will be used to enforce attribute-based access control policies.", + "default": {}, + "existingJavaType": "java.util.HashMap" + } + }, + "additionalProperties": false, + "example": { + "key": "react", + "resource": "repository", + "tenant": "default", + "attributes": { + "private": "false", + "owner": "facebook" + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourceinstanceread.json b/schemas/resourceinstanceread.json new file mode 100644 index 0000000..80c63e6 --- /dev/null +++ b/schemas/resourceinstanceread.json @@ -0,0 +1,100 @@ +{ + "title": "ResourceInstanceRead", + "required": [ + "key", + "resource", + "id", + "organization_id", + "project_id", + "environment_id", + "created_at", + "updated_at", + "resource_id" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "type": "string", + "description": "A unique identifier by which Permit will identify the resource instance for permission checks. You will later pass this identifier to the `permit.check()` API. A key can be anything: for example the resource db id, a url slug, a UUID or anything else as long as it's unique on your end. The resource instance key must be url-friendly." + }, + "tenant": { + "title": "Tenant", + "type": "string", + "description": "the *key* of the tenant that this resource belongs to, used to enforce tenant boundaries in multi-tenant apps." + }, + "resource": { + "title": "Resource", + "type": "string", + "description": "the *key* of the resource (type) of this resource instance. For example: if this resource instance is the annual budget document, the key of the resource might be `document`." + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the resource instance" + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the resource instance belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the resource instance belongs to." + }, + "environment_id": { + "title": "Environment Id", + "type": "string", + "description": "Unique id of the environment that the resource instance belongs to." + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the resource instance was created (ISO_8601 format).", + "format": "date-time" + }, + "updated_at": { + "title": "Updated At", + "type": "string", + "description": "Date and time when the resource instance was last updated/modified (ISO_8601 format).", + "format": "date-time" + }, + "resource_id": { + "title": "Resource Id", + "type": "string", + "description": "the id of the resource (type) of this resource instance." + }, + "tenant_id": { + "title": "Tenant Id", + "type": "string", + "description": "the id of the tenant of this resource instance." + }, + "attributes": { + "title": "Attributes", + "type": "object", + "description": "Arbitraty resource attributes that will be used to enforce attribute-based access control policies.", + "default": {}, + "existingJavaType": "java.util.HashMap" + } + }, + "additionalProperties": false, + "example": { + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "environment_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "resource_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c5", + "tenant_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c3", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z", + "key": "react", + "resource": "repository", + "tenant": "default", + "attributes": { + "private": "false", + "owner": "facebook" + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourceinstanceupdate.json b/schemas/resourceinstanceupdate.json new file mode 100644 index 0000000..dcdd4f5 --- /dev/null +++ b/schemas/resourceinstanceupdate.json @@ -0,0 +1,20 @@ +{ + "title": "ResourceInstanceUpdate", + "type": "object", + "properties": { + "attributes": { + "title": "Attributes", + "type": "object", + "description": "Arbitraty resource attributes that will be used to enforce attribute-based access control policies.", + "default": {} + } + }, + "additionalProperties": false, + "example": { + "attributes": { + "private": "false", + "owner": "facebook" + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourceread.json b/schemas/resourceread.json new file mode 100644 index 0000000..baca926 --- /dev/null +++ b/schemas/resourceread.json @@ -0,0 +1,134 @@ +{ + "title": "ResourceRead", + "required": [ + "key", + "id", + "organization_id", + "project_id", + "environment_id", + "created_at", + "updated_at", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "type": "string", + "description": "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." + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the resource" + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the resource belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the resource belongs to." + }, + "environment_id": { + "title": "Environment Id", + "type": "string", + "description": "Unique id of the environment that the resource belongs to." + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the resource was created (ISO_8601 format).", + "format": "date-time" + }, + "updated_at": { + "title": "Updated At", + "type": "string", + "description": "Date and time when the resource was last updated/modified (ISO_8601 format).", + "format": "date-time" + }, + "name": { + "title": "Name", + "type": "string", + "description": "The name of the resource" + }, + "urn": { + "title": "Urn", + "type": "string", + "description": "The [URN](https://en.wikipedia.org/wiki/Uniform_Resource_Name) (Uniform Resource Name) of the resource" + }, + "description": { + "title": "Description", + "type": "string", + "description": "An optional longer description of what this resource respresents in your system" + }, + "actions": { + "title": "Actions", + "existingJavaType": "java.util.HashMap", + "description": "\n A actions definition block, typically contained within a resource type definition block.\n The actions represents the ways you can interact with a protected resource.\n " + }, + "attributes": { + "title": "Attributes", + "existingJavaType": "java.util.HashMap", + "description": "Attributes that each resource of this type defines, and can be used in your ABAC policies." + } + }, + "additionalProperties": false, + "example": { + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "environment_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z", + "key": "repository", + "name": "Repository", + "urn": "prn:github:scm:repository", + "description": "a git repository stored on github", + "actions": { + "clone": { + "id": "90e21d70-2b1b-42f0-b492-8fd69c1d79d1" + }, + "read": { + "id": "2bc27751-6115-43c0-b68c-928cb46e34bc" + }, + "push": { + "id": "e06da336-6e03-41d6-a495-40b0d7537b2a" + } + }, + "roles": { + "contributor": { + "permissions": [ + "read" + ], + "description": "the contributor role can only read from the repo" + }, + "maintainer": { + "permissions": [ + "push" + ], + "extends": [ + "contributor" + ] + } + }, + "relations": { + "parent": "Organization" + }, + "attributes": { + "created": { + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f11", + "type": "time", + "description": "the time (timestamp) the repository was created" + }, + "private": { + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f22", + "type": "bool", + "description": "whether the repo is private (if false, the repo is public)" + } + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourcereplace.json b/schemas/resourcereplace.json new file mode 100644 index 0000000..34b7cb6 --- /dev/null +++ b/schemas/resourcereplace.json @@ -0,0 +1,37 @@ +{ + "title": "ResourceReplace", + "required": [ + "name", + "actions" + ], + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "The name of the resource" + }, + "urn": { + "title": "Urn", + "type": "string", + "description": "The [URN](https://en.wikipedia.org/wiki/Uniform_Resource_Name) (Uniform Resource Name) of the resource" + }, + "description": { + "title": "Description", + "type": "string", + "description": "An optional longer description of what this resource respresents in your system" + }, + "actions": { + "title": "Actions", + "existingJavaType": "java.util.HashMap", + "description": "\n A actions definition block, typically contained within a resource type definition block.\n The actions represents the ways you can interact with a protected resource.\n " + }, + "attributes": { + "title": "Attributes", + "existingJavaType": "java.util.HashMap", + "description": "Attributes that each resource of this type defines, and can be used in your ABAC policies." + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourcerolecreate.json b/schemas/resourcerolecreate.json new file mode 100644 index 0000000..30c264b --- /dev/null +++ b/schemas/resourcerolecreate.json @@ -0,0 +1,55 @@ +{ + "title": "ResourceRoleCreate", + "required": [ + "key", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "pattern": "^[A-Za-z0-9\\-_]+$", + "type": "string", + "description": "A URL-friendly name of the role (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the role." + }, + "name": { + "title": "Name", + "type": "string", + "description": "The name of the role" + }, + "description": { + "title": "Description", + "type": "string", + "description": "optional description string explaining what this role represents, or what permissions are granted to it." + }, + "permissions": { + "title": "Permissions", + "type": "array", + "items": { + "type": "string" + }, + "description": "list of action keys that define what actions this resource role is permitted to do" + }, + "extends": { + "title": "Extends", + "type": "array", + "items": { + "type": "string" + }, + "description": "list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list." + } + }, + "additionalProperties": false, + "example": { + "key": "maintainer", + "name": "Maintainer", + "description": "the maintainer role can read from the repo and push changes", + "permissions": [ + "push" + ], + "extends": [ + "contributor" + ] + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourceroleread.json b/schemas/resourceroleread.json new file mode 100644 index 0000000..bab6f12 --- /dev/null +++ b/schemas/resourceroleread.json @@ -0,0 +1,105 @@ +{ + "title": "ResourceRoleRead", + "required": [ + "name", + "key", + "id", + "organization_id", + "project_id", + "environment_id", + "resource_id", + "created_at", + "updated_at" + ], + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "The name of the role" + }, + "description": { + "title": "Description", + "type": "string", + "description": "optional description string explaining what this role represents, or what permissions are granted to it." + }, + "permissions": { + "title": "Permissions", + "type": "array", + "items": { + "type": "string" + }, + "description": "list of action keys that define what actions this resource role is permitted to do" + }, + "extends": { + "title": "Extends", + "type": "array", + "items": { + "type": "string" + }, + "description": "list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list." + }, + "key": { + "title": "Key", + "type": "string", + "description": "A URL-friendly name of the role (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the role." + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the role" + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the role belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the role belongs to." + }, + "environment_id": { + "title": "Environment Id", + "type": "string", + "description": "Unique id of the environment that the role belongs to." + }, + "resource_id": { + "title": "Resource Id", + "type": "string", + "description": "Unique id of the resource that the role belongs to." + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the role was created (ISO_8601 format).", + "format": "date-time" + }, + "updated_at": { + "title": "Updated At", + "type": "string", + "description": "Date and time when the role was last updated/modified (ISO_8601 format).", + "format": "date-time" + } + }, + "additionalProperties": false, + "example": { + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "key": "maintainer", + "name": "Maintainer", + "description": "the maintainer role can read from the repo and push changes", + "permissions": [ + "push" + ], + "extends": [ + "contributor" + ], + "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "environment_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "resource_id": "40ef0e48-a11f-4963-a229-e396c9f7e7dd", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourceroleupdate.json b/schemas/resourceroleupdate.json new file mode 100644 index 0000000..3e9e706 --- /dev/null +++ b/schemas/resourceroleupdate.json @@ -0,0 +1,40 @@ +{ + "title": "ResourceRoleUpdate", + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "The name of the role" + }, + "description": { + "title": "Description", + "type": "string", + "description": "optional description string explaining what this role represents, or what permissions are granted to it." + }, + "permissions": { + "title": "Permissions", + "type": "array", + "items": { + "type": "string" + }, + "description": "list of action keys that define what actions this resource role is permitted to do" + }, + "extends": { + "title": "Extends", + "type": "array", + "items": { + "type": "string" + }, + "description": "list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list." + } + }, + "additionalProperties": false, + "example": { + "description": "the maintainer role can read from the repo and push changes", + "permissions": [ + "push" + ] + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/resourceupdate.json b/schemas/resourceupdate.json new file mode 100644 index 0000000..615bd9f --- /dev/null +++ b/schemas/resourceupdate.json @@ -0,0 +1,33 @@ +{ + "title": "ResourceUpdate", + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "The name of the resource" + }, + "urn": { + "title": "Urn", + "type": "string", + "description": "The [URN](https://en.wikipedia.org/wiki/Uniform_Resource_Name) (Uniform Resource Name) of the resource" + }, + "description": { + "title": "Description", + "type": "string", + "description": "An optional longer description of what this resource respresents in your system" + }, + "actions": { + "title": "Actions", + "existingJavaType": "java.util.HashMap", + "description": "\n A actions definition block, typically contained within a resource type definition block.\n The actions represents the ways you can interact with a protected resource.\n " + }, + "attributes": { + "title": "Attributes", + "existingJavaType": "java.util.HashMap", + "description": "Attributes that each resource of this type defines, and can be used in your ABAC policies." + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/roleassignmentcreate.json b/schemas/roleassignmentcreate.json new file mode 100644 index 0000000..7b247f9 --- /dev/null +++ b/schemas/roleassignmentcreate.json @@ -0,0 +1,33 @@ +{ + "title": "RoleAssignmentCreate", + "required": [ + "role", + "tenant", + "user" + ], + "type": "object", + "properties": { + "role": { + "title": "Role", + "type": "string", + "description": "the role that will be assigned (accepts either the role id or the role key)" + }, + "tenant": { + "title": "Tenant", + "type": "string", + "description": "the tenant the role is associated with (accepts either the tenant id or the tenant key)" + }, + "user": { + "title": "User", + "type": "string", + "description": "the user the role will be assigned to (accepts either the user id or the user key)" + } + }, + "additionalProperties": false, + "example": { + "user": "jane@coolcompany.com", + "role": "admin", + "tenant": "stripe-inc" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/roleassignmentread.json b/schemas/roleassignmentread.json new file mode 100644 index 0000000..ac79a64 --- /dev/null +++ b/schemas/roleassignmentread.json @@ -0,0 +1,90 @@ +{ + "title": "RoleAssignmentRead", + "required": [ + "id", + "user", + "role", + "tenant", + "user_id", + "role_id", + "tenant_id", + "organization_id", + "project_id", + "environment_id", + "created_at" + ], + "type": "object", + "properties": { + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the role assignment" + }, + "user": { + "title": "User", + "type": "string", + "description": "the user the role is assigned to" + }, + "role": { + "title": "Role", + "type": "string", + "description": "the role that is assigned" + }, + "tenant": { + "title": "Tenant", + "type": "string", + "description": "the tenant the role is associated with" + }, + "user_id": { + "title": "User Id", + "type": "string", + "description": "Unique id of the user" + }, + "role_id": { + "title": "Role Id", + "type": "string", + "description": "Unique id of the role" + }, + "tenant_id": { + "title": "Tenant Id", + "type": "string", + "description": "Unique id of the tenant" + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the role assignment belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the role assignment belongs to." + }, + "environment_id": { + "title": "Environment Id", + "type": "string", + "description": "Unique id of the environment that the role assignment belongs to." + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the role assignment was created (ISO_8601 format).", + "format": "date-time" + } + }, + "additionalProperties": false, + "example": { + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "user": "jane@coolcompany.com", + "role": "admin", + "tenant": "stripe-inc", + "user_id": "7c60d51f-b44e-4682-87d6-449835ea4d11", + "role_id": "405d8375-3514-403b-8c43-83ae74cfe022", + "tenant_id": "40ef0e48-a11f-4963-a229-e396c9f7e733", + "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "environment_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "created_at": "2019-08-24T14:15:22Z" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/roleassignmentremove.json b/schemas/roleassignmentremove.json new file mode 100644 index 0000000..13e6a2a --- /dev/null +++ b/schemas/roleassignmentremove.json @@ -0,0 +1,33 @@ +{ + "title": "RoleAssignmentRemove", + "required": [ + "role", + "tenant", + "user" + ], + "type": "object", + "properties": { + "role": { + "title": "Role", + "type": "string", + "description": "the role that will be unassigned (accepts either the role id or the role key)" + }, + "tenant": { + "title": "Tenant", + "type": "string", + "description": "the tenant the role is associated with (accepts either the tenant id or the tenant key)" + }, + "user": { + "title": "User", + "type": "string", + "description": "the user the role will be unassigned from (accepts either the user id or the user key)" + } + }, + "additionalProperties": false, + "example": { + "user": "jane@coolcompany.com", + "role": "editor", + "tenant": "google-inc" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/roleblock.json b/schemas/roleblock.json new file mode 100644 index 0000000..80c3f67 --- /dev/null +++ b/schemas/roleblock.json @@ -0,0 +1,29 @@ +{ + "title": "RoleBlock", + "type": "object", + "properties": { + "description": { + "title": "Description", + "type": "string", + "description": "optional description string explaining what this role represents, or what permissions are granted to it." + }, + "permissions": { + "title": "Permissions", + "type": "array", + "items": { + "type": "string" + }, + "description": "list of action keys that define what actions this resource role is permitted to do" + }, + "extends": { + "title": "Extends", + "type": "array", + "items": { + "type": "string" + }, + "description": "list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list." + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/rolecreate.json b/schemas/rolecreate.json new file mode 100644 index 0000000..dd9fb46 --- /dev/null +++ b/schemas/rolecreate.json @@ -0,0 +1,55 @@ +{ + "title": "RoleCreate", + "required": [ + "key", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "pattern": "^[A-Za-z0-9\\-_]+$", + "type": "string", + "description": "A URL-friendly name of the role (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the role." + }, + "name": { + "title": "Name", + "type": "string", + "description": "The name of the role" + }, + "description": { + "title": "Description", + "type": "string", + "description": "optional description string explaining what this role represents, or what permissions are granted to it." + }, + "permissions": { + "title": "Permissions", + "type": "array", + "items": { + "type": "string" + }, + "description": "list of action keys that define what actions this resource role is permitted to do" + }, + "extends": { + "title": "Extends", + "type": "array", + "items": { + "type": "string" + }, + "description": "list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list." + } + }, + "additionalProperties": false, + "example": { + "key": "editor", + "name": "Editor", + "description": "the editor role can read and write to documents", + "permissions": [ + "document:write" + ], + "extends": [ + "viewer" + ] + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/roleread.json b/schemas/roleread.json new file mode 100644 index 0000000..d9ebe30 --- /dev/null +++ b/schemas/roleread.json @@ -0,0 +1,98 @@ +{ + "title": "RoleRead", + "required": [ + "name", + "key", + "id", + "organization_id", + "project_id", + "environment_id", + "created_at", + "updated_at" + ], + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "The name of the role" + }, + "description": { + "title": "Description", + "type": "string", + "description": "optional description string explaining what this role represents, or what permissions are granted to it." + }, + "permissions": { + "title": "Permissions", + "type": "array", + "items": { + "type": "string" + }, + "description": "list of action keys that define what actions this resource role is permitted to do" + }, + "extends": { + "title": "Extends", + "type": "array", + "items": { + "type": "string" + }, + "description": "list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list." + }, + "key": { + "title": "Key", + "type": "string", + "description": "A URL-friendly name of the role (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the role." + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the role" + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the role belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the role belongs to." + }, + "environment_id": { + "title": "Environment Id", + "type": "string", + "description": "Unique id of the environment that the role belongs to." + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the role was created (ISO_8601 format).", + "format": "date-time" + }, + "updated_at": { + "title": "Updated At", + "type": "string", + "description": "Date and time when the role was last updated/modified (ISO_8601 format).", + "format": "date-time" + } + }, + "additionalProperties": false, + "example": { + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "key": "editor", + "name": "Editor", + "description": "the editor role can read and write to documents", + "permissions": [ + "document:write" + ], + "extends": [ + "viewer" + ], + "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "environment_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/rolesblock.json b/schemas/rolesblock.json new file mode 100644 index 0000000..153a0ee --- /dev/null +++ b/schemas/rolesblock.json @@ -0,0 +1,7 @@ +{ + "title": "RolesBlock", + "type": "object", + "additionalProperties": false, + "description": "Resource roles definition block, defines all the roles on the resource.", + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/roleupdate.json b/schemas/roleupdate.json new file mode 100644 index 0000000..1142b2f --- /dev/null +++ b/schemas/roleupdate.json @@ -0,0 +1,40 @@ +{ + "title": "RoleUpdate", + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "The name of the role" + }, + "description": { + "title": "Description", + "type": "string", + "description": "optional description string explaining what this role represents, or what permissions are granted to it." + }, + "permissions": { + "title": "Permissions", + "type": "array", + "items": { + "type": "string" + }, + "description": "list of action keys that define what actions this resource role is permitted to do" + }, + "extends": { + "title": "Extends", + "type": "array", + "items": { + "type": "string" + }, + "description": "list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list." + } + }, + "additionalProperties": false, + "example": { + "description": "the editor role can read and write to documents", + "permissions": [ + "document:write" + ] + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/statistics.json b/schemas/statistics.json new file mode 100644 index 0000000..fee1067 --- /dev/null +++ b/schemas/statistics.json @@ -0,0 +1,45 @@ +{ + "title": "Statistics", + "required": [ + "roles", + "users", + "policies", + "resources", + "tenants", + "has_decision_logs" + ], + "type": "object", + "properties": { + "roles": { + "title": "Roles", + "minimum": 0.0, + "type": "integer" + }, + "users": { + "title": "Users", + "minimum": 0.0, + "type": "integer" + }, + "policies": { + "title": "Policies", + "minimum": 0.0, + "type": "integer" + }, + "resources": { + "title": "Resources", + "minimum": 0.0, + "type": "integer" + }, + "tenants": { + "title": "Tenants", + "minimum": 0.0, + "type": "integer" + }, + "has_decision_logs": { + "title": "Has Decision Logs", + "type": "boolean" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/tenantcreate.json b/schemas/tenantcreate.json new file mode 100644 index 0000000..31cf632 --- /dev/null +++ b/schemas/tenantcreate.json @@ -0,0 +1,45 @@ +{ + "title": "TenantCreate", + "required": [ + "key", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "pattern": "^[A-Za-z0-9\\-_]+$", + "type": "string", + "description": "A unique id by which Permit will identify the tenant. The tenant key must be url-friendly (slugified)." + }, + "name": { + "title": "Name", + "type": "string", + "description": "A descriptive name for the tenant" + }, + "description": { + "title": "Description", + "type": "string", + "description": "an optional longer description of the tenant" + }, + "attributes": { + "title": "Attributes", + "type": "object", + "description": "Arbitraty tenant attributes that will be used to enforce attribute-based access control policies.", + "default": {}, + "existingJavaType": "java.util.HashMap" + } + }, + "additionalProperties": false, + "example": { + "key": "stripeinc", + "name": "Stripe Inc", + "attributes": { + "allowed_locations": [ + "US", + "CA" + ] + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/tenantread.json b/schemas/tenantread.json new file mode 100644 index 0000000..7986662 --- /dev/null +++ b/schemas/tenantread.json @@ -0,0 +1,96 @@ +{ + "title": "TenantRead", + "required": [ + "key", + "id", + "organization_id", + "project_id", + "environment_id", + "created_at", + "updated_at", + "last_action_at", + "name" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "type": "string", + "description": "A unique id by which Permit will identify the tenant. The tenant key must be url-friendly (slugified)." + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the tenant" + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the tenant belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the tenant belongs to." + }, + "environment_id": { + "title": "Environment Id", + "type": "string", + "description": "Unique id of the environment that the tenant belongs to." + }, + "created_at": { + "title": "Created At", + "type": "string", + "description": "Date and time when the tenant was created (ISO_8601 format).", + "format": "date-time" + }, + "updated_at": { + "title": "Updated At", + "type": "string", + "description": "Date and time when the tenant was last updated/modified (ISO_8601 format).", + "format": "date-time" + }, + "last_action_at": { + "title": "Last Action At", + "type": "string", + "description": "Date and time when the tenant was last active (ISO_8601 format). In other words, this is the last time a permission check was done on a resource belonging to this tenant.", + "format": "date-time" + }, + "name": { + "title": "Name", + "type": "string", + "description": "A descriptive name for the tenant" + }, + "description": { + "title": "Description", + "type": "string", + "description": "an optional longer description of the tenant" + }, + "attributes": { + "title": "Attributes", + "type": "object", + "description": "Arbitraty tenant attributes that will be used to enforce attribute-based access control policies.", + "default": {}, + "existingJavaType": "java.util.HashMap" + } + }, + "additionalProperties": false, + "example": { + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "environment_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "created_at": "2019-08-24T14:15:22Z", + "updated_at": "2019-08-24T14:15:22Z", + "last_action_at": "2019-08-24T14:15:22Z", + "key": "stripeinc", + "name": "Stripe Inc", + "attributes": { + "allowed_locations": [ + "US", + "CA" + ] + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/tenantupdate.json b/schemas/tenantupdate.json new file mode 100644 index 0000000..ad9e545 --- /dev/null +++ b/schemas/tenantupdate.json @@ -0,0 +1,25 @@ +{ + "title": "TenantUpdate", + "type": "object", + "properties": { + "name": { + "title": "Name", + "type": "string", + "description": "A descriptive name for the tenant" + }, + "description": { + "title": "Description", + "type": "string", + "description": "an optional longer description of the tenant" + }, + "attributes": { + "title": "Attributes", + "type": "object", + "description": "Arbitraty tenant attributes that will be used to enforce attribute-based access control policies.", + "default": {}, + "existingJavaType": "java.util.HashMap" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/usercreate.json b/schemas/usercreate.json new file mode 100644 index 0000000..c5e4d14 --- /dev/null +++ b/schemas/usercreate.json @@ -0,0 +1,54 @@ +{ + "title": "UserCreate", + "required": [ + "key" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "pattern": "^[A-Za-z0-9|@+\\-\\._]+$", + "type": "string", + "description": "A unique id by which Permit will identify the user for permission checks." + }, + "email": { + "title": "Email", + "type": "string", + "description": "The email of the user. If synced, will be unique inside the environment.", + "format": "email" + }, + "first_name": { + "title": "First Name", + "type": "string", + "description": "First name of the user." + }, + "last_name": { + "title": "Last Name", + "type": "string", + "description": "Last name of the user." + }, + "attributes": { + "title": "Attributes", + "type": "object", + "description": "Arbitrary user attributes that will be used to enforce attribute-based access control policies.", + "default": {}, + "existingJavaType": "java.util.HashMap" + } + }, + "additionalProperties": false, + "example": { + "key": "user|892179821739812389327", + "email": "jane@coolcompany.com", + "first_name": "Jane", + "last_name": "Doe", + "attributes": { + "department": "marketing", + "age": 30, + "subscription": { + "tier": "pro", + "expired": false + } + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/userintenant.json b/schemas/userintenant.json new file mode 100644 index 0000000..4ac9b31 --- /dev/null +++ b/schemas/userintenant.json @@ -0,0 +1,29 @@ +{ + "title": "UserInTenant", + "required": [ + "tenant", + "roles", + "status" + ], + "type": "object", + "properties": { + "tenant": { + "title": "Tenant", + "type": "string", + "description": "The tenant key which the user is associated with" + }, + "roles": { + "title": "Roles", + "type": "array", + "items": { + "type": "string" + }, + "description": "List of roles assigned to the user in that tenant" + }, + "status": { + "$ref": "UserStatus.json" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/userloginrequestinput.json b/schemas/userloginrequestinput.json new file mode 100644 index 0000000..a2124c8 --- /dev/null +++ b/schemas/userloginrequestinput.json @@ -0,0 +1,21 @@ +{ + "title": "UserLoginRequestInput", + "required": [ + "user_id", + "tenant_id" + ], + "type": "object", + "properties": { + "user_id": { + "title": "User Id", + "type": "string", + "description": "ID or key of the user for whom to generate a token" + }, + "tenant_id": { + "title": "Tenant Id", + "type": "string", + "description": "ID or key of the tenant to which access is requested" + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/userread.json b/schemas/userread.json new file mode 100644 index 0000000..ff724b8 --- /dev/null +++ b/schemas/userread.json @@ -0,0 +1,124 @@ +{ + "title": "UserRead", + "required": [ + "key", + "id", + "organization_id", + "project_id", + "environment_id" + ], + "type": "object", + "properties": { + "key": { + "title": "Key", + "type": "string", + "description": "A unique id by which Permit will identify the user for permission checks." + }, + "id": { + "title": "Id", + "type": "string", + "description": "Unique id of the user" + }, + "organization_id": { + "title": "Organization Id", + "type": "string", + "description": "Unique id of the organization that the user belongs to." + }, + "project_id": { + "title": "Project Id", + "type": "string", + "description": "Unique id of the project that the user belongs to." + }, + "environment_id": { + "title": "Environment Id", + "type": "string", + "description": "Unique id of the environment that the user belongs to." + }, + "associated_tenants": { + "title": "Associated Tenants", + "type": "array", + "items": { + "$ref": "UserInTenant.json" + }, + "default": [] + }, + "roles": { + "title": "Roles", + "type": "array", + "items": { + "$ref": "UserRole.json" + }, + "default": [], + "deprecated": true + }, + "email": { + "title": "Email", + "type": "string", + "description": "The email of the user. If synced, will be unique inside the environment.", + "format": "email" + }, + "first_name": { + "title": "First Name", + "type": "string", + "description": "First name of the user." + }, + "last_name": { + "title": "Last Name", + "type": "string", + "description": "Last name of the user." + }, + "attributes": { + "title": "Attributes", + "type": "object", + "description": "Arbitrary user attributes that will be used to enforce attribute-based access control policies.", + "default": {}, + "existingJavaType": "java.util.HashMap" + } + }, + "additionalProperties": false, + "example": { + "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08", + "organization_id": "7c60d51f-b44e-4682-87d6-449835ea4de6", + "project_id": "405d8375-3514-403b-8c43-83ae74cfe0e9", + "environment_id": "40ef0e48-a11f-4963-a229-e396c9f7e7c4", + "key": "user|892179821739812389327", + "email": "jane@coolcompany.com", + "first_name": "Jane", + "last_name": "Doe", + "attributes": { + "department": "marketing", + "age": 30, + "subscription": { + "tier": "pro", + "expired": false + } + }, + "associated_tenants": [ + { + "tenant": "stripe-inc", + "roles": [ + "admin" + ], + "status": "active" + }, + { + "tenant": "othercompany.com", + "roles": [ + "viewer" + ], + "status": "pending" + } + ], + "roles": [ + { + "role": "admin", + "tenant": "stripe-inc" + }, + { + "role": "viewer", + "tenant": "othercompany.com" + } + ] + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/userrole.json b/schemas/userrole.json new file mode 100644 index 0000000..42062ca --- /dev/null +++ b/schemas/userrole.json @@ -0,0 +1,22 @@ +{ + "title": "UserRole", + "required": [ + "role", + "tenant" + ], + "type": "object", + "properties": { + "role": { + "title": "Role", + "type": "string", + "description": "the role that is assigned" + }, + "tenant": { + "title": "Tenant", + "type": "string", + "description": "the tenant the role is associated with" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/userrolecreate.json b/schemas/userrolecreate.json new file mode 100644 index 0000000..ff64d33 --- /dev/null +++ b/schemas/userrolecreate.json @@ -0,0 +1,26 @@ +{ + "title": "UserRoleCreate", + "required": [ + "role", + "tenant" + ], + "type": "object", + "properties": { + "role": { + "title": "Role", + "type": "string", + "description": "the role that will be assigned (accepts either the role id or the role key)" + }, + "tenant": { + "title": "Tenant", + "type": "string", + "description": "the tenant the role is associated with (accepts either the tenant id or the tenant key)" + } + }, + "additionalProperties": false, + "example": { + "role": "admin", + "tenant": "stripe-inc" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/userroleremove.json b/schemas/userroleremove.json new file mode 100644 index 0000000..b5d2ed4 --- /dev/null +++ b/schemas/userroleremove.json @@ -0,0 +1,26 @@ +{ + "title": "UserRoleRemove", + "required": [ + "role", + "tenant" + ], + "type": "object", + "properties": { + "role": { + "title": "Role", + "type": "string", + "description": "the role that will be unassigned (accepts either the role id or the role key)" + }, + "tenant": { + "title": "Tenant", + "type": "string", + "description": "the tenant the role is associated with (accepts either the tenant id or the tenant key)" + } + }, + "additionalProperties": false, + "example": { + "role": "editor", + "tenant": "google-inc" + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/userstatus.json b/schemas/userstatus.json new file mode 100644 index 0000000..a8650dc --- /dev/null +++ b/schemas/userstatus.json @@ -0,0 +1,10 @@ +{ + "title": "UserStatus", + "enum": [ + "active", + "pending" + ], + "type": "string", + "description": "Whether the user has signed in or not", + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/userupdate.json b/schemas/userupdate.json new file mode 100644 index 0000000..a07347c --- /dev/null +++ b/schemas/userupdate.json @@ -0,0 +1,31 @@ +{ + "title": "UserUpdate", + "type": "object", + "properties": { + "email": { + "title": "Email", + "type": "string", + "description": "The email of the user. If synced, will be unique inside the environment.", + "format": "email" + }, + "first_name": { + "title": "First Name", + "type": "string", + "description": "First name of the user." + }, + "last_name": { + "title": "Last Name", + "type": "string", + "description": "Last name of the user." + }, + "attributes": { + "title": "Attributes", + "type": "object", + "description": "Arbitrary user attributes that will be used to enforce attribute-based access control policies.", + "default": {}, + "existingJavaType": "java.util.HashMap" + } + }, + "additionalProperties": false, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/schemas/validationerror.json b/schemas/validationerror.json new file mode 100644 index 0000000..3d18676 --- /dev/null +++ b/schemas/validationerror.json @@ -0,0 +1,34 @@ +{ + "title": "ValidationError", + "required": [ + "loc", + "msg", + "type" + ], + "type": "object", + "properties": { + "loc": { + "title": "Location", + "type": "array", + "items": { + "anyOf": [ + { + "type": "string" + }, + { + "type": "integer" + } + ] + } + }, + "msg": { + "title": "Message", + "type": "string" + }, + "type": { + "title": "Error Type", + "type": "string" + } + }, + "$schema": "http://json-schema.org/schema#" +} \ No newline at end of file diff --git a/src/main/java/io/permit/sdk/ApiKeyLevel.java b/src/main/java/io/permit/sdk/ApiKeyLevel.java new file mode 100644 index 0000000..5bdb12a --- /dev/null +++ b/src/main/java/io/permit/sdk/ApiKeyLevel.java @@ -0,0 +1,8 @@ +package io.permit.sdk; + +public enum ApiKeyLevel { + WAIT_FOR_INIT, + ORGANIZATION_LEVEL_API_KEY, + PROJECT_LEVEL_API_KEY, + ENVIRONMENT_LEVEL_API_KEY, +} diff --git a/src/main/java/io/permit/sdk/Permit.java b/src/main/java/io/permit/sdk/Permit.java index 6ba1745..209f4e7 100644 --- a/src/main/java/io/permit/sdk/Permit.java +++ b/src/main/java/io/permit/sdk/Permit.java @@ -3,7 +3,7 @@ import com.google.gson.Gson; import com.google.gson.GsonBuilder; import io.permit.sdk.api.ApiClient; -import io.permit.sdk.api.ElementsClient; +import io.permit.sdk.api.ElementsApi; import io.permit.sdk.enforcement.Enforcer; import io.permit.sdk.enforcement.IEnforcerApi; import io.permit.sdk.enforcement.Resource; @@ -20,12 +20,12 @@ public class Permit implements IEnforcerApi { private final Enforcer enforcer; public final PermitConfig config; public final ApiClient api; - public final ElementsClient elements; + public final ElementsApi elements; public Permit(PermitConfig config) { this.config = config; this.api = new ApiClient(this.config); - this.elements = new ElementsClient(this.config); + this.elements = api.elements; this.enforcer = new Enforcer(this.config); if (this.config.isDebugMode()) { diff --git a/src/main/java/io/permit/sdk/PermitConfig.java b/src/main/java/io/permit/sdk/PermitConfig.java index dd61f32..b1f174f 100644 --- a/src/main/java/io/permit/sdk/PermitConfig.java +++ b/src/main/java/io/permit/sdk/PermitConfig.java @@ -22,6 +22,7 @@ public class PermitConfig { // multi tenancy config private final String defaultTenant; private final Boolean useDefaultTenantIfEmpty; + private PermitContext context; private PermitConfig(Builder builder) { this.token = builder.token; @@ -36,6 +37,7 @@ private PermitConfig(Builder builder) { this.autoMappingReviewMode = builder.autoMappingReviewMode; this.defaultTenant = builder.defaultTenant; this.useDefaultTenantIfEmpty = builder.useDefaultTenantIfEmpty; + this.context = builder.context; } // getters @@ -74,6 +76,14 @@ public Boolean shouldUseDefaultTenantIfEmpty() { return useDefaultTenantIfEmpty; } + public PermitContext getContext() { + return context; + } + + public void setContext(PermitContext context) { + this.context = context; + } + public static class Builder { // main config vars private String token; @@ -95,8 +105,11 @@ public static class Builder { private String defaultTenant = "default"; private Boolean useDefaultTenantIfEmpty = true; + private PermitContext context; + public Builder(String token) { this.token = token; + this.context = (new PermitContext.Builder()).build(); } public Builder withPdpAddress(String pdp) { @@ -104,6 +117,11 @@ public Builder withPdpAddress(String pdp) { return this; } + public Builder withApiUrl(String apiUrl) { + this.apiUrl = apiUrl; + return this; + } + public Builder withDebugMode(Boolean debugMode) { this.debugMode = debugMode; return this; @@ -149,6 +167,11 @@ public Builder withUseDefaultTenantIfEmpty(Boolean useDefaultTenantIfEmpty) { return this; } + public Builder withContext(PermitContext context) { + this.context = context; + return this; + } + public PermitConfig build() { PermitConfig config = new PermitConfig(this); return config; diff --git a/src/main/java/io/permit/sdk/PermitContext.java b/src/main/java/io/permit/sdk/PermitContext.java new file mode 100644 index 0000000..eb73be0 --- /dev/null +++ b/src/main/java/io/permit/sdk/PermitContext.java @@ -0,0 +1,74 @@ +package io.permit.sdk; + +public class PermitContext { + private final ApiKeyLevel apiKeyLevel; + private final String org; + private final String project; + private final String environment; + + public PermitContext(Builder builder) { + this.apiKeyLevel = builder.apiKeyLevel; + this.org = builder.org; + this.project = builder.project; + this.environment = builder.environment; + } + + public ApiKeyLevel getApiKeyLevel() { + return apiKeyLevel; + } + + public String getOrganization() { + return org; + } + + public String getProject() { + return project; + } + + public String getEnvironment() { + return environment; + } + + public static class Builder { + private ApiKeyLevel apiKeyLevel; + private String org; + private String project; + private String environment; + + public Builder() { + this.apiKeyLevel = ApiKeyLevel.WAIT_FOR_INIT; + this.org = null; + this.project = null; + this.environment = null; + } + + public Builder withOrganization(String org) { + this.org = org; + this.project = null; + this.environment = null; + this.apiKeyLevel = ApiKeyLevel.ORGANIZATION_LEVEL_API_KEY; + return this; + } + + public Builder withProject(String org, String project) { + this.org = org; + this.project = project; + this.environment = null; + this.apiKeyLevel = ApiKeyLevel.PROJECT_LEVEL_API_KEY; + return this; + } + + public Builder withEnvironment(String org, String project, String environment) { + this.org = org; + this.project = project; + this.environment = environment; + this.apiKeyLevel = ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY; + return this; + } + + public PermitContext build() { + PermitContext context = new PermitContext(this); + return context; + } + } +} diff --git a/src/main/java/io/permit/sdk/api/ApiClient.java b/src/main/java/io/permit/sdk/api/ApiClient.java index 3ba1a9c..be032f6 100644 --- a/src/main/java/io/permit/sdk/api/ApiClient.java +++ b/src/main/java/io/permit/sdk/api/ApiClient.java @@ -1,417 +1,206 @@ package io.permit.sdk.api; -import com.google.gson.Gson; import io.permit.sdk.PermitConfig; -import io.permit.sdk.api.models.*; -import io.permit.sdk.enforcement.User; +import io.permit.sdk.api.models.CreateOrUpdateResult; +import io.permit.sdk.openapi.models.*; import okhttp3.*; import org.jetbrains.annotations.NotNull; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.IOException; -import java.util.List; -interface IReadApis { - UserModel getUser(String userKey) throws IOException, PermitApiException; - RoleModel getRole(String roleKey) throws IOException, PermitApiException; - TenantModel getTenant(String tenantKey) throws IOException, PermitApiException; - RoleAssignmentList getAssignedRoles(String userKey, String tenantKey) throws IOException, PermitApiException; - RoleAssignmentList getAssignedRolesInAllTenants(String userKey) throws IOException, PermitApiException; +interface IDeprecatedApis { + UserRead getUser(String userKey) throws IOException, PermitApiError, PermitContextError; + RoleRead getRole(String roleKey) throws IOException, PermitApiError, PermitContextError; + TenantRead getTenant(String tenantKey) throws IOException, PermitApiError, PermitContextError; + RoleAssignmentRead[] getAssignedRoles(@NotNull String userKey, @NotNull String tenantKey) throws IOException, PermitApiError, PermitContextError; + RoleAssignmentRead[] getAssignedRolesInAllTenants(@NotNull String userKey) throws IOException, PermitApiError, PermitContextError; + CreateOrUpdateResult syncUser(UserCreate userData) throws IOException, PermitApiError, PermitContextError; + void deleteUser(String userKey) throws IOException, PermitContextError, PermitApiError; + TenantRead createTenant(TenantCreate tenantData) throws IOException, PermitApiError, PermitContextError; + TenantRead updateTenant(String tenantKey, TenantUpdate tenantData) throws IOException, PermitApiError, PermitContextError; + void deleteTenant(String tenantKey) throws IOException, PermitContextError, PermitApiError; + RoleAssignmentRead assignRole(String userKey, String roleKey, String tenantKey) throws IOException, PermitApiError, PermitContextError; + void unassignRole(String userKey, String roleKey, String tenantKey) throws IOException, PermitContextError, PermitApiError; } -interface IWriteApis { - UserModel syncUser(User user) throws IOException, PermitApiException; - Boolean deleteUser(String userKey) throws IOException; - TenantModel createTenant(TenantInput tenant) throws IOException, PermitApiException; - TenantModel updateTenant(TenantInput tenant) throws IOException, PermitApiException; - Boolean deleteTenant(String tenantKey) throws IOException; - RoleAssignmentModel assignRole(String userKey, String roleKey, String tenantKey) throws IOException, PermitApiException; - Boolean unassignRole(String userKey, String roleKey, String tenantKey) throws IOException, PermitApiException; - ResourceList syncResources(SyncedResources spec) throws IOException, PermitApiException; -} - -public class ApiClient implements IReadApis, IWriteApis { - final static int HTTP_404_NOT_FOUND = 404; - +public class ApiClient implements IDeprecatedApis { final static Logger logger = LoggerFactory.getLogger(ApiClient.class); - private final OkHttpClient client = new OkHttpClient(); + private final OkHttpClient client; private final PermitConfig config; - private final Headers headers; - private final String baseUrl; + + public final ProjectsApi projects; + public final EnvironmentsApi environments; + public final ResourcesApi resources; + public final ResourceActionsApi resourceActions; + public final ResourceAttributesApi resourceAttributes; + public final RolesApi roles; + public final TenantsApi tenants; + public final UsersApi users; + public final ElementsApi elements; public ApiClient(PermitConfig config) { this.config = config; - this.headers = new Headers.Builder() - .add("Content-Type", "application/json") - .add("Authorization", String.format("Bearer %s", this.config.getToken())) - .build(); - this.baseUrl = this.config.getPdpAddress(); - } - - private void throwIfErrorResponseCode(String requestRepr, Response response, String responseContent, List expectedErrorCodes) throws PermitApiException { - String log = String.format("Received response: %s : status code %d : %s", requestRepr, response.code(), responseContent); - if (!response.isSuccessful() && this.config.isDebugMode()) { - this.logger.error(log); - } else { - this.logger.debug(log); - } - if (!response.isSuccessful() && !expectedErrorCodes.contains(response.code())) { - throw new PermitApiException( - String.format( - "unexpected status code: %d for request: %s", - response.code(), - requestRepr - ) - ); - } - } - - private void throwIfErrorResponseCode(String requestRepr, Response response, String responseContent) throws PermitApiException { - throwIfErrorResponseCode(requestRepr, response, responseContent, List.of()); - } - - @Override - public UserModel getUser(String userKey) throws IOException, PermitApiException { - String url = String.format("%s/cloud/users/%s", this.baseUrl, userKey); - Request request = new Request.Builder() - .url(url) - .headers(this.headers) - .get() + this.client = new OkHttpClient.Builder() + .addInterceptor(new HttpLoggingInterceptor(logger, config)) .build(); - String requestRepr = String.format("permit.api.getUser(%s)", userKey); - this.logger.debug(String.format("Sending request: %s", requestRepr)); - - try (Response response = client.newCall(request).execute()) { - ResponseBody responseBody = response.body(); - if (responseBody == null) { - throw new IOException("got empty response"); - } - String responseString = responseBody.string(); - throwIfErrorResponseCode(requestRepr, response, responseString, List.of(HTTP_404_NOT_FOUND)); - if (response.code() == HTTP_404_NOT_FOUND) { - return null; - } - Gson gson = new Gson(); - return gson.fromJson(responseString, UserModel.class); - } - } - + this.projects = new ProjectsApi(this.client, this.config); + this.environments = new EnvironmentsApi(this.client, this.config); + this.resources = new ResourcesApi(this.client, this.config); + this.resourceActions = new ResourceActionsApi(this.client, this.config); + this.resourceAttributes = new ResourceAttributesApi(this.client, this.config); + this.roles = new RolesApi(this.client, this.config); + this.tenants = new TenantsApi(this.client, this.config); + this.users = new UsersApi(this.client, this.config); + this.elements = new ElementsApi(this.client, this.config); + } + + /** + * Gets a user by its key + * + * @deprecated replaced with permit.api.users.get() + * @see io.permit.sdk.api.UsersApi#get(String) + */ + @Deprecated @Override - public RoleModel getRole(String roleKey) throws IOException, PermitApiException { - String url = String.format("%s/cloud/roles/%s", this.baseUrl, roleKey); - Request request = new Request.Builder() - .url(url) - .headers(this.headers) - .get() - .build(); - - String requestRepr = String.format("permit.api.getRole(%s)", roleKey); - this.logger.debug(String.format("Sending request: %s", requestRepr)); - - try (Response response = client.newCall(request).execute()) { - ResponseBody responseBody = response.body(); - if (responseBody == null) { - throw new IOException("got empty response"); - } - String responseString = responseBody.string(); - throwIfErrorResponseCode(requestRepr, response, responseString, List.of(HTTP_404_NOT_FOUND)); - if (response.code() == HTTP_404_NOT_FOUND) { - return null; - } - Gson gson = new Gson(); - return gson.fromJson(responseString, RoleModel.class); - } + public UserRead getUser(String userKey) throws IOException, PermitApiError, PermitContextError { + return this.users.get(userKey); } + /** + * Gets a role by its key + * + * @deprecated replaced with permit.api.users.get() + * @see io.permit.sdk.api.RolesApi#get(String) + */ + @Deprecated @Override - public TenantModel getTenant(String tenantKey) throws IOException, PermitApiException { - String url = String.format("%s/cloud/tenants/%s", this.baseUrl, tenantKey); - Request request = new Request.Builder() - .url(url) - .headers(this.headers) - .get() - .build(); - - String requestRepr = String.format("permit.api.getTenant(%s)", tenantKey); - this.logger.debug(String.format("Sending request: %s", requestRepr)); - - try (Response response = client.newCall(request).execute()) { - ResponseBody responseBody = response.body(); - if (responseBody == null) { - throw new IOException("got empty response"); - } - String responseString = responseBody.string(); - throwIfErrorResponseCode(requestRepr, response, responseString, List.of(HTTP_404_NOT_FOUND)); - if (response.code() == HTTP_404_NOT_FOUND) { - return null; - } - Gson gson = new Gson(); - return gson.fromJson(responseString, TenantModel.class); - } + public RoleRead getRole(String roleKey) throws IOException, PermitApiError, PermitContextError { + return this.roles.get(roleKey); } + /** + * Gets a role by its key + * + * @deprecated replaced with permit.api.users.get() + * @see io.permit.sdk.api.TenantsApi#get(String) + */ + @Deprecated @Override - public RoleAssignmentList getAssignedRoles(@NotNull String userKey, String tenantKey) throws IOException, PermitApiException { - String url = String.format("%s/role_assignments?user=%s", this.baseUrl, userKey); - if (tenantKey != null) { - url = url + String.format("&tenant=%s", tenantKey); - } - Request request = new Request.Builder() - .url(url) - .headers(this.headers) - .get() - .build(); - - String requestRepr = String.format("permit.api.getAssignedRoles(user=%s, tenant=%s", userKey, tenantKey); - this.logger.debug(String.format("Sending request: %s", requestRepr)); - - try (Response response = client.newCall(request).execute()) { - ResponseBody responseBody = response.body(); - if (responseBody == null) { - throw new IOException("got empty response"); - } - String responseString = responseBody.string(); - throwIfErrorResponseCode(requestRepr, response, responseString); - Gson gson = new Gson(); - return gson.fromJson(responseString, RoleAssignmentList.class); - } + public TenantRead getTenant(String tenantKey) throws IOException, PermitApiError, PermitContextError { + return this.tenants.get(tenantKey); } + /** + * Gets the roles assigned to a user in a specific tenant + * + * @deprecated replaced with permit.api.users.getAssignedRoles() + * @see io.permit.sdk.api.UsersApi#getAssignedRoles(String, String, int, int) + */ + @Deprecated @Override - public RoleAssignmentList getAssignedRolesInAllTenants(String userKey) throws IOException, PermitApiException { - return this.getAssignedRoles(userKey, null); + public RoleAssignmentRead[] getAssignedRoles(@NotNull String userKey, @NotNull String tenantKey) throws IOException, PermitApiError, PermitContextError { + return this.users.getAssignedRoles(userKey, tenantKey, 1, 100); } + /** + * Gets the roles assigned to a user in all tenants + * + * @deprecated replaced with permit.api.users.getAssignedRoles() + * @see io.permit.sdk.api.UsersApi#getAssignedRoles(String, String, int, int) + */ + @Deprecated @Override - public UserModel syncUser(User user) throws IOException, PermitApiException { - // request body - Gson gson = new Gson(); - String requestBody = gson.toJson(user); - RequestBody body = RequestBody.create(requestBody, MediaType.parse("application/json")); - - // create the request - String url = String.format("%s/cloud/users", this.baseUrl); - Request request = new Request.Builder() - .url(url) - .headers(this.headers) - .put(body) - .build(); - - String requestRepr = String.format("permit.api.syncUser(%s)", requestBody); - this.logger.debug(String.format("Sending request: %s", requestRepr)); - - // send the request - try (Response response = client.newCall(request).execute()) { - ResponseBody responseBody = response.body(); - if (responseBody == null) { - throw new IOException("got empty response"); - } - String responseString = responseBody.string(); - throwIfErrorResponseCode(requestRepr, response, responseString); - return gson.fromJson(responseString, UserModel.class); - } - } - + public RoleAssignmentRead[] getAssignedRolesInAllTenants(@NotNull String userKey) throws IOException, PermitApiError, PermitContextError { + return this.users.getAssignedRoles(userKey, null, 1, 100); + } + + /** + * Syncs a user to the permissions system, i.e: creates the user if it's not already created, or updates the user in place. + * The user is identified by its key (a customer-side unique id that identifies the user). + * + * @deprecated replaced with permit.api.users.get() + * @see io.permit.sdk.api.UsersApi#sync(UserCreate) + */ + @Deprecated @Override - public Boolean deleteUser(String userKey) throws IOException { - // create the request - String url = String.format("%s/cloud/users/%s", this.baseUrl, userKey); - Request request = new Request.Builder() - .url(url) - .headers(this.headers) - .delete() - .build(); - - String requestRepr = String.format("permit.api.deleteUser(%s)", userKey); - this.logger.debug(String.format("Sending request: %s", requestRepr)); - - // send the request - try (Response response = client.newCall(request).execute()) { - logger.debug(String.format("Received response: %s : status code %d", requestRepr, response.code())); - return response.isSuccessful(); // return 204 on success, error codes otherwise - } + public CreateOrUpdateResult syncUser(UserCreate userData) throws IOException, PermitApiError, PermitContextError { + return this.users.sync(userData); } + /** + * Deletes a user from the permission system (this will delete the user from all tenants at once). + * + * @deprecated replaced with permit.api.users.delete() + * @see io.permit.sdk.api.UsersApi#delete(String) + */ + @Deprecated @Override - public TenantModel createTenant(TenantInput tenant) throws IOException, PermitApiException { - NewTenant newTenant = new NewTenant(); - newTenant.externalId = tenant.key; - newTenant.name = tenant.name; - if (tenant.description != null) { - newTenant.description = tenant.description; - } - // request body - Gson gson = new Gson(); - String requestBody = gson.toJson(newTenant); - RequestBody body = RequestBody.create(requestBody, MediaType.parse("application/json")); - - // create the request - String url = String.format("%s/cloud/tenants", this.baseUrl); - Request request = new Request.Builder() - .url(url) - .headers(this.headers) - .put(body) - .build(); - - String requestRepr = String.format("permit.api.createTenant(%s)", requestBody); - this.logger.debug(String.format("Sending request: %s", requestRepr)); - - // send the request - try (Response response = client.newCall(request).execute()) { - ResponseBody responseBody = response.body(); - if (responseBody == null) { - throw new IOException("got empty response"); - } - String responseString = responseBody.string(); - throwIfErrorResponseCode(requestRepr, response, responseString); - return gson.fromJson(responseString, TenantModel.class); - } - } - + public void deleteUser(String userKey) throws IOException, PermitContextError, PermitApiError { + this.users.delete(userKey); + } + + /** + * Creates a new tenant. + * @throws PermitApiError if a tenant already exists with the given key. + * + * @deprecated replaced with permit.api.tenants.create() + * @see io.permit.sdk.api.TenantsApi#create(TenantCreate) + */ + @Deprecated @Override - public TenantModel updateTenant(TenantInput tenant) throws IOException, PermitApiException { - NewTenant newTenant = new NewTenant(); - newTenant.name = tenant.name; - if (tenant.description != null) { - newTenant.description = tenant.description; - } - // request body - Gson gson = new Gson(); - String requestBody = gson.toJson(newTenant); - RequestBody body = RequestBody.create(requestBody, MediaType.parse("application/json")); - - // create the request - String url = String.format("%s/cloud/tenants/%s", this.baseUrl, tenant.key); - Request request = new Request.Builder() - .url(url) - .headers(this.headers) - .patch(body) - .build(); - - String requestRepr = String.format("permit.api.updateTenant(%s)", requestBody); - this.logger.debug(String.format("Sending request: %s", requestRepr)); - - // send the request - try (Response response = client.newCall(request).execute()) { - ResponseBody responseBody = response.body(); - if (responseBody == null) { - throw new IOException("got empty response"); - } - String responseString = responseBody.string(); - throwIfErrorResponseCode(requestRepr, response, responseString); - return gson.fromJson(responseString, TenantModel.class); - } + public TenantRead createTenant(TenantCreate tenantData) throws IOException, PermitApiError, PermitContextError { + return this.tenants.create(tenantData); } + /** + * Updates a tenant. + * + * @deprecated replaced with permit.api.tenants.update() + * @see io.permit.sdk.api.TenantsApi#update(String, TenantUpdate) + */ + @Deprecated @Override - public Boolean deleteTenant(String tenantKey) throws IOException { - // create the request - String url = String.format("%s/cloud/tenants/%s", this.baseUrl, tenantKey); - Request request = new Request.Builder() - .url(url) - .headers(this.headers) - .delete() - .build(); - - String requestRepr = String.format("permit.api.deleteTenant(%s)", tenantKey); - this.logger.debug(String.format("Sending request: %s", requestRepr)); - - // send the request - try (Response response = client.newCall(request).execute()) { - logger.debug(String.format("Received response: %s : status code %d", requestRepr, response.code())); - return response.isSuccessful(); // return 204 on success, error codes otherwise - } - } - + public TenantRead updateTenant(String tenantKey, TenantUpdate tenantData) throws IOException, PermitApiError, PermitContextError { + return this.tenants.update(tenantKey, tenantData); + } + + /** + * Deletes a tenant from the system. + * All roles assigned to users in that tenants will be unassigned as a result. + * + * @deprecated replaced with permit.api.tenants.delete() + * @see io.permit.sdk.api.TenantsApi#delete(String) + */ + @Deprecated @Override - public RoleAssignmentModel assignRole(String userKey, String roleKey, String tenantKey) throws IOException, PermitApiException { - RoleAssignmentInput input = new RoleAssignmentInput(); - input.user = userKey; - input.role = roleKey; - input.scope = tenantKey; - - // request body - Gson gson = new Gson(); - String requestBody = gson.toJson(input); - RequestBody body = RequestBody.create(requestBody, MediaType.parse("application/json")); - - // create the request - String url = String.format("%s/cloud/role_assignments", this.baseUrl); - Request request = new Request.Builder() - .url(url) - .headers(this.headers) - .post(body) - .build(); - - String requestRepr = String.format("permit.api.assignRole(%s)", requestBody); - this.logger.debug(String.format("Sending request: %s", requestRepr)); - - // send the request - try (Response response = client.newCall(request).execute()) { - ResponseBody responseBody = response.body(); - if (responseBody == null) { - throw new IOException("got empty response"); - } - String responseString = responseBody.string(); - throwIfErrorResponseCode(requestRepr, response, responseString); - return gson.fromJson(responseString, RoleAssignmentModel.class); - } + public void deleteTenant(String tenantKey) throws IOException, PermitContextError, PermitApiError { + this.tenants.delete(tenantKey); } + /** + * assigns a role to user in tenant, if not already assigned. + * + * @deprecated replaced with permit.api.users.assignRole() + * @see io.permit.sdk.api.UsersApi#assignRole(String, String, String) + */ + @Deprecated @Override - public Boolean unassignRole(String userKey, String roleKey, String tenantKey) throws IOException { - // create the request - String url = String.format( - "%s/cloud/role_assignments?role=%s&user=%s&scope=%s", - this.baseUrl, - roleKey, - userKey, - tenantKey - ); - Request request = new Request.Builder() - .url(url) - .headers(this.headers) - .delete() - .build(); - - String requestRepr = String.format("permit.api.unassignRole(%s,%s,%s)", userKey, roleKey, tenantKey); - this.logger.debug(String.format("Sending request: %s", requestRepr)); - - // send the request - try (Response response = client.newCall(request).execute()) { - return response.isSuccessful(); // return 204 on success, error codes otherwise - } + public RoleAssignmentRead assignRole(String userKey, String roleKey, String tenantKey) throws IOException, PermitApiError, PermitContextError { + return this.users.assignRole(userKey, roleKey, tenantKey); } + /** + * unassigns a role to user in tenant, if assigned. + * + * @deprecated replaced with permit.api.users.unassignRole() + * @see io.permit.sdk.api.UsersApi#unassignRole(String, String, String) + */ + @Deprecated @Override - public ResourceList syncResources(SyncedResources spec) throws IOException, PermitApiException { - // request body - Gson gson = new Gson(); - String requestBody = gson.toJson(spec); - RequestBody body = RequestBody.create(requestBody, MediaType.parse("application/json")); - - // create the request - String url = String.format("%s/cloud/resources", this.baseUrl); - Request request = new Request.Builder() - .url(url) - .headers(this.headers) - .put(body) - .build(); - - String requestRepr = String.format("permit.api.syncResources(%s)", requestBody); - this.logger.debug(String.format("Sending request: %s", requestRepr)); - - // send the request - try (Response response = client.newCall(request).execute()) { - ResponseBody responseBody = response.body(); - if (responseBody == null) { - throw new IOException("got empty response"); - } - String responseString = responseBody.string(); - throwIfErrorResponseCode(requestRepr, response, responseString); - return gson.fromJson(responseString, ResourceList.class); - } + public void unassignRole(String userKey, String roleKey, String tenantKey) throws IOException, PermitContextError, PermitApiError { + this.users.unassignRole(userKey, roleKey, tenantKey); } } diff --git a/src/main/java/io/permit/sdk/api/BaseApi.java b/src/main/java/io/permit/sdk/api/BaseApi.java new file mode 100644 index 0000000..8906482 --- /dev/null +++ b/src/main/java/io/permit/sdk/api/BaseApi.java @@ -0,0 +1,168 @@ +package io.permit.sdk.api; + +import com.google.gson.Gson; +import com.google.gson.GsonBuilder; +import io.permit.sdk.ApiKeyLevel; +import io.permit.sdk.PermitConfig; +import io.permit.sdk.PermitContext; +import io.permit.sdk.openapi.models.APIKeyScopeRead; +import io.permit.sdk.openapi.models.RoleCreate; +import io.permit.sdk.openapi.models.RoleRead; +import okhttp3.*; +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.List; + +public abstract class BaseApi { + protected final OkHttpClient client; + protected final PermitConfig config; + + protected final Logger logger; + protected final Headers headers; + + protected BaseApi(OkHttpClient client, PermitConfig config, Logger logger) { + this.client = client; + this.config = config; + this.logger = logger; + this.headers = new Headers.Builder() + .add("Content-Type", "application/json") + .add("Authorization", String.format("Bearer %s", this.config.getToken())) + .build(); + } + + protected T callApiAndParseJson(Request request, Class modelClass) throws IOException, PermitApiError { + try (Response response = client.newCall(request).execute()) { + String responseString = processResponseBody(response); + return (new Gson()).fromJson(responseString, modelClass); + } + } + + protected void throwIfErrorResponseCode(Response response, String responseContent, List validErrorCodes) throws PermitApiError { + if (!response.isSuccessful() && !validErrorCodes.contains(response.code())) { + if (config.isDebugMode()) { + prettyPrintErrorJson(responseContent); + } + + throw new PermitApiError( + String.format("Got error status code: %d", response.code()), + response.code(), + responseContent + ); + } + } + + protected void prettyPrintErrorJson(String responseString) { + Gson gson = new GsonBuilder().setPrettyPrinting().create(); + String json = gson.toJson(gson.fromJson(responseString, Object.class)); + logger.info(String.format("[Permit SDK] got error:\n%s", json)); + } + + protected String processResponseBody(Response response, boolean throwOnEmptyResponse) throws IOException, PermitApiError { + ResponseBody responseBody = response.body(); + if (responseBody == null && throwOnEmptyResponse) { + throw new IOException("got empty response"); + } + String responseString = responseBody.string(); + throwIfErrorResponseCode(response, responseString, new ArrayList()); + return responseString; + } + + @NotNull + protected static RequestBody getJsonRequestBody(T data) { + return RequestBody.create(( + new Gson()).toJson(data), + MediaType.parse("application/json") + ); + } + + protected String processResponseBody(Response response) throws IOException, PermitApiError { + return processResponseBody(response, true); + } + + protected String buildUrl(String relativeUrl) { + return String.format("%s%s", config.getApiUrl(), relativeUrl); + } + + protected Request buildRequest(Request.Builder builder) { + return builder.headers(this.headers).build(); + } + + private void setContextFromApiKey() throws IOException, PermitContextError { + String url = buildUrl("/v2/api-key/scope"); + Request request = buildRequest( + new Request.Builder() + .url(url) + .get() + ); + try (Response response = client.newCall(request).execute()) { + String responseString = processResponseBody(response); + Gson gson = new Gson(); + APIKeyScopeRead scope = gson.fromJson(responseString, APIKeyScopeRead.class); + if (scope.organizationId != null) { + if (scope.projectId != null) { + if (scope.environmentId != null) { + // env level scope + this.config.setContext( + new PermitContext.Builder().withEnvironment( + scope.organizationId, + scope.projectId, + scope.environmentId + ).build()); + return; + } + + // project level scope + this.config.setContext( + new PermitContext.Builder().withProject( + scope.organizationId, + scope.projectId + ).build()); + return; + } + + // org level scope + this.config.setContext( + new PermitContext.Builder().withOrganization( + scope.organizationId + ).build()); + return; + } + throw new PermitContextError("could not set api key scope"); + + } catch (PermitApiError e) { + throw new PermitContextError("could not get api key scope in order to create a context"); + } + } + + protected void ensureContext(ApiKeyLevel callLevel) throws PermitContextError, IOException { + // set context if not already set + if (this.config.getContext().getApiKeyLevel() == ApiKeyLevel.WAIT_FOR_INIT) { + setContextFromApiKey(); + } + + // verify context matches requested call level + if (callLevel == ApiKeyLevel.PROJECT_LEVEL_API_KEY && this.config.getContext().getProject() == null) { + throw new PermitContextError(""" + You're trying to use an SDK method that's specific to a project, + but you haven't set the current project in your client's context yet, + or you are using an organization level API key. + Please set the context to a specific + project using `permit.set_context()` method. + """); + } + + if (callLevel == ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY && this.config.getContext().getEnvironment() == null) { + throw new PermitContextError(""" + You're trying to use an SDK method that's specific to an environment, + but you haven't set the current environment in your client's context yet, + or you are using an organization/project level API key. + Please set the context to a specific + environment using `permit.set_context()` method. + """); + } + } +} diff --git a/src/main/java/io/permit/sdk/api/ElementsApi.java b/src/main/java/io/permit/sdk/api/ElementsApi.java new file mode 100644 index 0000000..6761289 --- /dev/null +++ b/src/main/java/io/permit/sdk/api/ElementsApi.java @@ -0,0 +1,56 @@ +package io.permit.sdk.api; + +import com.google.gson.Gson; +import io.permit.sdk.ApiKeyLevel; +import io.permit.sdk.PermitConfig; +import io.permit.sdk.api.models.*; +import io.permit.sdk.openapi.models.*; +import okhttp3.*; +import org.jetbrains.annotations.NotNull; +import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.util.*; + +interface IElementsApi { + EmbeddedLoginRequestOutput loginAs(String userKey, String tenantKey) throws IOException, PermitApiError, PermitContextError; +} + +public class ElementsApi extends BaseApi implements IElementsApi { + public ElementsApi(OkHttpClient client, PermitConfig config) { + super(client, config, LoggerFactory.getLogger(ElementsApi.class)); + } + + public EmbeddedLoginRequestOutput loginAs(String userKey, String tenantKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = buildUrl("/v2/auth/elements_login_as"); + RequestBody jsonBody = getJsonRequestBody(new UserLoginRequestInput(userKey, tenantKey)); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .post(jsonBody) + ); + + try (Response response = client.newCall(request).execute()) { + String responseString = processResponseBody(response); + EmbeddedLoginRequestOutput result = (new Gson()).fromJson(responseString, EmbeddedLoginRequestOutput.class); + return processResult(result); + } + } + + private ElementsLoginResult processResult(EmbeddedLoginRequestOutput result) { + Map content = new HashMap<>(); + content.put("url", result.redirectUrl); + + ElementsLoginResult loginResult = (ElementsLoginResult) (new ElementsLoginResult()) + .withError(result.error) + .withErrorCode(result.errorCode) + .withToken(result.token) + .withExtra(result.extra) + .withRedirectUrl(result.redirectUrl); + + loginResult.withContent(content); + + return loginResult; + } +} diff --git a/src/main/java/io/permit/sdk/api/ElementsClient.java b/src/main/java/io/permit/sdk/api/ElementsClient.java deleted file mode 100644 index 0b6b2b3..0000000 --- a/src/main/java/io/permit/sdk/api/ElementsClient.java +++ /dev/null @@ -1,101 +0,0 @@ -package io.permit.sdk.api; - -import com.google.gson.FieldNamingPolicy; -import com.google.gson.Gson; -import com.google.gson.GsonBuilder; -import io.permit.sdk.PermitConfig; -import io.permit.sdk.api.models.*; -import okhttp3.*; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.util.HashMap; -import java.util.List; - -interface IElementsApi { - UserLoginResponse loginAs(String userId, String tenantId) throws IOException, PermitApiException; -} - -public class ElementsClient implements IElementsApi { - final static Logger logger = LoggerFactory.getLogger(ApiClient.class); - private final OkHttpClient client = new OkHttpClient(); - private final PermitConfig config; - private final Headers headers; - private final String apiUrl; - - public ElementsClient(PermitConfig config) { - this.config = config; - this.headers = new Headers.Builder() - .add("Content-Type", "application/json") - .add("Authorization", String.format("Bearer %s", this.config.getToken())) - .build(); - this.apiUrl = this.config.getApiUrl(); - } - - private void throwIfErrorResponseCode(String requestRepr, Response response, String responseContent, List expectedErrorCodes) throws PermitApiException { - String log = String.format("Received response: %s : status code %d : %s", requestRepr, response.code(), responseContent); - if (!response.isSuccessful() && this.config.isDebugMode()) { - this.logger.error(log); - } else { - this.logger.debug(log); - } - if (!response.isSuccessful() && !expectedErrorCodes.contains(response.code())) { - throw new PermitApiException( - String.format( - "unexpected status code: %d for request: %s", - response.code(), - requestRepr - ) - ); - } - } - - private void throwIfErrorResponseCode(String requestRepr, Response response, String responseContent) throws PermitApiException { - throwIfErrorResponseCode(requestRepr, response, responseContent, List.of()); - } - - @Override - public UserLoginResponse loginAs(String userId, String tenantId) throws IOException, PermitApiException { - UserLoginRequest element = new UserLoginRequest(); - element.tenantId = tenantId; - element.userId = userId; - - // request body - Gson gson = new GsonBuilder() - .setFieldNamingPolicy(FieldNamingPolicy.LOWER_CASE_WITH_UNDERSCORES) - .create(); - String requestBody = gson.toJson(element); - RequestBody body = RequestBody.create(requestBody, MediaType.parse("application/json")); - - // create the request - String url = String.format("%s/v2/auth/elements_login_as", this.config.getApiUrl()); - Request request = new Request.Builder() - .url(url) - .headers(this.headers) - .post(body) - .build(); - - String requestRepr = String.format("permit.elements.login_as(%s)", requestBody); - this.logger.debug(String.format("Sending request: %s", requestRepr)); - - // send the request - try (Response response = client.newCall(request).execute()) { - ResponseBody responseBody = response.body(); - if (responseBody == null) { - throw new IOException("got empty response"); - } - String responseString = responseBody.string(); - throwIfErrorResponseCode(requestRepr, response, responseString); - UserLoginResponse userLoginResponse = gson.fromJson(responseString, UserLoginResponse.class); - userLoginResponse.content = new HashMap<>(); - userLoginResponse.content.put("url", userLoginResponse.redirectUrl); - return userLoginResponse; - } - } - - public String getApiUrl() { - return apiUrl; - } -} - diff --git a/src/main/java/io/permit/sdk/api/EnvironmentsApi.java b/src/main/java/io/permit/sdk/api/EnvironmentsApi.java new file mode 100644 index 0000000..65f756f --- /dev/null +++ b/src/main/java/io/permit/sdk/api/EnvironmentsApi.java @@ -0,0 +1,132 @@ +package io.permit.sdk.api; + +import com.google.gson.Gson; +import io.permit.sdk.ApiKeyLevel; +import io.permit.sdk.PermitConfig; +import io.permit.sdk.openapi.models.*; +import okhttp3.*; +import org.jetbrains.annotations.NotNull; +import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Objects; +import java.util.UUID; + +interface IEnvironmentsApi { + EnvironmentRead[] list(String projectKey, int page, int perPage) throws IOException, PermitApiError, PermitContextError; + EnvironmentRead[] list(String projectKey, int page) throws IOException, PermitApiError, PermitContextError; + EnvironmentRead[] list(String projectKey) throws IOException, PermitApiError, PermitContextError; + EnvironmentRead get(String projectKey, String environmentKey) throws IOException, PermitApiError, PermitContextError; + EnvironmentRead getByKey(String projectKey, String environmentKey) throws IOException, PermitApiError, PermitContextError; + EnvironmentRead getById(UUID projectId, UUID environmentId) throws IOException, PermitApiError, PermitContextError; + EnvironmentRead create(String projectKey, EnvironmentCreate environmentData) throws IOException, PermitApiError, PermitContextError; + EnvironmentRead update(String projectKey, String environmentKey, EnvironmentUpdate environmentData) throws IOException, PermitApiError, PermitContextError; + void delete(String projectKey, String environmentKey) throws IOException, PermitApiError, PermitContextError; +} + +public class EnvironmentsApi extends BaseApi implements IEnvironmentsApi { + public EnvironmentsApi(OkHttpClient client, PermitConfig config) { + super(client, config, LoggerFactory.getLogger(EnvironmentsApi.class)); + } + + private String getEnvironmentsUrl(String projectKey, String url) { + return buildUrl( + String.format( + "/v2/projects/%s/envs%s", + projectKey, + url + ) + ); + } + + public EnvironmentRead[] list(String projectKey, int page, int perPage) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.PROJECT_LEVEL_API_KEY); + String url = getEnvironmentsUrl(projectKey, ""); + HttpUrl.Builder urlBuilder = Objects.requireNonNull(HttpUrl.parse(url)).newBuilder(); + Request request = buildRequest( + new Request.Builder() + .url( + urlBuilder + .addQueryParameter("page", Integer.toString(page)) + .addQueryParameter("per_page", Integer.toString(perPage)) + .build() + ) + .get() + ); + + try (Response response = client.newCall(request).execute()) { + String responseString = processResponseBody(response); + return (new Gson()).fromJson(responseString, EnvironmentRead[].class); + } + } + + public EnvironmentRead[] list(String projectKey, int page) throws IOException, PermitApiError, PermitContextError { + return this.list(projectKey, page, 100); + } + + public EnvironmentRead[] list(String projectKey) throws IOException, PermitApiError, PermitContextError { + return this.list(projectKey,1); + } + + public EnvironmentRead get(String projectKey, String environmentKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.PROJECT_LEVEL_API_KEY); + String url = getEnvironmentsUrl(projectKey, String.format("/%s", environmentKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .get() + ); + + return this.callApiAndParseJson(request, EnvironmentRead.class); + } + + public EnvironmentRead getByKey(String projectKey, String environmentKey) throws IOException, PermitApiError, PermitContextError { + return this.get(projectKey, environmentKey); + } + + public EnvironmentRead getById(UUID projectId, UUID environmentId) throws IOException, PermitApiError, PermitContextError { + return this.get(projectId.toString(), environmentId.toString()); + } + + public EnvironmentRead create(String projectKey, EnvironmentCreate environmentData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.PROJECT_LEVEL_API_KEY); + String url = getEnvironmentsUrl(projectKey,""); + RequestBody jsonBody = getJsonRequestBody(environmentData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .post(jsonBody) + ); + + return this.callApiAndParseJson(request, EnvironmentRead.class); + } + + public EnvironmentRead update(String projectKey, String environmentKey, EnvironmentUpdate environmentData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.PROJECT_LEVEL_API_KEY); + String url = getEnvironmentsUrl(projectKey, String.format("/%s", environmentKey)); + RequestBody jsonBody = getJsonRequestBody(environmentData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .patch(jsonBody) + ); + + return this.callApiAndParseJson(request, EnvironmentRead.class); + } + + public void delete(String projectKey, String environmentKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.PROJECT_LEVEL_API_KEY); + String url = getEnvironmentsUrl(projectKey, String.format("/%s", environmentKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .delete() + ); + + try (Response response = client.newCall(request).execute()) { + processResponseBody(response, false); + } + } +} diff --git a/src/main/java/io/permit/sdk/api/HttpLoggingInterceptor.java b/src/main/java/io/permit/sdk/api/HttpLoggingInterceptor.java new file mode 100644 index 0000000..37bbe25 --- /dev/null +++ b/src/main/java/io/permit/sdk/api/HttpLoggingInterceptor.java @@ -0,0 +1,46 @@ +package io.permit.sdk.api; + +import io.permit.sdk.PermitConfig; +import okhttp3.Interceptor; +import okhttp3.Request; +import okhttp3.Response; + +import java.io.IOException; + +import org.jetbrains.annotations.NotNull; +import org.slf4j.Logger; + +public class HttpLoggingInterceptor implements Interceptor { + private final Logger logger; + private final PermitConfig config; + + public HttpLoggingInterceptor(Logger logger, PermitConfig config) { + this.logger = logger; + this.config = config; + } + + @NotNull + @Override public Response intercept(Interceptor.Chain chain) throws IOException { + Request request = chain.request(); + + if (config.isDebugMode()) { + logger.info( + String.format( + "[Permit SDK] Sending HTTP request: %s %s", request.method(), request.url() + ) + ); + } + + Response response = chain.proceed(request); + + if (config.isDebugMode()) { + logger.info( + String.format( + "[Permit SDK] Received HTTP response: %s %s, status %d", request.method(), request.url(), response.code() + ) + ); + } + + return response; + } +} \ No newline at end of file diff --git a/src/main/java/io/permit/sdk/api/PermitApiError.java b/src/main/java/io/permit/sdk/api/PermitApiError.java new file mode 100644 index 0000000..f9a9410 --- /dev/null +++ b/src/main/java/io/permit/sdk/api/PermitApiError.java @@ -0,0 +1,23 @@ +package io.permit.sdk.api; + +import com.google.gson.Gson; +import com.google.gson.internal.LinkedTreeMap; + +public class PermitApiError extends Throwable { + final private int responseCode; + final private String rawResponse; + + public PermitApiError(String s, int responseCode, String responseString) { + super(s); + this.responseCode = responseCode; + this.rawResponse = responseString; + } + + public int getResponseCode() { return responseCode; } + + public String getRawResponse() { return rawResponse; } + + public LinkedTreeMap getErrorObject () { + return (new Gson()).fromJson(rawResponse, LinkedTreeMap.class); + } +} diff --git a/src/main/java/io/permit/sdk/api/PermitContextError.java b/src/main/java/io/permit/sdk/api/PermitContextError.java new file mode 100644 index 0000000..778c34a --- /dev/null +++ b/src/main/java/io/permit/sdk/api/PermitContextError.java @@ -0,0 +1,7 @@ +package io.permit.sdk.api; + +public class PermitContextError extends Exception { + public PermitContextError(String message) { + super(message); + } +} diff --git a/src/main/java/io/permit/sdk/api/ProjectsApi.java b/src/main/java/io/permit/sdk/api/ProjectsApi.java new file mode 100644 index 0000000..70786ab --- /dev/null +++ b/src/main/java/io/permit/sdk/api/ProjectsApi.java @@ -0,0 +1,132 @@ +package io.permit.sdk.api; + +import com.google.gson.Gson; +import io.permit.sdk.ApiKeyLevel; +import io.permit.sdk.PermitConfig; +import io.permit.sdk.openapi.models.*; +import okhttp3.*; +import org.jetbrains.annotations.NotNull; +import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Objects; +import java.util.UUID; + + +interface IProjectsApi { + ProjectRead[] list(int page, int perPage) throws IOException, PermitApiError, PermitContextError; + ProjectRead[] list(int page) throws IOException, PermitApiError, PermitContextError; + ProjectRead[] list() throws IOException, PermitApiError, PermitContextError; + ProjectRead get(String projectKey) throws IOException, PermitApiError, PermitContextError; + ProjectRead getByKey(String projectKey) throws IOException, PermitApiError, PermitContextError; + ProjectRead getById(UUID projectId) throws IOException, PermitApiError, PermitContextError; + ProjectRead create(ProjectCreate projectData) throws IOException, PermitApiError, PermitContextError; + ProjectRead update(String projectKey, ProjectUpdate projectData) throws IOException, PermitApiError, PermitContextError; + void delete(String projectKey) throws IOException, PermitApiError, PermitContextError; +} + +public class ProjectsApi extends BaseApi implements IProjectsApi { + public ProjectsApi(OkHttpClient client, PermitConfig config) { + super(client, config, LoggerFactory.getLogger(ProjectsApi.class)); + } + + private String getProjectsUrl(String url) { + return buildUrl( + String.format( + "/v2/projects%s", + url + ) + ); + } + + public ProjectRead[] list(int page, int perPage) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ORGANIZATION_LEVEL_API_KEY); + String url = getProjectsUrl(""); + HttpUrl.Builder urlBuilder = Objects.requireNonNull(HttpUrl.parse(url)).newBuilder(); + Request request = buildRequest( + new Request.Builder() + .url( + urlBuilder + .addQueryParameter("page", Integer.toString(page)) + .addQueryParameter("per_page", Integer.toString(perPage)) + .build() + ) + .get() + ); + + try (Response response = client.newCall(request).execute()) { + String responseString = processResponseBody(response); + return (new Gson()).fromJson(responseString, ProjectRead[].class); + } + } + + public ProjectRead[] list(int page) throws IOException, PermitApiError, PermitContextError { + return this.list(page, 100); + } + + public ProjectRead[] list() throws IOException, PermitApiError, PermitContextError { + return this.list(1); + } + + public ProjectRead get(String projectKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ORGANIZATION_LEVEL_API_KEY); + String url = getProjectsUrl(String.format("/%s", projectKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .get() + ); + + return this.callApiAndParseJson(request, ProjectRead.class); + } + + public ProjectRead getByKey(String projectKey) throws IOException, PermitApiError, PermitContextError { + return this.get(projectKey); + } + + public ProjectRead getById(UUID projectId) throws IOException, PermitApiError, PermitContextError { + return this.get(projectId.toString()); + } + + public ProjectRead create(ProjectCreate projectData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ORGANIZATION_LEVEL_API_KEY); + String url = getProjectsUrl(""); + RequestBody jsonBody = getJsonRequestBody(projectData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .post(jsonBody) + ); + + return this.callApiAndParseJson(request, ProjectRead.class); + } + + public ProjectRead update(String projectKey, ProjectUpdate projectData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ORGANIZATION_LEVEL_API_KEY); + String url = getProjectsUrl(String.format("/%s", projectKey)); + RequestBody jsonBody = getJsonRequestBody(projectData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .patch(jsonBody) + ); + + return this.callApiAndParseJson(request, ProjectRead.class); + } + + public void delete(String projectKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ORGANIZATION_LEVEL_API_KEY); + String url = getProjectsUrl(String.format("/%s", projectKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .delete() + ); + + try (Response response = client.newCall(request).execute()) { + processResponseBody(response, false); + } + } +} diff --git a/src/main/java/io/permit/sdk/api/ResourceActionsApi.java b/src/main/java/io/permit/sdk/api/ResourceActionsApi.java new file mode 100644 index 0000000..64e72f1 --- /dev/null +++ b/src/main/java/io/permit/sdk/api/ResourceActionsApi.java @@ -0,0 +1,134 @@ +package io.permit.sdk.api; + +import com.google.gson.Gson; +import io.permit.sdk.ApiKeyLevel; +import io.permit.sdk.PermitConfig; +import io.permit.sdk.openapi.models.*; +import okhttp3.*; +import org.jetbrains.annotations.NotNull; +import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Objects; +import java.util.UUID; + +interface IResourceActionsApi { + ResourceActionRead[] list(String resourceKey, int page, int perPage) throws IOException, PermitApiError, PermitContextError; + ResourceActionRead[] list(String resourceKey, int page) throws IOException, PermitApiError, PermitContextError; + ResourceActionRead[] list(String resourceKey) throws IOException, PermitApiError, PermitContextError; + ResourceActionRead get(String resourceKey, String actionKey) throws IOException, PermitApiError, PermitContextError; + ResourceActionRead getByKey(String resourceKey, String actionKey) throws IOException, PermitApiError, PermitContextError; + ResourceActionRead getById(UUID resourceId, UUID actionId) throws IOException, PermitApiError, PermitContextError; + ResourceActionRead create(String resourceKey, ResourceActionCreate actionData) throws IOException, PermitApiError, PermitContextError; + ResourceActionRead update(String resourceKey, String actionKey, ResourceActionUpdate actionData) throws IOException, PermitApiError, PermitContextError; + void delete(String resourceKey, String actionKey) throws IOException, PermitApiError, PermitContextError; +} + +public class ResourceActionsApi extends BaseApi implements IResourceActionsApi { + public ResourceActionsApi(OkHttpClient client, PermitConfig config) { + super(client, config, LoggerFactory.getLogger(ResourceActionsApi.class)); + } + + private String getResourceActionsUrl(String resourceKey, String url) { + return buildUrl( + String.format( + "/v2/schema/%s/%s/resources/%s/actions%s", + config.getContext().getProject(), + config.getContext().getEnvironment(), + resourceKey, + url + ) + ); + } + + public ResourceActionRead[] list(String resourceKey, int page, int perPage) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourceActionsUrl(resourceKey, ""); + HttpUrl.Builder urlBuilder = Objects.requireNonNull(HttpUrl.parse(url)).newBuilder(); + Request request = buildRequest( + new Request.Builder() + .url( + urlBuilder + .addQueryParameter("page", Integer.toString(page)) + .addQueryParameter("per_page", Integer.toString(perPage)) + .build() + ) + .get() + ); + + try (Response response = client.newCall(request).execute()) { + String responseString = processResponseBody(response); + return (new Gson()).fromJson(responseString, ResourceActionRead[].class); + } + } + + public ResourceActionRead[] list(String resourceKey, int page) throws IOException, PermitApiError, PermitContextError { + return this.list(resourceKey, page, 100); + } + + public ResourceActionRead[] list(String resourceKey) throws IOException, PermitApiError, PermitContextError { + return this.list(resourceKey,1); + } + + public ResourceActionRead get(String resourceKey, String actionKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourceActionsUrl(resourceKey, String.format("/%s", actionKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .get() + ); + + return this.callApiAndParseJson(request, ResourceActionRead.class); + } + + public ResourceActionRead getByKey(String resourceKey, String actionKey) throws IOException, PermitApiError, PermitContextError { + return this.get(resourceKey, actionKey); + } + + public ResourceActionRead getById(UUID resourceId, UUID actionId) throws IOException, PermitApiError, PermitContextError { + return this.get(resourceId.toString(), actionId.toString()); + } + + public ResourceActionRead create(String resourceKey, ResourceActionCreate actionData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourceActionsUrl(resourceKey,""); + RequestBody jsonBody = getJsonRequestBody(actionData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .post(jsonBody) + ); + + return this.callApiAndParseJson(request, ResourceActionRead.class); + } + + public ResourceActionRead update(String resourceKey, String actionKey, ResourceActionUpdate actionData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourceActionsUrl(resourceKey, String.format("/%s", actionKey)); + RequestBody jsonBody = getJsonRequestBody(actionData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .patch(jsonBody) + ); + + return this.callApiAndParseJson(request, ResourceActionRead.class); + } + + public void delete(String resourceKey, String actionKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourceActionsUrl(resourceKey, String.format("/%s", actionKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .delete() + ); + + try (Response response = client.newCall(request).execute()) { + processResponseBody(response, false); + } + } +} diff --git a/src/main/java/io/permit/sdk/api/ResourceAttributesApi.java b/src/main/java/io/permit/sdk/api/ResourceAttributesApi.java new file mode 100644 index 0000000..eadf830 --- /dev/null +++ b/src/main/java/io/permit/sdk/api/ResourceAttributesApi.java @@ -0,0 +1,134 @@ +package io.permit.sdk.api; + +import com.google.gson.Gson; +import io.permit.sdk.ApiKeyLevel; +import io.permit.sdk.PermitConfig; +import io.permit.sdk.openapi.models.*; +import okhttp3.*; +import org.jetbrains.annotations.NotNull; +import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Objects; +import java.util.UUID; + +interface IResourceAttributesApi { + ResourceAttributeRead[] list(String resourceKey, int page, int perPage) throws IOException, PermitApiError, PermitContextError; + ResourceAttributeRead[] list(String resourceKey, int page) throws IOException, PermitApiError, PermitContextError; + ResourceAttributeRead[] list(String resourceKey) throws IOException, PermitApiError, PermitContextError; + ResourceAttributeRead get(String resourceKey, String attributeKey) throws IOException, PermitApiError, PermitContextError; + ResourceAttributeRead getByKey(String resourceKey, String attributeKey) throws IOException, PermitApiError, PermitContextError; + ResourceAttributeRead getById(UUID resourceId, UUID attributeId) throws IOException, PermitApiError, PermitContextError; + ResourceAttributeRead create(String resourceKey, ResourceAttributeCreate attributeData) throws IOException, PermitApiError, PermitContextError; + ResourceAttributeRead update(String resourceKey, String attributeKey, ResourceAttributeUpdate attributeData) throws IOException, PermitApiError, PermitContextError; + void delete(String resourceKey, String attributeKey) throws IOException, PermitApiError, PermitContextError; +} + +public class ResourceAttributesApi extends BaseApi implements IResourceAttributesApi { + public ResourceAttributesApi(OkHttpClient client, PermitConfig config) { + super(client, config, LoggerFactory.getLogger(ResourceAttributesApi.class)); + } + + private String getResourceAttributesUrl(String resourceKey, String url) { + return buildUrl( + String.format( + "/v2/schema/%s/%s/resources/%s/attributes%s", + config.getContext().getProject(), + config.getContext().getEnvironment(), + resourceKey, + url + ) + ); + } + + public ResourceAttributeRead[] list(String resourceKey, int page, int perPage) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourceAttributesUrl(resourceKey, ""); + HttpUrl.Builder urlBuilder = Objects.requireNonNull(HttpUrl.parse(url)).newBuilder(); + Request request = buildRequest( + new Request.Builder() + .url( + urlBuilder + .addQueryParameter("page", Integer.toString(page)) + .addQueryParameter("per_page", Integer.toString(perPage)) + .build() + ) + .get() + ); + + try (Response response = client.newCall(request).execute()) { + String responseString = processResponseBody(response); + return (new Gson()).fromJson(responseString, ResourceAttributeRead[].class); + } + } + + public ResourceAttributeRead[] list(String resourceKey, int page) throws IOException, PermitApiError, PermitContextError { + return this.list(resourceKey, page, 100); + } + + public ResourceAttributeRead[] list(String resourceKey) throws IOException, PermitApiError, PermitContextError { + return this.list(resourceKey,1); + } + + public ResourceAttributeRead get(String resourceKey, String attributeKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourceAttributesUrl(resourceKey, String.format("/%s", attributeKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .get() + ); + + return this.callApiAndParseJson(request, ResourceAttributeRead.class); + } + + public ResourceAttributeRead getByKey(String resourceKey, String attributeKey) throws IOException, PermitApiError, PermitContextError { + return this.get(resourceKey, attributeKey); + } + + public ResourceAttributeRead getById(UUID resourceId, UUID attributeId) throws IOException, PermitApiError, PermitContextError { + return this.get(resourceId.toString(), attributeId.toString()); + } + + public ResourceAttributeRead create(String resourceKey, ResourceAttributeCreate attributeData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourceAttributesUrl(resourceKey,""); + RequestBody jsonBody = getJsonRequestBody(attributeData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .post(jsonBody) + ); + + return this.callApiAndParseJson(request, ResourceAttributeRead.class); + } + + public ResourceAttributeRead update(String resourceKey, String attributeKey, ResourceAttributeUpdate attributeData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourceAttributesUrl(resourceKey, String.format("/%s", attributeKey)); + RequestBody jsonBody = getJsonRequestBody(attributeData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .patch(jsonBody) + ); + + return this.callApiAndParseJson(request, ResourceAttributeRead.class); + } + + public void delete(String resourceKey, String attributeKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourceAttributesUrl(resourceKey, String.format("/%s", attributeKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .delete() + ); + + try (Response response = client.newCall(request).execute()) { + processResponseBody(response, false); + } + } +} diff --git a/src/main/java/io/permit/sdk/api/ResourcesApi.java b/src/main/java/io/permit/sdk/api/ResourcesApi.java new file mode 100644 index 0000000..07308ce --- /dev/null +++ b/src/main/java/io/permit/sdk/api/ResourcesApi.java @@ -0,0 +1,148 @@ +package io.permit.sdk.api; + +import com.google.gson.Gson; +import io.permit.sdk.ApiKeyLevel; +import io.permit.sdk.PermitConfig; +import io.permit.sdk.openapi.models.*; +import okhttp3.*; +import org.jetbrains.annotations.NotNull; +import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Objects; +import java.util.UUID; + +interface IResourcesApi { + ResourceRead[] list(int page, int perPage) throws IOException, PermitApiError, PermitContextError; + ResourceRead[] list(int page) throws IOException, PermitApiError, PermitContextError; + ResourceRead[] list() throws IOException, PermitApiError, PermitContextError; + ResourceRead get(String resourceKey) throws IOException, PermitApiError, PermitContextError; + ResourceRead getByKey(String resourceKey) throws IOException, PermitApiError, PermitContextError; + ResourceRead getById(UUID resourceId) throws IOException, PermitApiError, PermitContextError; + ResourceRead create(ResourceCreate resourceData) throws IOException, PermitApiError, PermitContextError; + ResourceRead replace(String resourceKey, ResourceReplace resourceData) throws IOException, PermitApiError, PermitContextError; + ResourceRead update(String resourceKey, ResourceUpdate resourceData) throws IOException, PermitApiError, PermitContextError; + void delete(String resourceKey) throws IOException, PermitApiError, PermitContextError; +} + +public class ResourcesApi extends BaseApi implements IResourcesApi { + public ResourcesApi(OkHttpClient client, PermitConfig config) { + super(client, config, LoggerFactory.getLogger(ResourcesApi.class)); + } + + private String getResourcesUrl(String url) { + return buildUrl( + String.format( + "/v2/schema/%s/%s/resources%s", + config.getContext().getProject(), + config.getContext().getEnvironment(), + url + ) + ); + } + + public ResourceRead[] list(int page, int perPage) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourcesUrl(""); + HttpUrl.Builder urlBuilder = Objects.requireNonNull(HttpUrl.parse(url)).newBuilder(); + Request request = buildRequest( + new Request.Builder() + .url( + urlBuilder + .addQueryParameter("page", Integer.toString(page)) + .addQueryParameter("per_page", Integer.toString(perPage)) + .build() + ) + .get() + ); + + try (Response response = client.newCall(request).execute()) { + String responseString = processResponseBody(response); + return (new Gson()).fromJson(responseString, ResourceRead[].class); + } + } + + public ResourceRead[] list(int page) throws IOException, PermitApiError, PermitContextError { + return this.list(page, 100); + } + + public ResourceRead[] list() throws IOException, PermitApiError, PermitContextError { + return this.list(1); + } + + public ResourceRead get(String resourceKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourcesUrl(String.format("/%s", resourceKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .get() + ); + + return this.callApiAndParseJson(request, ResourceRead.class); + } + + public ResourceRead getByKey(String resourceKey) throws IOException, PermitApiError, PermitContextError { + return this.get(resourceKey); + } + + public ResourceRead getById(UUID resourceId) throws IOException, PermitApiError, PermitContextError { + return this.get(resourceId.toString()); + } + + public ResourceRead create(ResourceCreate resourceData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourcesUrl(""); + RequestBody jsonBody = getJsonRequestBody(resourceData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .post(jsonBody) + ); + + return this.callApiAndParseJson(request, ResourceRead.class); + } + + public ResourceRead replace(String resourceKey, ResourceReplace resourceData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourcesUrl(String.format("/%s", resourceKey)); + RequestBody jsonBody = getJsonRequestBody(resourceData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .put(jsonBody) + ); + + return this.callApiAndParseJson(request, ResourceRead.class); + } + + public ResourceRead update(String resourceKey, ResourceUpdate resourceData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourcesUrl(String.format("/%s", resourceKey)); + RequestBody jsonBody = getJsonRequestBody(resourceData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .patch(jsonBody) + ); + + return this.callApiAndParseJson(request, ResourceRead.class); + } + + public void delete(String resourceKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getResourcesUrl(String.format("/%s", resourceKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .delete() + ); + + try (Response response = client.newCall(request).execute()) { + processResponseBody(response, false); + } + } +} diff --git a/src/main/java/io/permit/sdk/api/RolesApi.java b/src/main/java/io/permit/sdk/api/RolesApi.java new file mode 100644 index 0000000..4389fb8 --- /dev/null +++ b/src/main/java/io/permit/sdk/api/RolesApi.java @@ -0,0 +1,163 @@ +package io.permit.sdk.api; + +import com.google.gson.Gson; +import io.permit.sdk.ApiKeyLevel; +import io.permit.sdk.PermitConfig; +import io.permit.sdk.openapi.models.*; +import okhttp3.*; +import org.jetbrains.annotations.NotNull; +import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Objects; +import java.util.UUID; + +interface IRolesApi { + RoleRead[] list(int page, int perPage) throws IOException, PermitApiError, PermitContextError; + RoleRead[] list(int page) throws IOException, PermitApiError, PermitContextError; + RoleRead[] list() throws IOException, PermitApiError, PermitContextError; + RoleRead get(String roleKey) throws IOException, PermitApiError, PermitContextError; + RoleRead getByKey(String roleKey) throws IOException, PermitApiError, PermitContextError; + RoleRead getById(UUID roleId) throws IOException, PermitApiError, PermitContextError; + RoleRead create(RoleCreate roleData) throws IOException, PermitApiError, PermitContextError; + RoleRead update(String roleKey, RoleUpdate roleData) throws IOException, PermitApiError, PermitContextError; + void delete(String roleKey) throws IOException, PermitApiError, PermitContextError; + RoleRead assignPermissions(String roleKey, ArrayList permissions) throws IOException, PermitApiError, PermitContextError; + RoleRead removePermissions(String roleKey, ArrayList permissions) throws IOException, PermitApiError, PermitContextError; +} + +public class RolesApi extends BaseApi implements IRolesApi { + public RolesApi(OkHttpClient client, PermitConfig config) { + super(client, config, LoggerFactory.getLogger(RolesApi.class)); + } + + private String getRolesUrl(String url) { + return buildUrl( + String.format( + "/v2/schema/%s/%s/roles%s", + config.getContext().getProject(), + config.getContext().getEnvironment(), + url + ) + ); + } + + public RoleRead[] list(int page, int perPage) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getRolesUrl(""); + HttpUrl.Builder urlBuilder = Objects.requireNonNull(HttpUrl.parse(url)).newBuilder(); + Request request = buildRequest( + new Request.Builder() + .url( + urlBuilder + .addQueryParameter("page", Integer.toString(page)) + .addQueryParameter("per_page", Integer.toString(perPage)) + .build() + ) + .get() + ); + + try (Response response = client.newCall(request).execute()) { + String responseString = processResponseBody(response); + return (new Gson()).fromJson(responseString, RoleRead[].class); + } + } + + public RoleRead[] list(int page) throws IOException, PermitApiError, PermitContextError { + return this.list(page, 100); + } + + public RoleRead[] list() throws IOException, PermitApiError, PermitContextError { + return this.list(1); + } + + public RoleRead get(String roleKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getRolesUrl(String.format("/%s", roleKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .get() + ); + + return this.callApiAndParseJson(request, RoleRead.class); + } + + public RoleRead getByKey(String roleKey) throws IOException, PermitApiError, PermitContextError { + return this.get(roleKey); + } + + public RoleRead getById(UUID roleId) throws IOException, PermitApiError, PermitContextError { + return this.get(roleId.toString()); + } + + public RoleRead create(RoleCreate roleData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getRolesUrl(""); + RequestBody jsonBody = getJsonRequestBody(roleData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .post(jsonBody) + ); + + return this.callApiAndParseJson(request, RoleRead.class); + } + + public RoleRead update(String roleKey, RoleUpdate roleData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getRolesUrl(String.format("/%s", roleKey)); + RequestBody jsonBody = getJsonRequestBody(roleData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .patch(jsonBody) + ); + + return this.callApiAndParseJson(request, RoleRead.class); + } + + public void delete(String roleKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getRolesUrl(String.format("/%s", roleKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .delete() + ); + + try (Response response = client.newCall(request).execute()) { + processResponseBody(response, false); + } + } + + public RoleRead assignPermissions(String roleKey, ArrayList permissions) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getRolesUrl(String.format("/%s/permissions", roleKey)); + RequestBody jsonBody = getJsonRequestBody(new AddRolePermissions(permissions)); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .post(jsonBody) + ); + + return this.callApiAndParseJson(request, RoleRead.class); + } + + public RoleRead removePermissions(String roleKey, ArrayList permissions) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getRolesUrl(String.format("/%s/permissions", roleKey)); + RequestBody jsonBody = getJsonRequestBody(new RemoveRolePermissions(permissions)); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .delete(jsonBody) + ); + + return this.callApiAndParseJson(request, RoleRead.class); + } +} diff --git a/src/main/java/io/permit/sdk/api/TenantsApi.java b/src/main/java/io/permit/sdk/api/TenantsApi.java new file mode 100644 index 0000000..228be56 --- /dev/null +++ b/src/main/java/io/permit/sdk/api/TenantsApi.java @@ -0,0 +1,162 @@ +package io.permit.sdk.api; + +import com.google.gson.Gson; +import io.permit.sdk.ApiKeyLevel; +import io.permit.sdk.PermitConfig; +import io.permit.sdk.api.models.CreateOrUpdateResult; +import io.permit.sdk.openapi.models.*; +import okhttp3.*; +import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Objects; +import java.util.UUID; + +interface ITenantsApi { + TenantRead[] list(int page, int perPage) throws IOException, PermitApiError, PermitContextError; + TenantRead[] list(int page) throws IOException, PermitApiError, PermitContextError; + TenantRead[] list() throws IOException, PermitApiError, PermitContextError; + PaginatedResultUserRead listTenantUsers(String tenantKey, int page, int perPage) throws IOException, PermitApiError, PermitContextError; + PaginatedResultUserRead listTenantUsers(String tenantKey, int page) throws IOException, PermitApiError, PermitContextError; + PaginatedResultUserRead listTenantUsers(String tenantKey) throws IOException, PermitApiError, PermitContextError; + TenantRead get(String tenantKey) throws IOException, PermitApiError, PermitContextError; + TenantRead getByKey(String tenantKey) throws IOException, PermitApiError, PermitContextError; + TenantRead getById(UUID tenantId) throws IOException, PermitApiError, PermitContextError; + TenantRead create(TenantCreate tenantData) throws IOException, PermitApiError, PermitContextError; + TenantRead update(String tenantKey, TenantUpdate tenantData) throws IOException, PermitApiError, PermitContextError; + void delete(String tenantKey) throws IOException, PermitApiError, PermitContextError; +} + +public class TenantsApi extends BaseApi implements ITenantsApi { + public TenantsApi(OkHttpClient client, PermitConfig config) { + super(client, config, LoggerFactory.getLogger(TenantsApi.class)); + } + + private String getTenantsUrl(String url) { + return buildUrl( + String.format( + "/v2/facts/%s/%s/tenants%s", + config.getContext().getProject(), + config.getContext().getEnvironment(), + url + ) + ); + } + + public TenantRead[] list(int page, int perPage) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getTenantsUrl(""); + HttpUrl.Builder urlBuilder = Objects.requireNonNull(HttpUrl.parse(url)).newBuilder(); + Request request = buildRequest( + new Request.Builder() + .url( + urlBuilder + .addQueryParameter("page", Integer.toString(page)) + .addQueryParameter("per_page", Integer.toString(perPage)) + .build() + ) + .get() + ); + + try (Response response = client.newCall(request).execute()) { + String responseString = processResponseBody(response); + return (new Gson()).fromJson(responseString, TenantRead[].class); + } + } + + public TenantRead[] list(int page) throws IOException, PermitApiError, PermitContextError { + return this.list(page, 100); + } + + public TenantRead[] list() throws IOException, PermitApiError, PermitContextError { + return this.list(1); + } + + public PaginatedResultUserRead listTenantUsers(String tenantKey, int page, int perPage) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getTenantsUrl(String.format("/%s/users", tenantKey)); + HttpUrl.Builder urlBuilder = Objects.requireNonNull(HttpUrl.parse(url)).newBuilder(); + Request request = buildRequest( + new Request.Builder() + .url( + urlBuilder + .addQueryParameter("page", Integer.toString(page)) + .addQueryParameter("per_page", Integer.toString(perPage)) + .build() + ) + .get() + ); + + return this.callApiAndParseJson(request, PaginatedResultUserRead.class); + } + + public PaginatedResultUserRead listTenantUsers(String tenantKey, int page) throws IOException, PermitApiError, PermitContextError { + return this.listTenantUsers(tenantKey, page, 100); + } + + public PaginatedResultUserRead listTenantUsers(String tenantKey) throws IOException, PermitApiError, PermitContextError { + return this.listTenantUsers(tenantKey, 1); + } + + public TenantRead get(String tenantKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getTenantsUrl(String.format("/%s", tenantKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .get() + ); + + return this.callApiAndParseJson(request, TenantRead.class); + } + + public TenantRead getByKey(String tenantKey) throws IOException, PermitApiError, PermitContextError { + return this.get(tenantKey); + } + + public TenantRead getById(UUID tenantId) throws IOException, PermitApiError, PermitContextError { + return this.get(tenantId.toString()); + } + + public TenantRead create(TenantCreate tenantData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getTenantsUrl(""); + RequestBody jsonBody = getJsonRequestBody(tenantData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .post(jsonBody) + ); + + return this.callApiAndParseJson(request, TenantRead.class); + } + + public TenantRead update(String tenantKey, TenantUpdate tenantData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getTenantsUrl(String.format("/%s", tenantKey)); + RequestBody jsonBody = getJsonRequestBody(tenantData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .patch(jsonBody) + ); + + return this.callApiAndParseJson(request, TenantRead.class); + } + + public void delete(String tenantKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getTenantsUrl(String.format("/%s", tenantKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .delete() + ); + + try (Response response = client.newCall(request).execute()) { + processResponseBody(response, false); + } + } +} diff --git a/src/main/java/io/permit/sdk/api/UsersApi.java b/src/main/java/io/permit/sdk/api/UsersApi.java new file mode 100644 index 0000000..3f01b4c --- /dev/null +++ b/src/main/java/io/permit/sdk/api/UsersApi.java @@ -0,0 +1,261 @@ +package io.permit.sdk.api; + +import com.google.gson.Gson; +import io.permit.sdk.ApiKeyLevel; +import io.permit.sdk.PermitConfig; +import io.permit.sdk.api.models.CreateOrUpdateResult; +import io.permit.sdk.enforcement.User; +import io.permit.sdk.openapi.models.*; +import okhttp3.*; +import org.jetbrains.annotations.NotNull; +import org.slf4j.LoggerFactory; +import java.io.IOException; +import java.util.ArrayList; +import java.util.Objects; +import java.util.UUID; + +interface IUsersApi { + PaginatedResultUserRead list(int page, int perPage) throws IOException, PermitApiError, PermitContextError; + PaginatedResultUserRead list(int page) throws IOException, PermitApiError, PermitContextError; + PaginatedResultUserRead list() throws IOException, PermitApiError, PermitContextError; + UserRead get(String userKey) throws IOException, PermitApiError, PermitContextError; + UserRead getByKey(String userKey) throws IOException, PermitApiError, PermitContextError; + UserRead getById(UUID userId) throws IOException, PermitApiError, PermitContextError; + UserRead create(UserCreate userData) throws IOException, PermitApiError, PermitContextError; + UserRead update(String userKey, UserUpdate userData) throws IOException, PermitApiError, PermitContextError; + CreateOrUpdateResult sync(UserCreate userData) throws IOException, PermitApiError, PermitContextError; + CreateOrUpdateResult sync(User user) throws IOException, PermitApiError, PermitContextError; + void delete(String userKey) throws IOException, PermitApiError, PermitContextError; + RoleAssignmentRead assignRole(String userKey, String roleKey, String tenantKey) throws IOException, PermitApiError, PermitContextError; + void unassignRole(String userKey, String roleKey, String tenantKey) throws IOException, PermitApiError, PermitContextError; + RoleAssignmentRead[] getAssignedRoles(@NotNull String userKey, String tenantKey, int page, int perPage) throws IOException, PermitApiError, PermitContextError; + RoleAssignmentRead[] getAssignedRoles(@NotNull String userKey, int page, int perPage) throws IOException, PermitApiError, PermitContextError; + RoleAssignmentRead[] getAssignedRoles(@NotNull String userKey, int page) throws IOException, PermitApiError, PermitContextError; + RoleAssignmentRead[] getAssignedRoles(@NotNull String userKey) throws IOException, PermitApiError, PermitContextError; +} + +public class UsersApi extends BaseApi implements IUsersApi { + public UsersApi(OkHttpClient client, PermitConfig config) { + super(client, config, LoggerFactory.getLogger(UsersApi.class)); + } + + private String getUsersUrl(String url) { + return buildUrl( + String.format( + "/v2/facts/%s/%s/users%s", + config.getContext().getProject(), + config.getContext().getEnvironment(), + url + ) + ); + } + + public PaginatedResultUserRead list(int page, int perPage) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getUsersUrl(""); + HttpUrl.Builder urlBuilder = Objects.requireNonNull(HttpUrl.parse(url)).newBuilder(); + Request request = buildRequest( + new Request.Builder() + .url( + urlBuilder + .addQueryParameter("page", Integer.toString(page)) + .addQueryParameter("per_page", Integer.toString(perPage)) + .build() + ) + .get() + ); + + try (Response response = client.newCall(request).execute()) { + String responseString = processResponseBody(response); + return (new Gson()).fromJson(responseString, PaginatedResultUserRead.class); + } + } + + public PaginatedResultUserRead list(int page) throws IOException, PermitApiError, PermitContextError { + return this.list(page, 100); + } + + public PaginatedResultUserRead list() throws IOException, PermitApiError, PermitContextError { + return this.list(1); + } + + public UserRead get(String userKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getUsersUrl(String.format("/%s", userKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .get() + ); + + return this.callApiAndParseJson(request, UserRead.class); + } + + public UserRead getByKey(String userKey) throws IOException, PermitApiError, PermitContextError { + return this.get(userKey); + } + + public UserRead getById(UUID userId) throws IOException, PermitApiError, PermitContextError { + return this.get(userId.toString()); + } + + public UserRead create(UserCreate userData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getUsersUrl(""); + RequestBody jsonBody = getJsonRequestBody(userData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .post(jsonBody) + ); + + return this.callApiAndParseJson(request, UserRead.class); + } + + public UserRead update(String userKey, UserUpdate userData) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getUsersUrl(String.format("/%s", userKey)); + RequestBody jsonBody = getJsonRequestBody(userData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .patch(jsonBody) + ); + + return this.callApiAndParseJson(request, UserRead.class); + } + + public CreateOrUpdateResult sync(UserCreate userData) throws IOException, PermitApiError, PermitContextError { + if (userData.key == null) { + throw new PermitApiError( + "You cannot pass a null key to permit.api.users.sync()", + 406, // not acceptable + "{}" + ); + } + + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getUsersUrl(String.format("/%s", userData.key)); // TODO: fix url to PUT /v2/.../users + RequestBody jsonBody = getJsonRequestBody(userData); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .put(jsonBody) + ); + + try (Response response = client.newCall(request).execute()) { + String responseString = processResponseBody(response); + UserRead result = (new Gson()).fromJson(responseString, UserRead.class); + boolean created = (response.code() == 200); // TODO: fix response code to 201 + return new CreateOrUpdateResult(result, created); + } + } + + public CreateOrUpdateResult sync(User user) throws IOException, PermitApiError, PermitContextError { + UserCreate userData = new UserCreate(user.getKey()); + if (user.getEmail() != null) { + userData.withEmail(user.getEmail()); + } + if (user.getFirstName() != null) { + userData.withFirstName(user.getFirstName()); + } + if (user.getLastName() != null) { + userData.withLastName(user.getLastName()); + } + if (user.getAttributes() != null && user.getAttributes().size() > 0) { + userData.withAttributes(user.getAttributes()); + } + + return this.sync(userData); + } + + public void delete(String userKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getUsersUrl(String.format("/%s", userKey)); + Request request = buildRequest( + new Request.Builder() + .url(url) + .delete() + ); + + try (Response response = client.newCall(request).execute()) { + processResponseBody(response, false); + } + } + + public RoleAssignmentRead assignRole(String userKey, String roleKey, String tenantKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getUsersUrl(String.format("/%s/roles", userKey)); + RequestBody jsonBody = getJsonRequestBody(new UserRoleCreate(roleKey, tenantKey)); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .post(jsonBody) + ); + + return this.callApiAndParseJson(request, RoleAssignmentRead.class); + } + + public void unassignRole(String userKey, String roleKey, String tenantKey) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = getUsersUrl(String.format("/%s/roles", userKey)); + RequestBody jsonBody = getJsonRequestBody(new UserRoleRemove(roleKey, tenantKey)); + + Request request = buildRequest( + new Request.Builder() + .url(url) + .delete(jsonBody) + ); + + try (Response response = client.newCall(request).execute()) { + processResponseBody(response, false); + } + } + + public RoleAssignmentRead[] getAssignedRoles(@NotNull String userKey, String tenantKey, int page, int perPage) throws IOException, PermitApiError, PermitContextError { + ensureContext(ApiKeyLevel.ENVIRONMENT_LEVEL_API_KEY); + String url = buildUrl( + String.format( + "/v2/facts/%s/%s/role_assignments", + config.getContext().getProject(), + config.getContext().getEnvironment() + ) + ); + HttpUrl.Builder urlBuilder = Objects.requireNonNull(HttpUrl.parse(url)).newBuilder(); + if (tenantKey != null) { + urlBuilder.addQueryParameter("tenant", tenantKey); + } + Request request = buildRequest( + new Request.Builder() + .url( + urlBuilder + .addQueryParameter("user", userKey) + .addQueryParameter("page", Integer.toString(page)) + .addQueryParameter("per_page", Integer.toString(perPage)) + .build() + ) + .get() + ); + + try (Response response = client.newCall(request).execute()) { + String responseString = processResponseBody(response); + return (new Gson()).fromJson(responseString, RoleAssignmentRead[].class); + } + } + + public RoleAssignmentRead[] getAssignedRoles(@NotNull String userKey, int page, int perPage) throws IOException, PermitApiError, PermitContextError { + return this.getAssignedRoles(userKey, null, page, perPage); + } + + public RoleAssignmentRead[] getAssignedRoles(@NotNull String userKey, int page) throws IOException, PermitApiError, PermitContextError { + return this.getAssignedRoles(userKey, page, 100); + } + + public RoleAssignmentRead[] getAssignedRoles(@NotNull String userKey) throws IOException, PermitApiError, PermitContextError { + return this.getAssignedRoles(userKey, 1); + } +} diff --git a/src/main/java/io/permit/sdk/api/models/CreateOrUpdateResult.java b/src/main/java/io/permit/sdk/api/models/CreateOrUpdateResult.java new file mode 100644 index 0000000..ae39001 --- /dev/null +++ b/src/main/java/io/permit/sdk/api/models/CreateOrUpdateResult.java @@ -0,0 +1,18 @@ +package io.permit.sdk.api.models; + +public class CreateOrUpdateResult { + private final T object; + private final boolean created; + public CreateOrUpdateResult(T object, boolean created) { + this.object = object; + this.created = created; + } + + public T getResult() { + return this.object; + } + + public boolean wasCreated() { + return this.created; + } +} diff --git a/src/main/java/io/permit/sdk/api/models/ElementsLoginResult.java b/src/main/java/io/permit/sdk/api/models/ElementsLoginResult.java new file mode 100644 index 0000000..fde738e --- /dev/null +++ b/src/main/java/io/permit/sdk/api/models/ElementsLoginResult.java @@ -0,0 +1,32 @@ +package io.permit.sdk.api.models; + +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; +import io.permit.sdk.openapi.models.EmbeddedLoginRequestOutput; + +import java.util.HashMap; +import java.util.Map; + +public class ElementsLoginResult extends EmbeddedLoginRequestOutput { + @SerializedName("content") + @Expose + public Map content; + + public ElementsLoginResult() { + content = new HashMap(); + } + + /** + * + * @param redirectUrl + */ + public ElementsLoginResult(String redirectUrl) { + super(redirectUrl); + content = new HashMap(); + } + + public ElementsLoginResult withContent(Map content) { + this.content = content; + return this; + } +} diff --git a/src/main/java/io/permit/sdk/enforcement/Enforcer.java b/src/main/java/io/permit/sdk/enforcement/Enforcer.java index dce38aa..c8f9811 100644 --- a/src/main/java/io/permit/sdk/enforcement/Enforcer.java +++ b/src/main/java/io/permit/sdk/enforcement/Enforcer.java @@ -2,6 +2,7 @@ import com.google.gson.Gson; import io.permit.sdk.PermitConfig; +import io.permit.sdk.api.HttpLoggingInterceptor; import io.permit.sdk.util.Context; import io.permit.sdk.util.ContextStore; @@ -18,12 +19,12 @@ import org.slf4j.LoggerFactory; class EnforcerInput { - public final String user; + public final User user; public final String action; public final Resource resource; public final HashMap context; - EnforcerInput(String user, String action, Resource resource, HashMap context) { + EnforcerInput(User user, String action, Resource resource, HashMap context) { this.user = user; this.action = action; this.resource = resource; @@ -42,11 +43,14 @@ class OpaResult { public class Enforcer implements IEnforcerApi { final static Logger logger = LoggerFactory.getLogger(Enforcer.class); public final ContextStore contextStore = new ContextStore(); - private final OkHttpClient client = new OkHttpClient(); + private final OkHttpClient client; private final PermitConfig config; public Enforcer(PermitConfig config) { this.config = config; + this.client = new OkHttpClient.Builder() + .addInterceptor(new HttpLoggingInterceptor(logger, config)) + .build(); } @Override @@ -55,7 +59,7 @@ public boolean check(User user, String action, Resource resource, Context contex Context queryContext = this.contextStore.getDerivedContext(context); EnforcerInput input = new EnforcerInput( - user.getKey(), + user, action, normalizedResource, queryContext @@ -79,7 +83,7 @@ public boolean check(User user, String action, Resource resource, Context contex if (!response.isSuccessful()) { String errorMessage = String.format( "Error in permit.check(%s, %s, %s): got unexpected status code %d", - user, + user.toString(), action, resource, response.code() diff --git a/src/main/java/io/permit/sdk/enforcement/Resource.java b/src/main/java/io/permit/sdk/enforcement/Resource.java index 231c400..1112993 100644 --- a/src/main/java/io/permit/sdk/enforcement/Resource.java +++ b/src/main/java/io/permit/sdk/enforcement/Resource.java @@ -6,25 +6,45 @@ public class Resource { private String type; - private String id = null; + private String key = null; private String tenant = null; private HashMap attributes = null; private HashMap context = new HashMap<>(); public Resource(Builder builder) { this.type = builder.type; - this.id = builder.id; + this.key = builder.key; this.tenant = builder.tenant; this.attributes = builder.attributes; this.context = builder.context; } + public String getType() { + return this.type; + } + + public String getKey() { + return this.key; + } + + public String getTenant() { + return this.tenant; + } + + public HashMap getAttributes() { + return this.attributes; + } + + public HashMap getContext() { + return this.context; + } + public static Resource fromString(String resourceString) { return new Resource(new Resource.Builder(resourceString)); } public String toString() { - return (this.id == null) ? String.format("%s:*", this.type) : String.format("%s:%s", this.type, this.id); + return (this.key == null) ? String.format("%s:*", this.type) : String.format("%s:%s", this.type, this.key); } public Resource normalize(PermitConfig config) { @@ -41,7 +61,7 @@ public Resource normalize(PermitConfig config) { } Resource normalizedResource = new Resource.Builder(this.type) - .withId(this.id) + .withKey(this.key) .withTenant(safeTenant) .withAttributes(this.attributes) .withContext(safeContext) @@ -52,7 +72,7 @@ public Resource normalize(PermitConfig config) { public static class Builder { private String type; - private String id = null; + private String key = null; private String tenant = null; private HashMap attributes = null; private HashMap context = new HashMap<>(); @@ -71,12 +91,12 @@ public Builder(String resourceString) { } this.type = parts[0]; if (parts.length > 1) { - this.id = parts[1]; + this.key = parts[1]; } } - public Builder withId(String id) { - this.id = id; + public Builder withKey(String key) { + this.key = key; return this; } diff --git a/src/main/java/io/permit/sdk/enforcement/User.java b/src/main/java/io/permit/sdk/enforcement/User.java index 8acb5ef..c611fa2 100644 --- a/src/main/java/io/permit/sdk/enforcement/User.java +++ b/src/main/java/io/permit/sdk/enforcement/User.java @@ -8,15 +8,13 @@ public class User { private String firstName = null; private String lastName = null; private String email = null; - private ArrayList roles = null; - private HashMap attributes = null; + private HashMap attributes = null; public User(Builder builder) { this.key = builder.key; this.firstName = builder.firstName; this.lastName = builder.lastName; this.email = builder.email; - this.roles = builder.roles; this.attributes = builder.attributes; } @@ -32,13 +30,28 @@ public static User fromString(String userKey) { return new User(new User.Builder(userKey)); } + public String getFirstName() { + return firstName; + } + + public String getLastName() { + return lastName; + } + + public String getEmail() { + return email; + } + + public HashMap getAttributes() { + return attributes; + } + public static class Builder { - private String key; + private final String key; private String firstName = null; private String lastName = null; private String email = null; - private ArrayList roles = null; - private HashMap attributes = null; + private HashMap attributes = null; public Builder(String userKey) { this.key = userKey; @@ -59,12 +72,7 @@ public Builder withEmail(String email) { return this; } - public Builder withRoles(ArrayList roles) { - this.roles = roles; - return this; - } - - public Builder withAttributes(HashMap attributes) { + public Builder withAttributes(HashMap attributes) { this.attributes = attributes; return this; } diff --git a/src/main/java/io/permit/sdk/openapi/models/APIKeyScopeRead.java b/src/main/java/io/permit/sdk/openapi/models/APIKeyScopeRead.java new file mode 100644 index 0000000..37ca36d --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/APIKeyScopeRead.java @@ -0,0 +1,78 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * APIKeyScopeRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class APIKeyScopeRead { + + /** + * Organization Id + *

+ * Unique id of the organization that the api_key belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the api_key belongs to. + * + */ + @SerializedName("project_id") + @Expose + public String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the api_key belongs to. + * + */ + @SerializedName("environment_id") + @Expose + public String environmentId; + + /** + * No args constructor for use in serialization + * + */ + public APIKeyScopeRead() { + } + + /** + * + * @param organizationId + */ + public APIKeyScopeRead(String organizationId) { + super(); + this.organizationId = organizationId; + } + + public APIKeyScopeRead withOrganizationId(String organizationId) { + this.organizationId = organizationId; + return this; + } + + public APIKeyScopeRead withProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + public APIKeyScopeRead withEnvironmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ActionBlockEditable.java b/src/main/java/io/permit/sdk/openapi/models/ActionBlockEditable.java new file mode 100644 index 0000000..a1dc6bb --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ActionBlockEditable.java @@ -0,0 +1,47 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ActionBlockEditable + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ActionBlockEditable { + + /** + * Name + *

+ * a more descriptive name for the action + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * optional description string explaining what this action represents in your system + * + */ + @SerializedName("description") + @Expose + public String description; + + public ActionBlockEditable withName(String name) { + this.name = name; + return this; + } + + public ActionBlockEditable withDescription(String description) { + this.description = description; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ActionBlockRead.java b/src/main/java/io/permit/sdk/openapi/models/ActionBlockRead.java new file mode 100644 index 0000000..7431e74 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ActionBlockRead.java @@ -0,0 +1,92 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ActionBlockRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ActionBlockRead { + + /** + * Name + *

+ * a more descriptive name for the action + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * optional description string explaining what this action represents in your system + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Id + *

+ * Unique id of the action + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * Key + *

+ * action key + * + */ + @SerializedName("key") + @Expose + public String key; + + /** + * No args constructor for use in serialization + * + */ + public ActionBlockRead() { + } + + /** + * + * @param id + */ + public ActionBlockRead(String id) { + super(); + this.id = id; + } + + public ActionBlockRead withName(String name) { + this.name = name; + return this; + } + + public ActionBlockRead withDescription(String description) { + this.description = description; + return this; + } + + public ActionBlockRead withId(String id) { + this.id = id; + return this; + } + + public ActionBlockRead withKey(String key) { + this.key = key; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/AddRolePermissions.java b/src/main/java/io/permit/sdk/openapi/models/AddRolePermissions.java new file mode 100644 index 0000000..8c93cf0 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/AddRolePermissions.java @@ -0,0 +1,51 @@ + +package io.permit.sdk.openapi.models; + +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * AddRolePermissions + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class AddRolePermissions { + + /** + * Permissions + *

+ * List of permissions to assign to the role. If a permission is already granted to the role it is skipped. Each permission can be either a resource action id, or `{resource_key}:{action_key}`, i.e: the "permission name". + * (Required) + * + */ + @SerializedName("permissions") + @Expose + public List permissions; + + /** + * No args constructor for use in serialization + * + */ + public AddRolePermissions() { + } + + /** + * + * @param permissions + */ + public AddRolePermissions(List permissions) { + super(); + this.permissions = permissions; + } + + public AddRolePermissions withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/AttributeBlockEditable.java b/src/main/java/io/permit/sdk/openapi/models/AttributeBlockEditable.java new file mode 100644 index 0000000..37b2eec --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/AttributeBlockEditable.java @@ -0,0 +1,62 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * AttributeBlockEditable + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class AttributeBlockEditable { + + /** + * + * (Required) + * + */ + @SerializedName("type") + @Expose + public AttributeType type; + /** + * Description + *

+ * optional description string explaining what data this attribute will store + * + */ + @SerializedName("description") + @Expose + public String description; + + /** + * No args constructor for use in serialization + * + */ + public AttributeBlockEditable() { + } + + /** + * + * @param type + */ + public AttributeBlockEditable(AttributeType type) { + super(); + this.type = type; + } + + public AttributeBlockEditable withType(AttributeType type) { + this.type = type; + return this; + } + + public AttributeBlockEditable withDescription(String description) { + this.description = description; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/AttributeBlockRead.java b/src/main/java/io/permit/sdk/openapi/models/AttributeBlockRead.java new file mode 100644 index 0000000..6707ee0 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/AttributeBlockRead.java @@ -0,0 +1,93 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * AttributeBlockRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class AttributeBlockRead { + + /** + * + * (Required) + * + */ + @SerializedName("type") + @Expose + public AttributeType type; + /** + * Description + *

+ * optional description string explaining what data this attribute will store + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Id + *

+ * Unique id of the attribute + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * Key + *

+ * action key + * + */ + @SerializedName("key") + @Expose + public String key; + + /** + * No args constructor for use in serialization + * + */ + public AttributeBlockRead() { + } + + /** + * + * @param id + * @param type + */ + public AttributeBlockRead(AttributeType type, String id) { + super(); + this.type = type; + this.id = id; + } + + public AttributeBlockRead withType(AttributeType type) { + this.type = type; + return this; + } + + public AttributeBlockRead withDescription(String description) { + this.description = description; + return this; + } + + public AttributeBlockRead withId(String id) { + this.id = id; + return this; + } + + public AttributeBlockRead withKey(String key) { + this.key = key; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/AttributeType.java b/src/main/java/io/permit/sdk/openapi/models/AttributeType.java new file mode 100644 index 0000000..d30137a --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/AttributeType.java @@ -0,0 +1,62 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.SerializedName; + + +/** + * AttributeType + *

+ * The type of the attribute, we currently support: `bool`, `number` (ints, floats), `time` (a timestamp), `string`, and `json`. + * + */ +@Generated("jsonschema2pojo") +public enum AttributeType { + + @SerializedName("bool") + BOOL("bool"), + @SerializedName("number") + NUMBER("number"), + @SerializedName("string") + STRING("string"), + @SerializedName("time") + TIME("time"), + @SerializedName("array") + ARRAY("array"), + @SerializedName("json") + JSON("json"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (AttributeType c: values()) { + CONSTANTS.put(c.value, c); + } + } + + AttributeType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static AttributeType fromValue(String value) { + AttributeType constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/Attributes.java b/src/main/java/io/permit/sdk/openapi/models/Attributes.java new file mode 100644 index 0000000..78ffb07 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/Attributes.java @@ -0,0 +1,17 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; + + +/** + * Attributes + *

+ * Arbitraty resource attributes that will be used to enforce attribute-based access control policies. + * + */ +@Generated("jsonschema2pojo") +public class Attributes { + + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ConditionSetCreate.java b/src/main/java/io/permit/sdk/openapi/models/ConditionSetCreate.java new file mode 100644 index 0000000..4b29f13 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ConditionSetCreate.java @@ -0,0 +1,136 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ConditionSetCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ConditionSetCreate { + + /** + * Key + *

+ * A unique id by which Permit will identify the condition set. The key will be used as the generated rego rule name. + * (Required) + * + */ + @SerializedName("key") + @Expose + public java.lang.String key; + /** + * the type of the set: UserSet or ResourceSet + * + */ + @SerializedName("type") + @Expose + public ConditionSetType type; + /** + * Autogenerated + *

+ * whether the set was autogenerated by the system. + * + */ + @SerializedName("autogenerated") + @Expose + public Boolean autogenerated = false; + /** + * Resource Id + *

+ * For ResourceSets, the id of the base resource. + * + */ + @SerializedName("resource_id") + @Expose + public java.lang.String resourceId; + /** + * Name + *

+ * A descriptive name for the set, i.e: 'US based employees' or 'Users behind VPN' + * (Required) + * + */ + @SerializedName("name") + @Expose + public java.lang.String name; + /** + * Description + *

+ * an optional longer description of the set + * + */ + @SerializedName("description") + @Expose + public java.lang.String description; + /** + * Conditions + *

+ * a boolean expression that consists of multiple conditions, with and/or logic. + * + */ + @SerializedName("conditions") + @Expose + public HashMap conditions; + + /** + * No args constructor for use in serialization + * + */ + public ConditionSetCreate() { + } + + /** + * + * @param name + * @param key + */ + public ConditionSetCreate(java.lang.String key, java.lang.String name) { + super(); + this.key = key; + this.name = name; + } + + public ConditionSetCreate withKey(java.lang.String key) { + this.key = key; + return this; + } + + public ConditionSetCreate withType(ConditionSetType type) { + this.type = type; + return this; + } + + public ConditionSetCreate withAutogenerated(Boolean autogenerated) { + this.autogenerated = autogenerated; + return this; + } + + public ConditionSetCreate withResourceId(java.lang.String resourceId) { + this.resourceId = resourceId; + return this; + } + + public ConditionSetCreate withName(java.lang.String name) { + this.name = name; + return this; + } + + public ConditionSetCreate withDescription(java.lang.String description) { + this.description = description; + return this; + } + + public ConditionSetCreate withConditions(HashMap conditions) { + this.conditions = conditions; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ConditionSetRead.java b/src/main/java/io/permit/sdk/openapi/models/ConditionSetRead.java new file mode 100644 index 0000000..89c400b --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ConditionSetRead.java @@ -0,0 +1,253 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ConditionSetRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ConditionSetRead { + + /** + * Key + *

+ * A unique id by which Permit will identify the condition set. The key will be used as the generated rego rule name. + * (Required) + * + */ + @SerializedName("key") + @Expose + public java.lang.String key; + /** + * the type of the set: UserSet or ResourceSet + * + */ + @SerializedName("type") + @Expose + public ConditionSetType type; + /** + * Autogenerated + *

+ * whether the set was autogenerated by the system. + * + */ + @SerializedName("autogenerated") + @Expose + public Boolean autogenerated = false; + /** + * Resource Id + *

+ * For ResourceSets, the id of the base resource. + * + */ + @SerializedName("resource_id") + @Expose + public java.lang.String resourceId; + /** + * Id + *

+ * Unique id of the condition set + * (Required) + * + */ + @SerializedName("id") + @Expose + public java.lang.String id; + /** + * Organization Id + *

+ * Unique id of the organization that the condition set belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public java.lang.String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the condition set belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public java.lang.String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the condition set belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public java.lang.String environmentId; + /** + * Created At + *

+ * Date and time when the condition set was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the condition set was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + /** + * ResourceRead + *

+ * + * + */ + @SerializedName("resource") + @Expose + public ResourceRead resource; + /** + * Name + *

+ * A descriptive name for the set, i.e: 'US based employees' or 'Users behind VPN' + * (Required) + * + */ + @SerializedName("name") + @Expose + public java.lang.String name; + /** + * Description + *

+ * an optional longer description of the set + * + */ + @SerializedName("description") + @Expose + public java.lang.String description; + /** + * Conditions + *

+ * a boolean expression that consists of multiple conditions, with and/or logic. + * + */ + @SerializedName("conditions") + @Expose + public HashMap conditions; + + /** + * No args constructor for use in serialization + * + */ + public ConditionSetRead() { + } + + /** + * + * @param organizationId + * @param createdAt + * @param environmentId + * @param name + * @param id + * @param projectId + * @param key + * @param updatedAt + */ + public ConditionSetRead(java.lang.String key, java.lang.String id, java.lang.String organizationId, java.lang.String projectId, java.lang.String environmentId, Date createdAt, Date updatedAt, java.lang.String name) { + super(); + this.key = key; + this.id = id; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.name = name; + } + + public ConditionSetRead withKey(java.lang.String key) { + this.key = key; + return this; + } + + public ConditionSetRead withType(ConditionSetType type) { + this.type = type; + return this; + } + + public ConditionSetRead withAutogenerated(Boolean autogenerated) { + this.autogenerated = autogenerated; + return this; + } + + public ConditionSetRead withResourceId(java.lang.String resourceId) { + this.resourceId = resourceId; + return this; + } + + public ConditionSetRead withId(java.lang.String id) { + this.id = id; + return this; + } + + public ConditionSetRead withOrganizationId(java.lang.String organizationId) { + this.organizationId = organizationId; + return this; + } + + public ConditionSetRead withProjectId(java.lang.String projectId) { + this.projectId = projectId; + return this; + } + + public ConditionSetRead withEnvironmentId(java.lang.String environmentId) { + this.environmentId = environmentId; + return this; + } + + public ConditionSetRead withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public ConditionSetRead withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public ConditionSetRead withResource(ResourceRead resource) { + this.resource = resource; + return this; + } + + public ConditionSetRead withName(java.lang.String name) { + this.name = name; + return this; + } + + public ConditionSetRead withDescription(java.lang.String description) { + this.description = description; + return this; + } + + public ConditionSetRead withConditions(HashMap conditions) { + this.conditions = conditions; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ConditionSetRuleCreate.java b/src/main/java/io/permit/sdk/openapi/models/ConditionSetRuleCreate.java new file mode 100644 index 0000000..8367d33 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ConditionSetRuleCreate.java @@ -0,0 +1,112 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ConditionSetRuleCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ConditionSetRuleCreate { + + /** + * User Set + *

+ * The userset that will be given permission, i.e: all the users matching this rule will be given the specified permission + * (Required) + * + */ + @SerializedName("user_set") + @Expose + public String userSet; + /** + * Permission + *

+ * The permission that will be granted to the userset *on* the resourceset. The permission can be either a resource action id, or `{resource_key}:{action_key}`, i.e: the "permission name". + * (Required) + * + */ + @SerializedName("permission") + @Expose + public String permission; + /** + * Resource Set + *

+ * The resourceset that represents the resources that are granted for access, i.e: all the resources matching this rule can be accessed by the userset to perform the granted *permission* + * (Required) + * + */ + @SerializedName("resource_set") + @Expose + public String resourceSet; + /** + * Is Role + *

+ * if True, will set the condition set rule to the role's autogen user-set. + * + */ + @SerializedName("is_role") + @Expose + public Boolean isRole = false; + /** + * Is Resource + *

+ * if True, will set the condition set rule to the resource's autogen resource-set. + * + */ + @SerializedName("is_resource") + @Expose + public Boolean isResource = false; + + /** + * No args constructor for use in serialization + * + */ + public ConditionSetRuleCreate() { + } + + /** + * + * @param resourceSet + * @param permission + * @param userSet + */ + public ConditionSetRuleCreate(String userSet, String permission, String resourceSet) { + super(); + this.userSet = userSet; + this.permission = permission; + this.resourceSet = resourceSet; + } + + public ConditionSetRuleCreate withUserSet(String userSet) { + this.userSet = userSet; + return this; + } + + public ConditionSetRuleCreate withPermission(String permission) { + this.permission = permission; + return this; + } + + public ConditionSetRuleCreate withResourceSet(String resourceSet) { + this.resourceSet = resourceSet; + return this; + } + + public ConditionSetRuleCreate withIsRole(Boolean isRole) { + this.isRole = isRole; + return this; + } + + public ConditionSetRuleCreate withIsResource(Boolean isResource) { + this.isResource = isResource; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ConditionSetRuleRead.java b/src/main/java/io/permit/sdk/openapi/models/ConditionSetRuleRead.java new file mode 100644 index 0000000..657bd97 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ConditionSetRuleRead.java @@ -0,0 +1,204 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ConditionSetRuleRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ConditionSetRuleRead { + + /** + * Id + *

+ * Unique id of the condition set rule + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * Key + *

+ * A unique id by which Permit will identify this condition set rule. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * User Set + *

+ * the userset that is currently granted permissions, i.e: all the users matching this rule are granted the permission on the resourceset + * (Required) + * + */ + @SerializedName("user_set") + @Expose + public String userSet; + /** + * Permission + *

+ * a permission that is currently granted to the userset *on* the resourceset. + * (Required) + * + */ + @SerializedName("permission") + @Expose + public String permission; + /** + * Resource Set + *

+ * the resourceset that represents the resources that are currently granted for access, i.e: all the resources matching this rule can be accessed by the userset to perform the granted *permission* + * (Required) + * + */ + @SerializedName("resource_set") + @Expose + public String resourceSet; + /** + * Organization Id + *

+ * Unique id of the organization that the condition set rule belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the condition set rule belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the condition set rule belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public String environmentId; + /** + * Created At + *

+ * Date and time when the condition set rule was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the condition set rule was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + + /** + * No args constructor for use in serialization + * + */ + public ConditionSetRuleRead() { + } + + /** + * + * @param organizationId + * @param resourceSet + * @param createdAt + * @param environmentId + * @param permission + * @param id + * @param userSet + * @param projectId + * @param key + * @param updatedAt + */ + public ConditionSetRuleRead(String id, String key, String userSet, String permission, String resourceSet, String organizationId, String projectId, String environmentId, Date createdAt, Date updatedAt) { + super(); + this.id = id; + this.key = key; + this.userSet = userSet; + this.permission = permission; + this.resourceSet = resourceSet; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } + + public ConditionSetRuleRead withId(String id) { + this.id = id; + return this; + } + + public ConditionSetRuleRead withKey(String key) { + this.key = key; + return this; + } + + public ConditionSetRuleRead withUserSet(String userSet) { + this.userSet = userSet; + return this; + } + + public ConditionSetRuleRead withPermission(String permission) { + this.permission = permission; + return this; + } + + public ConditionSetRuleRead withResourceSet(String resourceSet) { + this.resourceSet = resourceSet; + return this; + } + + public ConditionSetRuleRead withOrganizationId(String organizationId) { + this.organizationId = organizationId; + return this; + } + + public ConditionSetRuleRead withProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + public ConditionSetRuleRead withEnvironmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + public ConditionSetRuleRead withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public ConditionSetRuleRead withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ConditionSetRuleRemove.java b/src/main/java/io/permit/sdk/openapi/models/ConditionSetRuleRemove.java new file mode 100644 index 0000000..c37e9f4 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ConditionSetRuleRemove.java @@ -0,0 +1,112 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ConditionSetRuleRemove + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ConditionSetRuleRemove { + + /** + * User Set + *

+ * The userset that will be unassigned these permission, i.e: all the users matching this rule will lose the specified permission + * (Required) + * + */ + @SerializedName("user_set") + @Expose + public String userSet; + /** + * Permission + *

+ * The permission that will be removed from the userset *on* the resourceset. The permission can be either a resource action id, or `{resource_key}:{action_key}`, i.e: the "permission name". + * (Required) + * + */ + @SerializedName("permission") + @Expose + public String permission; + /** + * Resource Set + *

+ * The resourceset that represents the resources that are no longer granted for access, i.e: all the resources matching this rule can no longer be accessed by the userset, and will be revoked the specified *permission* + * (Required) + * + */ + @SerializedName("resource_set") + @Expose + public String resourceSet; + /** + * Is Role + *

+ * if True, will set the condition set rule to the role's autogen user-set. + * + */ + @SerializedName("is_role") + @Expose + public Boolean isRole = false; + /** + * Is Resource + *

+ * if True, will set the condition set rule to the resource's autogen resource-set. + * + */ + @SerializedName("is_resource") + @Expose + public Boolean isResource = false; + + /** + * No args constructor for use in serialization + * + */ + public ConditionSetRuleRemove() { + } + + /** + * + * @param resourceSet + * @param permission + * @param userSet + */ + public ConditionSetRuleRemove(String userSet, String permission, String resourceSet) { + super(); + this.userSet = userSet; + this.permission = permission; + this.resourceSet = resourceSet; + } + + public ConditionSetRuleRemove withUserSet(String userSet) { + this.userSet = userSet; + return this; + } + + public ConditionSetRuleRemove withPermission(String permission) { + this.permission = permission; + return this; + } + + public ConditionSetRuleRemove withResourceSet(String resourceSet) { + this.resourceSet = resourceSet; + return this; + } + + public ConditionSetRuleRemove withIsRole(Boolean isRole) { + this.isRole = isRole; + return this; + } + + public ConditionSetRuleRemove withIsResource(Boolean isResource) { + this.isResource = isResource; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ConditionSetType.java b/src/main/java/io/permit/sdk/openapi/models/ConditionSetType.java new file mode 100644 index 0000000..f2f3dbd --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ConditionSetType.java @@ -0,0 +1,54 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.SerializedName; + + +/** + * ConditionSetType + *

+ * the type of the set: UserSet or ResourceSet + * + */ +@Generated("jsonschema2pojo") +public enum ConditionSetType { + + @SerializedName("userset") + USERSET("userset"), + @SerializedName("resourceset") + RESOURCESET("resourceset"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (ConditionSetType c: values()) { + CONSTANTS.put(c.value, c); + } + } + + ConditionSetType(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static ConditionSetType fromValue(String value) { + ConditionSetType constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ConditionSetUpdate.java b/src/main/java/io/permit/sdk/openapi/models/ConditionSetUpdate.java new file mode 100644 index 0000000..812a4c8 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ConditionSetUpdate.java @@ -0,0 +1,62 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ConditionSetUpdate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ConditionSetUpdate { + + /** + * Name + *

+ * A descriptive name for the set, i.e: 'US based employees' or 'Users behind VPN' + * + */ + @SerializedName("name") + @Expose + public java.lang.String name; + /** + * Description + *

+ * an optional longer description of the set + * + */ + @SerializedName("description") + @Expose + public java.lang.String description; + /** + * Conditions + *

+ * a boolean expression that consists of multiple conditions, with and/or logic. + * + */ + @SerializedName("conditions") + @Expose + public HashMap conditions; + + public ConditionSetUpdate withName(java.lang.String name) { + this.name = name; + return this; + } + + public ConditionSetUpdate withDescription(java.lang.String description) { + this.description = description; + return this; + } + + public ConditionSetUpdate withConditions(HashMap conditions) { + this.conditions = conditions; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/EmbeddedLoginRequestOutput.java b/src/main/java/io/permit/sdk/openapi/models/EmbeddedLoginRequestOutput.java new file mode 100644 index 0000000..386467a --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/EmbeddedLoginRequestOutput.java @@ -0,0 +1,106 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * EmbeddedLoginRequestOutput + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class EmbeddedLoginRequestOutput { + + /** + * Error + *

+ * If the login request failed, this field will contain the error message + * + */ + @SerializedName("error") + @Expose + public String error; + /** + * Error Code + *

+ * If the login request failed, this field will contain the error code + * + */ + @SerializedName("error_code") + @Expose + public Integer errorCode; + /** + * Token + *

+ * The auth token that lets your users login into permit elements + * + */ + @SerializedName("token") + @Expose + public String token; + /** + * Extra + *

+ * Extra data that you can pass to the login request + * + */ + @SerializedName("extra") + @Expose + public String extra; + /** + * Redirect Url + *

+ * The full URL to which the user should be redirected in order to complete the login process + * (Required) + * + */ + @SerializedName("redirect_url") + @Expose + public String redirectUrl; + + /** + * No args constructor for use in serialization + * + */ + public EmbeddedLoginRequestOutput() { + } + + /** + * + * @param redirectUrl + */ + public EmbeddedLoginRequestOutput(String redirectUrl) { + super(); + this.redirectUrl = redirectUrl; + } + + public EmbeddedLoginRequestOutput withError(String error) { + this.error = error; + return this; + } + + public EmbeddedLoginRequestOutput withErrorCode(Integer errorCode) { + this.errorCode = errorCode; + return this; + } + + public EmbeddedLoginRequestOutput withToken(String token) { + this.token = token; + return this; + } + + public EmbeddedLoginRequestOutput withExtra(String extra) { + this.extra = extra; + return this; + } + + public EmbeddedLoginRequestOutput withRedirectUrl(String redirectUrl) { + this.redirectUrl = redirectUrl; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/EnvironmentCreate.java b/src/main/java/io/permit/sdk/openapi/models/EnvironmentCreate.java new file mode 100644 index 0000000..e44ad7c --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/EnvironmentCreate.java @@ -0,0 +1,95 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * EnvironmentCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class EnvironmentCreate { + + /** + * Key + *

+ * A URL-friendly name of the environment (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the environment. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Name + *

+ * The name of the environment + * (Required) + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * an optional longer description of the environment + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Custom Branch Name + *

+ * when using gitops feature, an optional branch name for the environment + * + */ + @SerializedName("custom_branch_name") + @Expose + public String customBranchName; + + /** + * No args constructor for use in serialization + * + */ + public EnvironmentCreate() { + } + + /** + * + * @param name + * @param key + */ + public EnvironmentCreate(String key, String name) { + super(); + this.key = key; + this.name = name; + } + + public EnvironmentCreate withKey(String key) { + this.key = key; + return this; + } + + public EnvironmentCreate withName(String name) { + this.name = name; + return this; + } + + public EnvironmentCreate withDescription(String description) { + this.description = description; + return this; + } + + public EnvironmentCreate withCustomBranchName(String customBranchName) { + this.customBranchName = customBranchName; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/EnvironmentRead.java b/src/main/java/io/permit/sdk/openapi/models/EnvironmentRead.java new file mode 100644 index 0000000..7a0342a --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/EnvironmentRead.java @@ -0,0 +1,181 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * EnvironmentRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class EnvironmentRead { + + /** + * Key + *

+ * A URL-friendly name of the environment (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the environment. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Id + *

+ * Unique id of the environment + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * Organization Id + *

+ * Unique id of the organization that the environment belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the environment belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public String projectId; + /** + * Created At + *

+ * Date and time when the environment was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the environment was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + /** + * Name + *

+ * The name of the environment + * (Required) + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * an optional longer description of the environment + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Custom Branch Name + *

+ * when using gitops feature, an optional branch name for the environment + * + */ + @SerializedName("custom_branch_name") + @Expose + public String customBranchName; + + /** + * No args constructor for use in serialization + * + */ + public EnvironmentRead() { + } + + /** + * + * @param organizationId + * @param createdAt + * @param name + * @param id + * @param projectId + * @param key + * @param updatedAt + */ + public EnvironmentRead(String key, String id, String organizationId, String projectId, Date createdAt, Date updatedAt, String name) { + super(); + this.key = key; + this.id = id; + this.organizationId = organizationId; + this.projectId = projectId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.name = name; + } + + public EnvironmentRead withKey(String key) { + this.key = key; + return this; + } + + public EnvironmentRead withId(String id) { + this.id = id; + return this; + } + + public EnvironmentRead withOrganizationId(String organizationId) { + this.organizationId = organizationId; + return this; + } + + public EnvironmentRead withProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + public EnvironmentRead withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public EnvironmentRead withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public EnvironmentRead withName(String name) { + this.name = name; + return this; + } + + public EnvironmentRead withDescription(String description) { + this.description = description; + return this; + } + + public EnvironmentRead withCustomBranchName(String customBranchName) { + this.customBranchName = customBranchName; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/EnvironmentStats.java b/src/main/java/io/permit/sdk/openapi/models/EnvironmentStats.java new file mode 100644 index 0000000..66740a6 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/EnvironmentStats.java @@ -0,0 +1,216 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * EnvironmentStats + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class EnvironmentStats { + + /** + * Key + *

+ * A URL-friendly name of the environment (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the environment. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Id + *

+ * Unique id of the environment + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * Organization Id + *

+ * Unique id of the organization that the environment belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the environment belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public String projectId; + /** + * Created At + *

+ * Date and time when the environment was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the environment was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + /** + * Name + *

+ * The name of the environment + * (Required) + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * an optional longer description of the environment + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Custom Branch Name + *

+ * when using gitops feature, an optional branch name for the environment + * + */ + @SerializedName("custom_branch_name") + @Expose + public String customBranchName; + /** + * Pdp Configs + *

+ * + * (Required) + * + */ + @SerializedName("pdp_configs") + @Expose + public List pdpConfigs; + /** + * Statistics + *

+ * + * (Required) + * + */ + @SerializedName("stats") + @Expose + public Statistics stats; + + /** + * No args constructor for use in serialization + * + */ + public EnvironmentStats() { + } + + /** + * + * @param organizationId + * @param createdAt + * @param stats + * @param name + * @param id + * @param pdpConfigs + * @param projectId + * @param key + * @param updatedAt + */ + public EnvironmentStats(String key, String id, String organizationId, String projectId, Date createdAt, Date updatedAt, String name, List pdpConfigs, Statistics stats) { + super(); + this.key = key; + this.id = id; + this.organizationId = organizationId; + this.projectId = projectId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.name = name; + this.pdpConfigs = pdpConfigs; + this.stats = stats; + } + + public EnvironmentStats withKey(String key) { + this.key = key; + return this; + } + + public EnvironmentStats withId(String id) { + this.id = id; + return this; + } + + public EnvironmentStats withOrganizationId(String organizationId) { + this.organizationId = organizationId; + return this; + } + + public EnvironmentStats withProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + public EnvironmentStats withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public EnvironmentStats withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public EnvironmentStats withName(String name) { + this.name = name; + return this; + } + + public EnvironmentStats withDescription(String description) { + this.description = description; + return this; + } + + public EnvironmentStats withCustomBranchName(String customBranchName) { + this.customBranchName = customBranchName; + return this; + } + + public EnvironmentStats withPdpConfigs(List pdpConfigs) { + this.pdpConfigs = pdpConfigs; + return this; + } + + public EnvironmentStats withStats(Statistics stats) { + this.stats = stats; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/EnvironmentUpdate.java b/src/main/java/io/permit/sdk/openapi/models/EnvironmentUpdate.java new file mode 100644 index 0000000..372940d --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/EnvironmentUpdate.java @@ -0,0 +1,61 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * EnvironmentUpdate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class EnvironmentUpdate { + + /** + * Name + *

+ * The name of the environment + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * an optional longer description of the environment + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Custom Branch Name + *

+ * when using gitops feature, an optional branch name for the environment + * + */ + @SerializedName("custom_branch_name") + @Expose + public String customBranchName; + + public EnvironmentUpdate withName(String name) { + this.name = name; + return this; + } + + public EnvironmentUpdate withDescription(String description) { + this.description = description; + return this; + } + + public EnvironmentUpdate withCustomBranchName(String customBranchName) { + this.customBranchName = customBranchName; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/HTTPValidationError.java b/src/main/java/io/permit/sdk/openapi/models/HTTPValidationError.java new file mode 100644 index 0000000..8c510cd --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/HTTPValidationError.java @@ -0,0 +1,34 @@ + +package io.permit.sdk.openapi.models; + +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * HTTPValidationError + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class HTTPValidationError { + + /** + * Detail + *

+ * + * + */ + @SerializedName("detail") + @Expose + public List detail; + + public HTTPValidationError withDetail(List detail) { + this.detail = detail; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/OrganizationCreate.java b/src/main/java/io/permit/sdk/openapi/models/OrganizationCreate.java new file mode 100644 index 0000000..fe95e49 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/OrganizationCreate.java @@ -0,0 +1,81 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * OrganizationCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class OrganizationCreate { + + /** + * Key + *

+ * A URL-friendly name of the organization (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the organization. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Name + *

+ * The name of the organization, usually it's your company's name. + * (Required) + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Settings + *

+ * the settings for this project + * + */ + @SerializedName("settings") + @Expose + public Settings settings; + + /** + * No args constructor for use in serialization + * + */ + public OrganizationCreate() { + } + + /** + * + * @param name + * @param key + */ + public OrganizationCreate(String key, String name) { + super(); + this.key = key; + this.name = name; + } + + public OrganizationCreate withKey(String key) { + this.key = key; + return this; + } + + public OrganizationCreate withName(String name) { + this.name = name; + return this; + } + + public OrganizationCreate withSettings(Settings settings) { + this.settings = settings; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/OrganizationRead.java b/src/main/java/io/permit/sdk/openapi/models/OrganizationRead.java new file mode 100644 index 0000000..62b532e --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/OrganizationRead.java @@ -0,0 +1,133 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * OrganizationRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class OrganizationRead { + + /** + * Key + *

+ * A URL-friendly name of the organization (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the organization. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Id + *

+ * Unique id of the organization + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * Created At + *

+ * Date and time when the organization was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the organization was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + /** + * Name + *

+ * The name of the organization, usually it's your company's name. + * (Required) + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Settings + *

+ * the settings for this project + * + */ + @SerializedName("settings") + @Expose + public Settings__1 settings; + + /** + * No args constructor for use in serialization + * + */ + public OrganizationRead() { + } + + /** + * + * @param createdAt + * @param name + * @param id + * @param key + * @param updatedAt + */ + public OrganizationRead(String key, String id, Date createdAt, Date updatedAt, String name) { + super(); + this.key = key; + this.id = id; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.name = name; + } + + public OrganizationRead withKey(String key) { + this.key = key; + return this; + } + + public OrganizationRead withId(String id) { + this.id = id; + return this; + } + + public OrganizationRead withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public OrganizationRead withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public OrganizationRead withName(String name) { + this.name = name; + return this; + } + + public OrganizationRead withSettings(Settings__1 settings) { + this.settings = settings; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/OrganizationReadWithAPIKey.java b/src/main/java/io/permit/sdk/openapi/models/OrganizationReadWithAPIKey.java new file mode 100644 index 0000000..095cf8b --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/OrganizationReadWithAPIKey.java @@ -0,0 +1,161 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * OrganizationReadWithAPIKey + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class OrganizationReadWithAPIKey { + + /** + * Key + *

+ * A URL-friendly name of the organization (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the organization. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Id + *

+ * Unique id of the organization + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * Created At + *

+ * Date and time when the organization was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the organization was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + /** + * Name + *

+ * The name of the organization, usually it's your company's name. + * (Required) + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Settings + *

+ * the settings for this project + * + */ + @SerializedName("settings") + @Expose + public Settings__2 settings; + /** + * Api Key Id + *

+ * + * + */ + @SerializedName("api_key_id") + @Expose + public String apiKeyId; + /** + * Api Key Secret + *

+ * + * + */ + @SerializedName("api_key_secret") + @Expose + public String apiKeySecret; + + /** + * No args constructor for use in serialization + * + */ + public OrganizationReadWithAPIKey() { + } + + /** + * + * @param createdAt + * @param name + * @param id + * @param key + * @param updatedAt + */ + public OrganizationReadWithAPIKey(String key, String id, Date createdAt, Date updatedAt, String name) { + super(); + this.key = key; + this.id = id; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.name = name; + } + + public OrganizationReadWithAPIKey withKey(String key) { + this.key = key; + return this; + } + + public OrganizationReadWithAPIKey withId(String id) { + this.id = id; + return this; + } + + public OrganizationReadWithAPIKey withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public OrganizationReadWithAPIKey withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public OrganizationReadWithAPIKey withName(String name) { + this.name = name; + return this; + } + + public OrganizationReadWithAPIKey withSettings(Settings__2 settings) { + this.settings = settings; + return this; + } + + public OrganizationReadWithAPIKey withApiKeyId(String apiKeyId) { + this.apiKeyId = apiKeyId; + return this; + } + + public OrganizationReadWithAPIKey withApiKeySecret(String apiKeySecret) { + this.apiKeySecret = apiKeySecret; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/OrganizationUpdate.java b/src/main/java/io/permit/sdk/openapi/models/OrganizationUpdate.java new file mode 100644 index 0000000..082c4b0 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/OrganizationUpdate.java @@ -0,0 +1,47 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * OrganizationUpdate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class OrganizationUpdate { + + /** + * Name + *

+ * The name of the organization, usually it's your company's name. + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Settings + *

+ * the settings for this project + * + */ + @SerializedName("settings") + @Expose + public Settings__3 settings; + + public OrganizationUpdate withName(String name) { + this.name = name; + return this; + } + + public OrganizationUpdate withSettings(Settings__3 settings) { + this.settings = settings; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/PDPConfigRead.java b/src/main/java/io/permit/sdk/openapi/models/PDPConfigRead.java new file mode 100644 index 0000000..9442c10 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/PDPConfigRead.java @@ -0,0 +1,132 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * PDPConfigRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class PDPConfigRead { + + /** + * Id + *

+ * + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * Name + *

+ * + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Organization Id + *

+ * Unique id of the organization that the pdp_config belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the pdp_config belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the pdp_config belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public String environmentId; + /** + * Client Secret + *

+ * + * (Required) + * + */ + @SerializedName("client_secret") + @Expose + public String clientSecret; + + /** + * No args constructor for use in serialization + * + */ + public PDPConfigRead() { + } + + /** + * + * @param organizationId + * @param environmentId + * @param clientSecret + * @param id + * @param projectId + */ + public PDPConfigRead(String id, String organizationId, String projectId, String environmentId, String clientSecret) { + super(); + this.id = id; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + this.clientSecret = clientSecret; + } + + public PDPConfigRead withId(String id) { + this.id = id; + return this; + } + + public PDPConfigRead withName(String name) { + this.name = name; + return this; + } + + public PDPConfigRead withOrganizationId(String organizationId) { + this.organizationId = organizationId; + return this; + } + + public PDPConfigRead withProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + public PDPConfigRead withEnvironmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + public PDPConfigRead withClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/PDPConfigRead__1.java b/src/main/java/io/permit/sdk/openapi/models/PDPConfigRead__1.java new file mode 100644 index 0000000..8f99e80 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/PDPConfigRead__1.java @@ -0,0 +1,132 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * PDPConfigRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class PDPConfigRead__1 { + + /** + * Id + *

+ * + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * Name + *

+ * + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Organization Id + *

+ * Unique id of the organization that the pdp_config belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the pdp_config belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the pdp_config belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public String environmentId; + /** + * Client Secret + *

+ * + * (Required) + * + */ + @SerializedName("client_secret") + @Expose + public String clientSecret; + + /** + * No args constructor for use in serialization + * + */ + public PDPConfigRead__1() { + } + + /** + * + * @param organizationId + * @param environmentId + * @param clientSecret + * @param id + * @param projectId + */ + public PDPConfigRead__1(String id, String organizationId, String projectId, String environmentId, String clientSecret) { + super(); + this.id = id; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + this.clientSecret = clientSecret; + } + + public PDPConfigRead__1 withId(String id) { + this.id = id; + return this; + } + + public PDPConfigRead__1 withName(String name) { + this.name = name; + return this; + } + + public PDPConfigRead__1 withOrganizationId(String organizationId) { + this.organizationId = organizationId; + return this; + } + + public PDPConfigRead__1 withProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + public PDPConfigRead__1 withEnvironmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + public PDPConfigRead__1 withClientSecret(String clientSecret) { + this.clientSecret = clientSecret; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/PaginatedResultUserRead.java b/src/main/java/io/permit/sdk/openapi/models/PaginatedResultUserRead.java new file mode 100644 index 0000000..6d33fe9 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/PaginatedResultUserRead.java @@ -0,0 +1,82 @@ + +package io.permit.sdk.openapi.models; + +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * PaginatedResult[UserRead] + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class PaginatedResultUserRead { + + /** + * Data + *

+ * + * (Required) + * + */ + @SerializedName("data") + @Expose + public List data; + /** + * Total Count + *

+ * + * (Required) + * + */ + @SerializedName("total_count") + @Expose + public Integer totalCount; + /** + * Page Count + *

+ * + * + */ + @SerializedName("page_count") + @Expose + public Integer pageCount = 0; + + /** + * No args constructor for use in serialization + * + */ + public PaginatedResultUserRead() { + } + + /** + * + * @param data + * @param totalCount + */ + public PaginatedResultUserRead(List data, Integer totalCount) { + super(); + this.data = data; + this.totalCount = totalCount; + } + + public PaginatedResultUserRead withData(List data) { + this.data = data; + return this; + } + + public PaginatedResultUserRead withTotalCount(Integer totalCount) { + this.totalCount = totalCount; + return this; + } + + public PaginatedResultUserRead withPageCount(Integer pageCount) { + this.pageCount = pageCount; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ProjectCreate.java b/src/main/java/io/permit/sdk/openapi/models/ProjectCreate.java new file mode 100644 index 0000000..07619cc --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ProjectCreate.java @@ -0,0 +1,123 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ProjectCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ProjectCreate { + + /** + * Key + *

+ * A URL-friendly name of the project (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the project. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Urn Namespace + *

+ * Optional namespace for URNs. If empty, URNs will be generated from project key. + * + */ + @SerializedName("urn_namespace") + @Expose + public String urnNamespace; + /** + * Name + *

+ * The name of the project + * (Required) + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * a longer description outlining the project objectives + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Settings + *

+ * the settings for this project + * + */ + @SerializedName("settings") + @Expose + public Settings__4 settings; + /** + * Active Policy Repo Id + *

+ * the id of the policy repo to use for this project + * + */ + @SerializedName("active_policy_repo_id") + @Expose + public String activePolicyRepoId; + + /** + * No args constructor for use in serialization + * + */ + public ProjectCreate() { + } + + /** + * + * @param name + * @param key + */ + public ProjectCreate(String key, String name) { + super(); + this.key = key; + this.name = name; + } + + public ProjectCreate withKey(String key) { + this.key = key; + return this; + } + + public ProjectCreate withUrnNamespace(String urnNamespace) { + this.urnNamespace = urnNamespace; + return this; + } + + public ProjectCreate withName(String name) { + this.name = name; + return this; + } + + public ProjectCreate withDescription(String description) { + this.description = description; + return this; + } + + public ProjectCreate withSettings(Settings__4 settings) { + this.settings = settings; + return this; + } + + public ProjectCreate withActivePolicyRepoId(String activePolicyRepoId) { + this.activePolicyRepoId = activePolicyRepoId; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ProjectRead.java b/src/main/java/io/permit/sdk/openapi/models/ProjectRead.java new file mode 100644 index 0000000..06865cf --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ProjectRead.java @@ -0,0 +1,192 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ProjectRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ProjectRead { + + /** + * Key + *

+ * A URL-friendly name of the project (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the project. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Urn Namespace + *

+ * Optional namespace for URNs. If empty, URNs will be generated from project key. + * + */ + @SerializedName("urn_namespace") + @Expose + public String urnNamespace; + /** + * Id + *

+ * Unique id of the project + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * Organization Id + *

+ * Unique id of the organization that the project belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public String organizationId; + /** + * Created At + *

+ * Date and time when the project was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the project was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + /** + * Name + *

+ * The name of the project + * (Required) + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * a longer description outlining the project objectives + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Settings + *

+ * the settings for this project + * + */ + @SerializedName("settings") + @Expose + public Settings__5 settings; + /** + * Active Policy Repo Id + *

+ * the id of the policy repo to use for this project + * + */ + @SerializedName("active_policy_repo_id") + @Expose + public String activePolicyRepoId; + + /** + * No args constructor for use in serialization + * + */ + public ProjectRead() { + } + + /** + * + * @param organizationId + * @param createdAt + * @param name + * @param id + * @param key + * @param updatedAt + */ + public ProjectRead(String key, String id, String organizationId, Date createdAt, Date updatedAt, String name) { + super(); + this.key = key; + this.id = id; + this.organizationId = organizationId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.name = name; + } + + public ProjectRead withKey(String key) { + this.key = key; + return this; + } + + public ProjectRead withUrnNamespace(String urnNamespace) { + this.urnNamespace = urnNamespace; + return this; + } + + public ProjectRead withId(String id) { + this.id = id; + return this; + } + + public ProjectRead withOrganizationId(String organizationId) { + this.organizationId = organizationId; + return this; + } + + public ProjectRead withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public ProjectRead withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public ProjectRead withName(String name) { + this.name = name; + return this; + } + + public ProjectRead withDescription(String description) { + this.description = description; + return this; + } + + public ProjectRead withSettings(Settings__5 settings) { + this.settings = settings; + return this; + } + + public ProjectRead withActivePolicyRepoId(String activePolicyRepoId) { + this.activePolicyRepoId = activePolicyRepoId; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ProjectUpdate.java b/src/main/java/io/permit/sdk/openapi/models/ProjectUpdate.java new file mode 100644 index 0000000..4c8c1aa --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ProjectUpdate.java @@ -0,0 +1,75 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ProjectUpdate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ProjectUpdate { + + /** + * Name + *

+ * The name of the project + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * a longer description outlining the project objectives + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Settings + *

+ * the settings for this project + * + */ + @SerializedName("settings") + @Expose + public Settings__6 settings; + /** + * Active Policy Repo Id + *

+ * the id of the policy repo to use for this project + * + */ + @SerializedName("active_policy_repo_id") + @Expose + public String activePolicyRepoId; + + public ProjectUpdate withName(String name) { + this.name = name; + return this; + } + + public ProjectUpdate withDescription(String description) { + this.description = description; + return this; + } + + public ProjectUpdate withSettings(Settings__6 settings) { + this.settings = settings; + return this; + } + + public ProjectUpdate withActivePolicyRepoId(String activePolicyRepoId) { + this.activePolicyRepoId = activePolicyRepoId; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/RelationsBlock.java b/src/main/java/io/permit/sdk/openapi/models/RelationsBlock.java new file mode 100644 index 0000000..f1ab7ad --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/RelationsBlock.java @@ -0,0 +1,18 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; + + +/** + * RelationsBlock + *

+ * A actions definition block, typically contained within a resource type definition block. + * The actions represents the ways you can interact with a protected resource. + * + */ +@Generated("jsonschema2pojo") +public class RelationsBlock { + + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/RemoveRolePermissions.java b/src/main/java/io/permit/sdk/openapi/models/RemoveRolePermissions.java new file mode 100644 index 0000000..f9d6f53 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/RemoveRolePermissions.java @@ -0,0 +1,51 @@ + +package io.permit.sdk.openapi.models; + +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * RemoveRolePermissions + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class RemoveRolePermissions { + + /** + * Permissions + *

+ * List of permissions to remove from the role. If a permission is not found it is skipped. Each permission can be either a resource action id, or `{resource_key}:{action_key}`,i.e: the "permission name". + * (Required) + * + */ + @SerializedName("permissions") + @Expose + public List permissions; + + /** + * No args constructor for use in serialization + * + */ + public RemoveRolePermissions() { + } + + /** + * + * @param permissions + */ + public RemoveRolePermissions(List permissions) { + super(); + this.permissions = permissions; + } + + public RemoveRolePermissions withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceActionCreate.java b/src/main/java/io/permit/sdk/openapi/models/ResourceActionCreate.java new file mode 100644 index 0000000..238849e --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceActionCreate.java @@ -0,0 +1,81 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceActionCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceActionCreate { + + /** + * Key + *

+ * A URL-friendly name of the action (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the action. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Name + *

+ * The name of the action + * (Required) + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * An optional longer description of what this action respresents in your system + * + */ + @SerializedName("description") + @Expose + public String description; + + /** + * No args constructor for use in serialization + * + */ + public ResourceActionCreate() { + } + + /** + * + * @param name + * @param key + */ + public ResourceActionCreate(String key, String name) { + super(); + this.key = key; + this.name = name; + } + + public ResourceActionCreate withKey(String key) { + this.key = key; + return this; + } + + public ResourceActionCreate withName(String name) { + this.name = name; + return this; + } + + public ResourceActionCreate withDescription(String description) { + this.description = description; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceActionRead.java b/src/main/java/io/permit/sdk/openapi/models/ResourceActionRead.java new file mode 100644 index 0000000..edaf686 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceActionRead.java @@ -0,0 +1,218 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceActionRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceActionRead { + + /** + * Name + *

+ * The name of the action + * (Required) + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * An optional longer description of what this action respresents in your system + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Key + *

+ * A URL-friendly name of the action (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the action. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Id + *

+ * Unique id of the action + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * Permission Name + *

+ * The name of the action, prefixed by the resource the action is acting upon. + * (Required) + * + */ + @SerializedName("permission_name") + @Expose + public String permissionName; + /** + * Organization Id + *

+ * Unique id of the organization that the action belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the action belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the action belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public String environmentId; + /** + * Resource Id + *

+ * Unique id of the resource that the action belongs to. + * (Required) + * + */ + @SerializedName("resource_id") + @Expose + public String resourceId; + /** + * Created At + *

+ * Date and time when the action was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the action was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + + /** + * No args constructor for use in serialization + * + */ + public ResourceActionRead() { + } + + /** + * + * @param organizationId + * @param createdAt + * @param resourceId + * @param environmentId + * @param name + * @param id + * @param projectId + * @param key + * @param permissionName + * @param updatedAt + */ + public ResourceActionRead(String name, String key, String id, String permissionName, String organizationId, String projectId, String environmentId, String resourceId, Date createdAt, Date updatedAt) { + super(); + this.name = name; + this.key = key; + this.id = id; + this.permissionName = permissionName; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + this.resourceId = resourceId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } + + public ResourceActionRead withName(String name) { + this.name = name; + return this; + } + + public ResourceActionRead withDescription(String description) { + this.description = description; + return this; + } + + public ResourceActionRead withKey(String key) { + this.key = key; + return this; + } + + public ResourceActionRead withId(String id) { + this.id = id; + return this; + } + + public ResourceActionRead withPermissionName(String permissionName) { + this.permissionName = permissionName; + return this; + } + + public ResourceActionRead withOrganizationId(String organizationId) { + this.organizationId = organizationId; + return this; + } + + public ResourceActionRead withProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + public ResourceActionRead withEnvironmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + public ResourceActionRead withResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + public ResourceActionRead withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public ResourceActionRead withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceActionUpdate.java b/src/main/java/io/permit/sdk/openapi/models/ResourceActionUpdate.java new file mode 100644 index 0000000..0e32342 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceActionUpdate.java @@ -0,0 +1,47 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceActionUpdate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceActionUpdate { + + /** + * Name + *

+ * The name of the action + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * An optional longer description of what this action respresents in your system + * + */ + @SerializedName("description") + @Expose + public String description; + + public ResourceActionUpdate withName(String name) { + this.name = name; + return this; + } + + public ResourceActionUpdate withDescription(String description) { + this.description = description; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceAttributeCreate.java b/src/main/java/io/permit/sdk/openapi/models/ResourceAttributeCreate.java new file mode 100644 index 0000000..17c5a8d --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceAttributeCreate.java @@ -0,0 +1,79 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceAttributeCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceAttributeCreate { + + /** + * Key + *

+ * A URL-friendly name of the attribute (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the attribute. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * + * (Required) + * + */ + @SerializedName("type") + @Expose + public AttributeType type; + /** + * Description + *

+ * An optional longer description of what this attribute respresents in your system + * + */ + @SerializedName("description") + @Expose + public String description; + + /** + * No args constructor for use in serialization + * + */ + public ResourceAttributeCreate() { + } + + /** + * + * @param type + * @param key + */ + public ResourceAttributeCreate(String key, AttributeType type) { + super(); + this.key = key; + this.type = type; + } + + public ResourceAttributeCreate withKey(String key) { + this.key = key; + return this; + } + + public ResourceAttributeCreate withType(AttributeType type) { + this.type = type; + return this; + } + + public ResourceAttributeCreate withDescription(String description) { + this.description = description; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceAttributeRead.java b/src/main/java/io/permit/sdk/openapi/models/ResourceAttributeRead.java new file mode 100644 index 0000000..285a13d --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceAttributeRead.java @@ -0,0 +1,216 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceAttributeRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceAttributeRead { + + /** + * + * (Required) + * + */ + @SerializedName("type") + @Expose + public AttributeType type; + /** + * Description + *

+ * An optional longer description of what this attribute respresents in your system + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Key + *

+ * A URL-friendly name of the attribute (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the attribute. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Id + *

+ * Unique id of the attribute + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * Resource Id + *

+ * Unique id of the resource that the attribute belongs to. + * (Required) + * + */ + @SerializedName("resource_id") + @Expose + public String resourceId; + /** + * Resource 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. + * (Required) + * + */ + @SerializedName("resource_key") + @Expose + public String resourceKey; + /** + * Organization Id + *

+ * Unique id of the organization that the attribute belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the attribute belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the attribute belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public String environmentId; + /** + * Created At + *

+ * Date and time when the attribute was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the attribute was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + + /** + * No args constructor for use in serialization + * + */ + public ResourceAttributeRead() { + } + + /** + * + * @param organizationId + * @param createdAt + * @param resourceId + * @param environmentId + * @param resourceKey + * @param id + * @param type + * @param projectId + * @param key + * @param updatedAt + */ + public ResourceAttributeRead(AttributeType type, String key, String id, String resourceId, String resourceKey, String organizationId, String projectId, String environmentId, Date createdAt, Date updatedAt) { + super(); + this.type = type; + this.key = key; + this.id = id; + this.resourceId = resourceId; + this.resourceKey = resourceKey; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } + + public ResourceAttributeRead withType(AttributeType type) { + this.type = type; + return this; + } + + public ResourceAttributeRead withDescription(String description) { + this.description = description; + return this; + } + + public ResourceAttributeRead withKey(String key) { + this.key = key; + return this; + } + + public ResourceAttributeRead withId(String id) { + this.id = id; + return this; + } + + public ResourceAttributeRead withResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + public ResourceAttributeRead withResourceKey(String resourceKey) { + this.resourceKey = resourceKey; + return this; + } + + public ResourceAttributeRead withOrganizationId(String organizationId) { + this.organizationId = organizationId; + return this; + } + + public ResourceAttributeRead withProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + public ResourceAttributeRead withEnvironmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + public ResourceAttributeRead withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public ResourceAttributeRead withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceAttributeUpdate.java b/src/main/java/io/permit/sdk/openapi/models/ResourceAttributeUpdate.java new file mode 100644 index 0000000..748cf9c --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceAttributeUpdate.java @@ -0,0 +1,41 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceAttributeUpdate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceAttributeUpdate { + + @SerializedName("type") + @Expose + public AttributeType type; + /** + * Description + *

+ * An optional longer description of what this attribute respresents in your system + * + */ + @SerializedName("description") + @Expose + public String description; + + public ResourceAttributeUpdate withType(AttributeType type) { + this.type = type; + return this; + } + + public ResourceAttributeUpdate withDescription(String description) { + this.description = description; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceCreate.java b/src/main/java/io/permit/sdk/openapi/models/ResourceCreate.java new file mode 100644 index 0000000..0183fe6 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceCreate.java @@ -0,0 +1,130 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceCreate { + + /** + * 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. + * (Required) + * + */ + @SerializedName("key") + @Expose + public java.lang.String key; + /** + * Name + *

+ * The name of the resource + * (Required) + * + */ + @SerializedName("name") + @Expose + public java.lang.String name; + /** + * Urn + *

+ * The [URN](https://en.wikipedia.org/wiki/Uniform_Resource_Name) (Uniform Resource Name) of the resource + * + */ + @SerializedName("urn") + @Expose + public java.lang.String urn; + /** + * Description + *

+ * An optional longer description of what this resource respresents in your system + * + */ + @SerializedName("description") + @Expose + public java.lang.String description; + /** + * 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. + * + * (Required) + * + */ + @SerializedName("actions") + @Expose + public HashMap actions; + /** + * Attributes + *

+ * Attributes that each resource of this type defines, and can be used in your ABAC policies. + * + */ + @SerializedName("attributes") + @Expose + public HashMap attributes; + + /** + * No args constructor for use in serialization + * + */ + public ResourceCreate() { + } + + /** + * + * @param name + * @param actions + * @param key + */ + public ResourceCreate(java.lang.String key, java.lang.String name, HashMap actions) { + super(); + this.key = key; + this.name = name; + this.actions = actions; + } + + public ResourceCreate withKey(java.lang.String key) { + this.key = key; + return this; + } + + public ResourceCreate withName(java.lang.String name) { + this.name = name; + return this; + } + + public ResourceCreate withUrn(java.lang.String urn) { + this.urn = urn; + return this; + } + + public ResourceCreate withDescription(java.lang.String description) { + this.description = description; + return this; + } + + public ResourceCreate withActions(HashMap actions) { + this.actions = actions; + return this; + } + + public ResourceCreate withAttributes(HashMap attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceInstanceCreate.java b/src/main/java/io/permit/sdk/openapi/models/ResourceInstanceCreate.java new file mode 100644 index 0000000..39ef12d --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceInstanceCreate.java @@ -0,0 +1,96 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceInstanceCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceInstanceCreate { + + /** + * Key + *

+ * A unique identifier by which Permit will identify the resource instance for permission checks. You will later pass this identifier to the `permit.check()` API. A key can be anything: for example the resource db id, a url slug, a UUID or anything else as long as it's unique on your end. The resource instance key must be url-friendly. + * (Required) + * + */ + @SerializedName("key") + @Expose + public java.lang.String key; + /** + * Tenant + *

+ * the *key* of the tenant that this resource belongs to, used to enforce tenant boundaries in multi-tenant apps. + * + */ + @SerializedName("tenant") + @Expose + public java.lang.String tenant; + /** + * Resource + *

+ * the *key* of the resource (type) of this resource instance. For example: if this resource instance is the annual budget document, the key of the resource might be `document`. + * (Required) + * + */ + @SerializedName("resource") + @Expose + public java.lang.String resource; + /** + * Attributes + *

+ * Arbitraty resource attributes that will be used to enforce attribute-based access control policies. + * + */ + @SerializedName("attributes") + @Expose + public HashMap attributes; + + /** + * No args constructor for use in serialization + * + */ + public ResourceInstanceCreate() { + } + + /** + * + * @param resource + * @param key + */ + public ResourceInstanceCreate(java.lang.String key, java.lang.String resource) { + super(); + this.key = key; + this.resource = resource; + } + + public ResourceInstanceCreate withKey(java.lang.String key) { + this.key = key; + return this; + } + + public ResourceInstanceCreate withTenant(java.lang.String tenant) { + this.tenant = tenant; + return this; + } + + public ResourceInstanceCreate withResource(java.lang.String resource) { + this.resource = resource; + return this; + } + + public ResourceInstanceCreate withAttributes(HashMap attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceInstanceRead.java b/src/main/java/io/permit/sdk/openapi/models/ResourceInstanceRead.java new file mode 100644 index 0000000..f038d9c --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceInstanceRead.java @@ -0,0 +1,230 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceInstanceRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceInstanceRead { + + /** + * Key + *

+ * A unique identifier by which Permit will identify the resource instance for permission checks. You will later pass this identifier to the `permit.check()` API. A key can be anything: for example the resource db id, a url slug, a UUID or anything else as long as it's unique on your end. The resource instance key must be url-friendly. + * (Required) + * + */ + @SerializedName("key") + @Expose + public java.lang.String key; + /** + * Tenant + *

+ * the *key* of the tenant that this resource belongs to, used to enforce tenant boundaries in multi-tenant apps. + * + */ + @SerializedName("tenant") + @Expose + public java.lang.String tenant; + /** + * Resource + *

+ * the *key* of the resource (type) of this resource instance. For example: if this resource instance is the annual budget document, the key of the resource might be `document`. + * (Required) + * + */ + @SerializedName("resource") + @Expose + public java.lang.String resource; + /** + * Id + *

+ * Unique id of the resource instance + * (Required) + * + */ + @SerializedName("id") + @Expose + public java.lang.String id; + /** + * Organization Id + *

+ * Unique id of the organization that the resource instance belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public java.lang.String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the resource instance belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public java.lang.String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the resource instance belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public java.lang.String environmentId; + /** + * Created At + *

+ * Date and time when the resource instance was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the resource instance was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + /** + * Resource Id + *

+ * the id of the resource (type) of this resource instance. + * (Required) + * + */ + @SerializedName("resource_id") + @Expose + public java.lang.String resourceId; + /** + * Tenant Id + *

+ * the id of the tenant of this resource instance. + * + */ + @SerializedName("tenant_id") + @Expose + public java.lang.String tenantId; + /** + * Attributes + *

+ * Arbitraty resource attributes that will be used to enforce attribute-based access control policies. + * + */ + @SerializedName("attributes") + @Expose + public HashMap attributes; + + /** + * No args constructor for use in serialization + * + */ + public ResourceInstanceRead() { + } + + /** + * + * @param organizationId + * @param createdAt + * @param resourceId + * @param environmentId + * @param resource + * @param id + * @param projectId + * @param key + * @param updatedAt + */ + public ResourceInstanceRead(java.lang.String key, java.lang.String resource, java.lang.String id, java.lang.String organizationId, java.lang.String projectId, java.lang.String environmentId, Date createdAt, Date updatedAt, java.lang.String resourceId) { + super(); + this.key = key; + this.resource = resource; + this.id = id; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.resourceId = resourceId; + } + + public ResourceInstanceRead withKey(java.lang.String key) { + this.key = key; + return this; + } + + public ResourceInstanceRead withTenant(java.lang.String tenant) { + this.tenant = tenant; + return this; + } + + public ResourceInstanceRead withResource(java.lang.String resource) { + this.resource = resource; + return this; + } + + public ResourceInstanceRead withId(java.lang.String id) { + this.id = id; + return this; + } + + public ResourceInstanceRead withOrganizationId(java.lang.String organizationId) { + this.organizationId = organizationId; + return this; + } + + public ResourceInstanceRead withProjectId(java.lang.String projectId) { + this.projectId = projectId; + return this; + } + + public ResourceInstanceRead withEnvironmentId(java.lang.String environmentId) { + this.environmentId = environmentId; + return this; + } + + public ResourceInstanceRead withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public ResourceInstanceRead withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public ResourceInstanceRead withResourceId(java.lang.String resourceId) { + this.resourceId = resourceId; + return this; + } + + public ResourceInstanceRead withTenantId(java.lang.String tenantId) { + this.tenantId = tenantId; + return this; + } + + public ResourceInstanceRead withAttributes(HashMap attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceInstanceUpdate.java b/src/main/java/io/permit/sdk/openapi/models/ResourceInstanceUpdate.java new file mode 100644 index 0000000..23e3777 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceInstanceUpdate.java @@ -0,0 +1,33 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceInstanceUpdate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceInstanceUpdate { + + /** + * Attributes + *

+ * Arbitraty resource attributes that will be used to enforce attribute-based access control policies. + * + */ + @SerializedName("attributes") + @Expose + public Attributes attributes; + + public ResourceInstanceUpdate withAttributes(Attributes attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceRead.java b/src/main/java/io/permit/sdk/openapi/models/ResourceRead.java new file mode 100644 index 0000000..896250d --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceRead.java @@ -0,0 +1,230 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceRead { + + /** + * 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. + * (Required) + * + */ + @SerializedName("key") + @Expose + public java.lang.String key; + /** + * Id + *

+ * Unique id of the resource + * (Required) + * + */ + @SerializedName("id") + @Expose + public java.lang.String id; + /** + * Organization Id + *

+ * Unique id of the organization that the resource belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public java.lang.String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the resource belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public java.lang.String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the resource belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public java.lang.String environmentId; + /** + * Created At + *

+ * Date and time when the resource was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the resource was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + /** + * Name + *

+ * The name of the resource + * (Required) + * + */ + @SerializedName("name") + @Expose + public java.lang.String name; + /** + * Urn + *

+ * The [URN](https://en.wikipedia.org/wiki/Uniform_Resource_Name) (Uniform Resource Name) of the resource + * + */ + @SerializedName("urn") + @Expose + public java.lang.String urn; + /** + * Description + *

+ * An optional longer description of what this resource respresents in your system + * + */ + @SerializedName("description") + @Expose + public java.lang.String description; + /** + * 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. + * + * + */ + @SerializedName("actions") + @Expose + public HashMap actions; + /** + * Attributes + *

+ * Attributes that each resource of this type defines, and can be used in your ABAC policies. + * + */ + @SerializedName("attributes") + @Expose + public HashMap attributes; + + /** + * No args constructor for use in serialization + * + */ + public ResourceRead() { + } + + /** + * + * @param organizationId + * @param createdAt + * @param environmentId + * @param name + * @param id + * @param projectId + * @param key + * @param updatedAt + */ + public ResourceRead(java.lang.String key, java.lang.String id, java.lang.String organizationId, java.lang.String projectId, java.lang.String environmentId, Date createdAt, Date updatedAt, java.lang.String name) { + super(); + this.key = key; + this.id = id; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.name = name; + } + + public ResourceRead withKey(java.lang.String key) { + this.key = key; + return this; + } + + public ResourceRead withId(java.lang.String id) { + this.id = id; + return this; + } + + public ResourceRead withOrganizationId(java.lang.String organizationId) { + this.organizationId = organizationId; + return this; + } + + public ResourceRead withProjectId(java.lang.String projectId) { + this.projectId = projectId; + return this; + } + + public ResourceRead withEnvironmentId(java.lang.String environmentId) { + this.environmentId = environmentId; + return this; + } + + public ResourceRead withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public ResourceRead withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public ResourceRead withName(java.lang.String name) { + this.name = name; + return this; + } + + public ResourceRead withUrn(java.lang.String urn) { + this.urn = urn; + return this; + } + + public ResourceRead withDescription(java.lang.String description) { + this.description = description; + return this; + } + + public ResourceRead withActions(HashMap actions) { + this.actions = actions; + return this; + } + + public ResourceRead withAttributes(HashMap attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceRead__1.java b/src/main/java/io/permit/sdk/openapi/models/ResourceRead__1.java new file mode 100644 index 0000000..ee1581c --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceRead__1.java @@ -0,0 +1,230 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceRead__1 { + + /** + * 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. + * (Required) + * + */ + @SerializedName("key") + @Expose + public java.lang.String key; + /** + * Id + *

+ * Unique id of the resource + * (Required) + * + */ + @SerializedName("id") + @Expose + public java.lang.String id; + /** + * Organization Id + *

+ * Unique id of the organization that the resource belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public java.lang.String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the resource belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public java.lang.String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the resource belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public java.lang.String environmentId; + /** + * Created At + *

+ * Date and time when the resource was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the resource was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + /** + * Name + *

+ * The name of the resource + * (Required) + * + */ + @SerializedName("name") + @Expose + public java.lang.String name; + /** + * Urn + *

+ * The [URN](https://en.wikipedia.org/wiki/Uniform_Resource_Name) (Uniform Resource Name) of the resource + * + */ + @SerializedName("urn") + @Expose + public java.lang.String urn; + /** + * Description + *

+ * An optional longer description of what this resource respresents in your system + * + */ + @SerializedName("description") + @Expose + public java.lang.String description; + /** + * 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. + * + * + */ + @SerializedName("actions") + @Expose + public HashMap actions; + /** + * Attributes + *

+ * Attributes that each resource of this type defines, and can be used in your ABAC policies. + * + */ + @SerializedName("attributes") + @Expose + public HashMap attributes; + + /** + * No args constructor for use in serialization + * + */ + public ResourceRead__1() { + } + + /** + * + * @param organizationId + * @param createdAt + * @param environmentId + * @param name + * @param id + * @param projectId + * @param key + * @param updatedAt + */ + public ResourceRead__1(java.lang.String key, java.lang.String id, java.lang.String organizationId, java.lang.String projectId, java.lang.String environmentId, Date createdAt, Date updatedAt, java.lang.String name) { + super(); + this.key = key; + this.id = id; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.name = name; + } + + public ResourceRead__1 withKey(java.lang.String key) { + this.key = key; + return this; + } + + public ResourceRead__1 withId(java.lang.String id) { + this.id = id; + return this; + } + + public ResourceRead__1 withOrganizationId(java.lang.String organizationId) { + this.organizationId = organizationId; + return this; + } + + public ResourceRead__1 withProjectId(java.lang.String projectId) { + this.projectId = projectId; + return this; + } + + public ResourceRead__1 withEnvironmentId(java.lang.String environmentId) { + this.environmentId = environmentId; + return this; + } + + public ResourceRead__1 withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public ResourceRead__1 withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public ResourceRead__1 withName(java.lang.String name) { + this.name = name; + return this; + } + + public ResourceRead__1 withUrn(java.lang.String urn) { + this.urn = urn; + return this; + } + + public ResourceRead__1 withDescription(java.lang.String description) { + this.description = description; + return this; + } + + public ResourceRead__1 withActions(HashMap actions) { + this.actions = actions; + return this; + } + + public ResourceRead__1 withAttributes(HashMap attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceReplace.java b/src/main/java/io/permit/sdk/openapi/models/ResourceReplace.java new file mode 100644 index 0000000..6111582 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceReplace.java @@ -0,0 +1,113 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceReplace + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceReplace { + + /** + * Name + *

+ * The name of the resource + * (Required) + * + */ + @SerializedName("name") + @Expose + public java.lang.String name; + /** + * Urn + *

+ * The [URN](https://en.wikipedia.org/wiki/Uniform_Resource_Name) (Uniform Resource Name) of the resource + * + */ + @SerializedName("urn") + @Expose + public java.lang.String urn; + /** + * Description + *

+ * An optional longer description of what this resource respresents in your system + * + */ + @SerializedName("description") + @Expose + public java.lang.String description; + /** + * 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. + * + * (Required) + * + */ + @SerializedName("actions") + @Expose + public HashMap actions; + /** + * Attributes + *

+ * Attributes that each resource of this type defines, and can be used in your ABAC policies. + * + */ + @SerializedName("attributes") + @Expose + public HashMap attributes; + + /** + * No args constructor for use in serialization + * + */ + public ResourceReplace() { + } + + /** + * + * @param name + * @param actions + */ + public ResourceReplace(java.lang.String name, HashMap actions) { + super(); + this.name = name; + this.actions = actions; + } + + public ResourceReplace withName(java.lang.String name) { + this.name = name; + return this; + } + + public ResourceReplace withUrn(java.lang.String urn) { + this.urn = urn; + return this; + } + + public ResourceReplace withDescription(java.lang.String description) { + this.description = description; + return this; + } + + public ResourceReplace withActions(HashMap actions) { + this.actions = actions; + return this; + } + + public ResourceReplace withAttributes(HashMap attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceRoleCreate.java b/src/main/java/io/permit/sdk/openapi/models/ResourceRoleCreate.java new file mode 100644 index 0000000..70ace75 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceRoleCreate.java @@ -0,0 +1,110 @@ + +package io.permit.sdk.openapi.models; + +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceRoleCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceRoleCreate { + + /** + * Key + *

+ * A URL-friendly name of the role (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the role. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Name + *

+ * The name of the role + * (Required) + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * optional description string explaining what this role represents, or what permissions are granted to it. + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Permissions + *

+ * list of action keys that define what actions this resource role is permitted to do + * + */ + @SerializedName("permissions") + @Expose + public List permissions; + /** + * Extends + *

+ * list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list. + * + */ + @SerializedName("extends") + @Expose + public List _extends; + + /** + * No args constructor for use in serialization + * + */ + public ResourceRoleCreate() { + } + + /** + * + * @param name + * @param key + */ + public ResourceRoleCreate(String key, String name) { + super(); + this.key = key; + this.name = name; + } + + public ResourceRoleCreate withKey(String key) { + this.key = key; + return this; + } + + public ResourceRoleCreate withName(String name) { + this.name = name; + return this; + } + + public ResourceRoleCreate withDescription(String description) { + this.description = description; + return this; + } + + public ResourceRoleCreate withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + + public ResourceRoleCreate withExtends(List _extends) { + this._extends = _extends; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceRoleRead.java b/src/main/java/io/permit/sdk/openapi/models/ResourceRoleRead.java new file mode 100644 index 0000000..f42b8e2 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceRoleRead.java @@ -0,0 +1,230 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceRoleRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceRoleRead { + + /** + * Name + *

+ * The name of the role + * (Required) + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * optional description string explaining what this role represents, or what permissions are granted to it. + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Permissions + *

+ * list of action keys that define what actions this resource role is permitted to do + * + */ + @SerializedName("permissions") + @Expose + public List permissions; + /** + * Extends + *

+ * list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list. + * + */ + @SerializedName("extends") + @Expose + public List _extends; + /** + * Key + *

+ * A URL-friendly name of the role (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the role. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Id + *

+ * Unique id of the role + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * Organization Id + *

+ * Unique id of the organization that the role belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the role belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the role belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public String environmentId; + /** + * Resource Id + *

+ * Unique id of the resource that the role belongs to. + * (Required) + * + */ + @SerializedName("resource_id") + @Expose + public String resourceId; + /** + * Created At + *

+ * Date and time when the role was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the role was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + + /** + * No args constructor for use in serialization + * + */ + public ResourceRoleRead() { + } + + /** + * + * @param organizationId + * @param createdAt + * @param resourceId + * @param environmentId + * @param name + * @param id + * @param projectId + * @param key + * @param updatedAt + */ + public ResourceRoleRead(String name, String key, String id, String organizationId, String projectId, String environmentId, String resourceId, Date createdAt, Date updatedAt) { + super(); + this.name = name; + this.key = key; + this.id = id; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + this.resourceId = resourceId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } + + public ResourceRoleRead withName(String name) { + this.name = name; + return this; + } + + public ResourceRoleRead withDescription(String description) { + this.description = description; + return this; + } + + public ResourceRoleRead withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + + public ResourceRoleRead withExtends(List _extends) { + this._extends = _extends; + return this; + } + + public ResourceRoleRead withKey(String key) { + this.key = key; + return this; + } + + public ResourceRoleRead withId(String id) { + this.id = id; + return this; + } + + public ResourceRoleRead withOrganizationId(String organizationId) { + this.organizationId = organizationId; + return this; + } + + public ResourceRoleRead withProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + public ResourceRoleRead withEnvironmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + public ResourceRoleRead withResourceId(String resourceId) { + this.resourceId = resourceId; + return this; + } + + public ResourceRoleRead withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public ResourceRoleRead withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceRoleUpdate.java b/src/main/java/io/permit/sdk/openapi/models/ResourceRoleUpdate.java new file mode 100644 index 0000000..68685eb --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceRoleUpdate.java @@ -0,0 +1,76 @@ + +package io.permit.sdk.openapi.models; + +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceRoleUpdate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceRoleUpdate { + + /** + * Name + *

+ * The name of the role + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * optional description string explaining what this role represents, or what permissions are granted to it. + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Permissions + *

+ * list of action keys that define what actions this resource role is permitted to do + * + */ + @SerializedName("permissions") + @Expose + public List permissions; + /** + * Extends + *

+ * list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list. + * + */ + @SerializedName("extends") + @Expose + public List _extends; + + public ResourceRoleUpdate withName(String name) { + this.name = name; + return this; + } + + public ResourceRoleUpdate withDescription(String description) { + this.description = description; + return this; + } + + public ResourceRoleUpdate withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + + public ResourceRoleUpdate withExtends(List _extends) { + this._extends = _extends; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ResourceUpdate.java b/src/main/java/io/permit/sdk/openapi/models/ResourceUpdate.java new file mode 100644 index 0000000..76ac6c6 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ResourceUpdate.java @@ -0,0 +1,93 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ResourceUpdate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ResourceUpdate { + + /** + * Name + *

+ * The name of the resource + * + */ + @SerializedName("name") + @Expose + public java.lang.String name; + /** + * Urn + *

+ * The [URN](https://en.wikipedia.org/wiki/Uniform_Resource_Name) (Uniform Resource Name) of the resource + * + */ + @SerializedName("urn") + @Expose + public java.lang.String urn; + /** + * Description + *

+ * An optional longer description of what this resource respresents in your system + * + */ + @SerializedName("description") + @Expose + public java.lang.String description; + /** + * 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. + * + * + */ + @SerializedName("actions") + @Expose + public HashMap actions; + /** + * Attributes + *

+ * Attributes that each resource of this type defines, and can be used in your ABAC policies. + * + */ + @SerializedName("attributes") + @Expose + public HashMap attributes; + + public ResourceUpdate withName(java.lang.String name) { + this.name = name; + return this; + } + + public ResourceUpdate withUrn(java.lang.String urn) { + this.urn = urn; + return this; + } + + public ResourceUpdate withDescription(java.lang.String description) { + this.description = description; + return this; + } + + public ResourceUpdate withActions(HashMap actions) { + this.actions = actions; + return this; + } + + public ResourceUpdate withAttributes(HashMap attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/RoleAssignmentCreate.java b/src/main/java/io/permit/sdk/openapi/models/RoleAssignmentCreate.java new file mode 100644 index 0000000..6f4ea88 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/RoleAssignmentCreate.java @@ -0,0 +1,84 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * RoleAssignmentCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class RoleAssignmentCreate { + + /** + * Role + *

+ * the role that will be assigned (accepts either the role id or the role key) + * (Required) + * + */ + @SerializedName("role") + @Expose + public String role; + /** + * Tenant + *

+ * the tenant the role is associated with (accepts either the tenant id or the tenant key) + * (Required) + * + */ + @SerializedName("tenant") + @Expose + public String tenant; + /** + * User + *

+ * the user the role will be assigned to (accepts either the user id or the user key) + * (Required) + * + */ + @SerializedName("user") + @Expose + public String user; + + /** + * No args constructor for use in serialization + * + */ + public RoleAssignmentCreate() { + } + + /** + * + * @param role + * @param user + * @param tenant + */ + public RoleAssignmentCreate(String role, String tenant, String user) { + super(); + this.role = role; + this.tenant = tenant; + this.user = user; + } + + public RoleAssignmentCreate withRole(String role) { + this.role = role; + return this; + } + + public RoleAssignmentCreate withTenant(String tenant) { + this.tenant = tenant; + return this; + } + + public RoleAssignmentCreate withUser(String user) { + this.user = user; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/RoleAssignmentRead.java b/src/main/java/io/permit/sdk/openapi/models/RoleAssignmentRead.java new file mode 100644 index 0000000..f31f2fe --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/RoleAssignmentRead.java @@ -0,0 +1,221 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * RoleAssignmentRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class RoleAssignmentRead { + + /** + * Id + *

+ * Unique id of the role assignment + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * User + *

+ * the user the role is assigned to + * (Required) + * + */ + @SerializedName("user") + @Expose + public String user; + /** + * Role + *

+ * the role that is assigned + * (Required) + * + */ + @SerializedName("role") + @Expose + public String role; + /** + * Tenant + *

+ * the tenant the role is associated with + * (Required) + * + */ + @SerializedName("tenant") + @Expose + public String tenant; + /** + * User Id + *

+ * Unique id of the user + * (Required) + * + */ + @SerializedName("user_id") + @Expose + public String userId; + /** + * Role Id + *

+ * Unique id of the role + * (Required) + * + */ + @SerializedName("role_id") + @Expose + public String roleId; + /** + * Tenant Id + *

+ * Unique id of the tenant + * (Required) + * + */ + @SerializedName("tenant_id") + @Expose + public String tenantId; + /** + * Organization Id + *

+ * Unique id of the organization that the role assignment belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the role assignment belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the role assignment belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public String environmentId; + /** + * Created At + *

+ * Date and time when the role assignment was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + + /** + * No args constructor for use in serialization + * + */ + public RoleAssignmentRead() { + } + + /** + * + * @param organizationId + * @param createdAt + * @param role + * @param environmentId + * @param roleId + * @param tenantId + * @param id + * @param user + * @param userId + * @param projectId + * @param tenant + */ + public RoleAssignmentRead(String id, String user, String role, String tenant, String userId, String roleId, String tenantId, String organizationId, String projectId, String environmentId, Date createdAt) { + super(); + this.id = id; + this.user = user; + this.role = role; + this.tenant = tenant; + this.userId = userId; + this.roleId = roleId; + this.tenantId = tenantId; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + this.createdAt = createdAt; + } + + public RoleAssignmentRead withId(String id) { + this.id = id; + return this; + } + + public RoleAssignmentRead withUser(String user) { + this.user = user; + return this; + } + + public RoleAssignmentRead withRole(String role) { + this.role = role; + return this; + } + + public RoleAssignmentRead withTenant(String tenant) { + this.tenant = tenant; + return this; + } + + public RoleAssignmentRead withUserId(String userId) { + this.userId = userId; + return this; + } + + public RoleAssignmentRead withRoleId(String roleId) { + this.roleId = roleId; + return this; + } + + public RoleAssignmentRead withTenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + + public RoleAssignmentRead withOrganizationId(String organizationId) { + this.organizationId = organizationId; + return this; + } + + public RoleAssignmentRead withProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + public RoleAssignmentRead withEnvironmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + public RoleAssignmentRead withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/RoleAssignmentRemove.java b/src/main/java/io/permit/sdk/openapi/models/RoleAssignmentRemove.java new file mode 100644 index 0000000..5391069 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/RoleAssignmentRemove.java @@ -0,0 +1,84 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * RoleAssignmentRemove + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class RoleAssignmentRemove { + + /** + * Role + *

+ * the role that will be unassigned (accepts either the role id or the role key) + * (Required) + * + */ + @SerializedName("role") + @Expose + public String role; + /** + * Tenant + *

+ * the tenant the role is associated with (accepts either the tenant id or the tenant key) + * (Required) + * + */ + @SerializedName("tenant") + @Expose + public String tenant; + /** + * User + *

+ * the user the role will be unassigned from (accepts either the user id or the user key) + * (Required) + * + */ + @SerializedName("user") + @Expose + public String user; + + /** + * No args constructor for use in serialization + * + */ + public RoleAssignmentRemove() { + } + + /** + * + * @param role + * @param user + * @param tenant + */ + public RoleAssignmentRemove(String role, String tenant, String user) { + super(); + this.role = role; + this.tenant = tenant; + this.user = user; + } + + public RoleAssignmentRemove withRole(String role) { + this.role = role; + return this; + } + + public RoleAssignmentRemove withTenant(String tenant) { + this.tenant = tenant; + return this; + } + + public RoleAssignmentRemove withUser(String user) { + this.user = user; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/RoleBlock.java b/src/main/java/io/permit/sdk/openapi/models/RoleBlock.java new file mode 100644 index 0000000..4874668 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/RoleBlock.java @@ -0,0 +1,62 @@ + +package io.permit.sdk.openapi.models; + +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * RoleBlock + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class RoleBlock { + + /** + * Description + *

+ * optional description string explaining what this role represents, or what permissions are granted to it. + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Permissions + *

+ * list of action keys that define what actions this resource role is permitted to do + * + */ + @SerializedName("permissions") + @Expose + public List permissions; + /** + * Extends + *

+ * list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list. + * + */ + @SerializedName("extends") + @Expose + public List _extends; + + public RoleBlock withDescription(String description) { + this.description = description; + return this; + } + + public RoleBlock withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + + public RoleBlock withExtends(List _extends) { + this._extends = _extends; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/RoleCreate.java b/src/main/java/io/permit/sdk/openapi/models/RoleCreate.java new file mode 100644 index 0000000..25dbba1 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/RoleCreate.java @@ -0,0 +1,110 @@ + +package io.permit.sdk.openapi.models; + +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * RoleCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class RoleCreate { + + /** + * Key + *

+ * A URL-friendly name of the role (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the role. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Name + *

+ * The name of the role + * (Required) + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * optional description string explaining what this role represents, or what permissions are granted to it. + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Permissions + *

+ * list of action keys that define what actions this resource role is permitted to do + * + */ + @SerializedName("permissions") + @Expose + public List permissions; + /** + * Extends + *

+ * list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list. + * + */ + @SerializedName("extends") + @Expose + public List _extends; + + /** + * No args constructor for use in serialization + * + */ + public RoleCreate() { + } + + /** + * + * @param name + * @param key + */ + public RoleCreate(String key, String name) { + super(); + this.key = key; + this.name = name; + } + + public RoleCreate withKey(String key) { + this.key = key; + return this; + } + + public RoleCreate withName(String name) { + this.name = name; + return this; + } + + public RoleCreate withDescription(String description) { + this.description = description; + return this; + } + + public RoleCreate withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + + public RoleCreate withExtends(List _extends) { + this._extends = _extends; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/RoleRead.java b/src/main/java/io/permit/sdk/openapi/models/RoleRead.java new file mode 100644 index 0000000..c8096eb --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/RoleRead.java @@ -0,0 +1,213 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * RoleRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class RoleRead { + + /** + * Name + *

+ * The name of the role + * (Required) + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * optional description string explaining what this role represents, or what permissions are granted to it. + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Permissions + *

+ * list of action keys that define what actions this resource role is permitted to do + * + */ + @SerializedName("permissions") + @Expose + public List permissions; + /** + * Extends + *

+ * list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list. + * + */ + @SerializedName("extends") + @Expose + public List _extends; + /** + * Key + *

+ * A URL-friendly name of the role (i.e: slug). You will be able to query later using this key instead of the id (UUID) of the role. + * (Required) + * + */ + @SerializedName("key") + @Expose + public String key; + /** + * Id + *

+ * Unique id of the role + * (Required) + * + */ + @SerializedName("id") + @Expose + public String id; + /** + * Organization Id + *

+ * Unique id of the organization that the role belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the role belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the role belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public String environmentId; + /** + * Created At + *

+ * Date and time when the role was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the role was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + + /** + * No args constructor for use in serialization + * + */ + public RoleRead() { + } + + /** + * + * @param organizationId + * @param createdAt + * @param environmentId + * @param name + * @param id + * @param projectId + * @param key + * @param updatedAt + */ + public RoleRead(String name, String key, String id, String organizationId, String projectId, String environmentId, Date createdAt, Date updatedAt) { + super(); + this.name = name; + this.key = key; + this.id = id; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + } + + public RoleRead withName(String name) { + this.name = name; + return this; + } + + public RoleRead withDescription(String description) { + this.description = description; + return this; + } + + public RoleRead withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + + public RoleRead withExtends(List _extends) { + this._extends = _extends; + return this; + } + + public RoleRead withKey(String key) { + this.key = key; + return this; + } + + public RoleRead withId(String id) { + this.id = id; + return this; + } + + public RoleRead withOrganizationId(String organizationId) { + this.organizationId = organizationId; + return this; + } + + public RoleRead withProjectId(String projectId) { + this.projectId = projectId; + return this; + } + + public RoleRead withEnvironmentId(String environmentId) { + this.environmentId = environmentId; + return this; + } + + public RoleRead withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public RoleRead withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/RoleUpdate.java b/src/main/java/io/permit/sdk/openapi/models/RoleUpdate.java new file mode 100644 index 0000000..d1deec3 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/RoleUpdate.java @@ -0,0 +1,76 @@ + +package io.permit.sdk.openapi.models; + +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * RoleUpdate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class RoleUpdate { + + /** + * Name + *

+ * The name of the role + * + */ + @SerializedName("name") + @Expose + public String name; + /** + * Description + *

+ * optional description string explaining what this role represents, or what permissions are granted to it. + * + */ + @SerializedName("description") + @Expose + public String description; + /** + * Permissions + *

+ * list of action keys that define what actions this resource role is permitted to do + * + */ + @SerializedName("permissions") + @Expose + public List permissions; + /** + * Extends + *

+ * list of role keys that define what roles this role extends. In other words: this role will automatically inherit all the permissions of the given roles in this list. + * + */ + @SerializedName("extends") + @Expose + public List _extends; + + public RoleUpdate withName(String name) { + this.name = name; + return this; + } + + public RoleUpdate withDescription(String description) { + this.description = description; + return this; + } + + public RoleUpdate withPermissions(List permissions) { + this.permissions = permissions; + return this; + } + + public RoleUpdate withExtends(List _extends) { + this._extends = _extends; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/RolesBlock.java b/src/main/java/io/permit/sdk/openapi/models/RolesBlock.java new file mode 100644 index 0000000..feb0c68 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/RolesBlock.java @@ -0,0 +1,17 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; + + +/** + * RolesBlock + *

+ * Resource roles definition block, defines all the roles on the resource. + * + */ +@Generated("jsonschema2pojo") +public class RolesBlock { + + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/Settings.java b/src/main/java/io/permit/sdk/openapi/models/Settings.java new file mode 100644 index 0000000..9c50d9a --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/Settings.java @@ -0,0 +1,17 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; + + +/** + * Settings + *

+ * the settings for this project + * + */ +@Generated("jsonschema2pojo") +public class Settings { + + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/Settings__1.java b/src/main/java/io/permit/sdk/openapi/models/Settings__1.java new file mode 100644 index 0000000..f83a3cd --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/Settings__1.java @@ -0,0 +1,17 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; + + +/** + * Settings + *

+ * the settings for this project + * + */ +@Generated("jsonschema2pojo") +public class Settings__1 { + + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/Settings__2.java b/src/main/java/io/permit/sdk/openapi/models/Settings__2.java new file mode 100644 index 0000000..d5586cf --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/Settings__2.java @@ -0,0 +1,17 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; + + +/** + * Settings + *

+ * the settings for this project + * + */ +@Generated("jsonschema2pojo") +public class Settings__2 { + + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/Settings__3.java b/src/main/java/io/permit/sdk/openapi/models/Settings__3.java new file mode 100644 index 0000000..00ce996 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/Settings__3.java @@ -0,0 +1,17 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; + + +/** + * Settings + *

+ * the settings for this project + * + */ +@Generated("jsonschema2pojo") +public class Settings__3 { + + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/Settings__4.java b/src/main/java/io/permit/sdk/openapi/models/Settings__4.java new file mode 100644 index 0000000..d06d611 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/Settings__4.java @@ -0,0 +1,17 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; + + +/** + * Settings + *

+ * the settings for this project + * + */ +@Generated("jsonschema2pojo") +public class Settings__4 { + + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/Settings__5.java b/src/main/java/io/permit/sdk/openapi/models/Settings__5.java new file mode 100644 index 0000000..7da16b3 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/Settings__5.java @@ -0,0 +1,17 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; + + +/** + * Settings + *

+ * the settings for this project + * + */ +@Generated("jsonschema2pojo") +public class Settings__5 { + + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/Settings__6.java b/src/main/java/io/permit/sdk/openapi/models/Settings__6.java new file mode 100644 index 0000000..6ba2e1d --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/Settings__6.java @@ -0,0 +1,17 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; + + +/** + * Settings + *

+ * the settings for this project + * + */ +@Generated("jsonschema2pojo") +public class Settings__6 { + + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/Statistics.java b/src/main/java/io/permit/sdk/openapi/models/Statistics.java new file mode 100644 index 0000000..c35903e --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/Statistics.java @@ -0,0 +1,135 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * Statistics + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class Statistics { + + /** + * Roles + *

+ * + * (Required) + * + */ + @SerializedName("roles") + @Expose + public Integer roles; + /** + * Users + *

+ * + * (Required) + * + */ + @SerializedName("users") + @Expose + public Integer users; + /** + * Policies + *

+ * + * (Required) + * + */ + @SerializedName("policies") + @Expose + public Integer policies; + /** + * Resources + *

+ * + * (Required) + * + */ + @SerializedName("resources") + @Expose + public Integer resources; + /** + * Tenants + *

+ * + * (Required) + * + */ + @SerializedName("tenants") + @Expose + public Integer tenants; + /** + * Has Decision Logs + *

+ * + * (Required) + * + */ + @SerializedName("has_decision_logs") + @Expose + public Boolean hasDecisionLogs; + + /** + * No args constructor for use in serialization + * + */ + public Statistics() { + } + + /** + * + * @param tenants + * @param roles + * @param policies + * @param resources + * @param hasDecisionLogs + * @param users + */ + public Statistics(Integer roles, Integer users, Integer policies, Integer resources, Integer tenants, Boolean hasDecisionLogs) { + super(); + this.roles = roles; + this.users = users; + this.policies = policies; + this.resources = resources; + this.tenants = tenants; + this.hasDecisionLogs = hasDecisionLogs; + } + + public Statistics withRoles(Integer roles) { + this.roles = roles; + return this; + } + + public Statistics withUsers(Integer users) { + this.users = users; + return this; + } + + public Statistics withPolicies(Integer policies) { + this.policies = policies; + return this; + } + + public Statistics withResources(Integer resources) { + this.resources = resources; + return this; + } + + public Statistics withTenants(Integer tenants) { + this.tenants = tenants; + return this; + } + + public Statistics withHasDecisionLogs(Boolean hasDecisionLogs) { + this.hasDecisionLogs = hasDecisionLogs; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/Statistics__1.java b/src/main/java/io/permit/sdk/openapi/models/Statistics__1.java new file mode 100644 index 0000000..1e9af13 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/Statistics__1.java @@ -0,0 +1,135 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * Statistics + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class Statistics__1 { + + /** + * Roles + *

+ * + * (Required) + * + */ + @SerializedName("roles") + @Expose + public Integer roles; + /** + * Users + *

+ * + * (Required) + * + */ + @SerializedName("users") + @Expose + public Integer users; + /** + * Policies + *

+ * + * (Required) + * + */ + @SerializedName("policies") + @Expose + public Integer policies; + /** + * Resources + *

+ * + * (Required) + * + */ + @SerializedName("resources") + @Expose + public Integer resources; + /** + * Tenants + *

+ * + * (Required) + * + */ + @SerializedName("tenants") + @Expose + public Integer tenants; + /** + * Has Decision Logs + *

+ * + * (Required) + * + */ + @SerializedName("has_decision_logs") + @Expose + public Boolean hasDecisionLogs; + + /** + * No args constructor for use in serialization + * + */ + public Statistics__1() { + } + + /** + * + * @param tenants + * @param roles + * @param policies + * @param resources + * @param hasDecisionLogs + * @param users + */ + public Statistics__1(Integer roles, Integer users, Integer policies, Integer resources, Integer tenants, Boolean hasDecisionLogs) { + super(); + this.roles = roles; + this.users = users; + this.policies = policies; + this.resources = resources; + this.tenants = tenants; + this.hasDecisionLogs = hasDecisionLogs; + } + + public Statistics__1 withRoles(Integer roles) { + this.roles = roles; + return this; + } + + public Statistics__1 withUsers(Integer users) { + this.users = users; + return this; + } + + public Statistics__1 withPolicies(Integer policies) { + this.policies = policies; + return this; + } + + public Statistics__1 withResources(Integer resources) { + this.resources = resources; + return this; + } + + public Statistics__1 withTenants(Integer tenants) { + this.tenants = tenants; + return this; + } + + public Statistics__1 withHasDecisionLogs(Boolean hasDecisionLogs) { + this.hasDecisionLogs = hasDecisionLogs; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/TenantCreate.java b/src/main/java/io/permit/sdk/openapi/models/TenantCreate.java new file mode 100644 index 0000000..f8667fe --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/TenantCreate.java @@ -0,0 +1,96 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * TenantCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class TenantCreate { + + /** + * Key + *

+ * A unique id by which Permit will identify the tenant. The tenant key must be url-friendly (slugified). + * (Required) + * + */ + @SerializedName("key") + @Expose + public java.lang.String key; + /** + * Name + *

+ * A descriptive name for the tenant + * (Required) + * + */ + @SerializedName("name") + @Expose + public java.lang.String name; + /** + * Description + *

+ * an optional longer description of the tenant + * + */ + @SerializedName("description") + @Expose + public java.lang.String description; + /** + * Attributes + *

+ * Arbitraty tenant attributes that will be used to enforce attribute-based access control policies. + * + */ + @SerializedName("attributes") + @Expose + public HashMap attributes; + + /** + * No args constructor for use in serialization + * + */ + public TenantCreate() { + } + + /** + * + * @param name + * @param key + */ + public TenantCreate(java.lang.String key, java.lang.String name) { + super(); + this.key = key; + this.name = name; + } + + public TenantCreate withKey(java.lang.String key) { + this.key = key; + return this; + } + + public TenantCreate withName(java.lang.String name) { + this.name = name; + return this; + } + + public TenantCreate withDescription(java.lang.String description) { + this.description = description; + return this; + } + + public TenantCreate withAttributes(HashMap attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/TenantRead.java b/src/main/java/io/permit/sdk/openapi/models/TenantRead.java new file mode 100644 index 0000000..2c3459c --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/TenantRead.java @@ -0,0 +1,216 @@ + +package io.permit.sdk.openapi.models; + +import java.util.Date; +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * TenantRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class TenantRead { + + /** + * Key + *

+ * A unique id by which Permit will identify the tenant. The tenant key must be url-friendly (slugified). + * (Required) + * + */ + @SerializedName("key") + @Expose + public java.lang.String key; + /** + * Id + *

+ * Unique id of the tenant + * (Required) + * + */ + @SerializedName("id") + @Expose + public java.lang.String id; + /** + * Organization Id + *

+ * Unique id of the organization that the tenant belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public java.lang.String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the tenant belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public java.lang.String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the tenant belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public java.lang.String environmentId; + /** + * Created At + *

+ * Date and time when the tenant was created (ISO_8601 format). + * (Required) + * + */ + @SerializedName("created_at") + @Expose + public Date createdAt; + /** + * Updated At + *

+ * Date and time when the tenant was last updated/modified (ISO_8601 format). + * (Required) + * + */ + @SerializedName("updated_at") + @Expose + public Date updatedAt; + /** + * Last Action At + *

+ * Date and time when the tenant was last active (ISO_8601 format). In other words, this is the last time a permission check was done on a resource belonging to this tenant. + * (Required) + * + */ + @SerializedName("last_action_at") + @Expose + public Date lastActionAt; + /** + * Name + *

+ * A descriptive name for the tenant + * (Required) + * + */ + @SerializedName("name") + @Expose + public java.lang.String name; + /** + * Description + *

+ * an optional longer description of the tenant + * + */ + @SerializedName("description") + @Expose + public java.lang.String description; + /** + * Attributes + *

+ * Arbitraty tenant attributes that will be used to enforce attribute-based access control policies. + * + */ + @SerializedName("attributes") + @Expose + public HashMap attributes; + + /** + * No args constructor for use in serialization + * + */ + public TenantRead() { + } + + /** + * + * @param organizationId + * @param createdAt + * @param environmentId + * @param lastActionAt + * @param name + * @param id + * @param projectId + * @param key + * @param updatedAt + */ + public TenantRead(java.lang.String key, java.lang.String id, java.lang.String organizationId, java.lang.String projectId, java.lang.String environmentId, Date createdAt, Date updatedAt, Date lastActionAt, java.lang.String name) { + super(); + this.key = key; + this.id = id; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + this.createdAt = createdAt; + this.updatedAt = updatedAt; + this.lastActionAt = lastActionAt; + this.name = name; + } + + public TenantRead withKey(java.lang.String key) { + this.key = key; + return this; + } + + public TenantRead withId(java.lang.String id) { + this.id = id; + return this; + } + + public TenantRead withOrganizationId(java.lang.String organizationId) { + this.organizationId = organizationId; + return this; + } + + public TenantRead withProjectId(java.lang.String projectId) { + this.projectId = projectId; + return this; + } + + public TenantRead withEnvironmentId(java.lang.String environmentId) { + this.environmentId = environmentId; + return this; + } + + public TenantRead withCreatedAt(Date createdAt) { + this.createdAt = createdAt; + return this; + } + + public TenantRead withUpdatedAt(Date updatedAt) { + this.updatedAt = updatedAt; + return this; + } + + public TenantRead withLastActionAt(Date lastActionAt) { + this.lastActionAt = lastActionAt; + return this; + } + + public TenantRead withName(java.lang.String name) { + this.name = name; + return this; + } + + public TenantRead withDescription(java.lang.String description) { + this.description = description; + return this; + } + + public TenantRead withAttributes(HashMap attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/TenantUpdate.java b/src/main/java/io/permit/sdk/openapi/models/TenantUpdate.java new file mode 100644 index 0000000..e0f9c8a --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/TenantUpdate.java @@ -0,0 +1,62 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * TenantUpdate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class TenantUpdate { + + /** + * Name + *

+ * A descriptive name for the tenant + * + */ + @SerializedName("name") + @Expose + public java.lang.String name; + /** + * Description + *

+ * an optional longer description of the tenant + * + */ + @SerializedName("description") + @Expose + public java.lang.String description; + /** + * Attributes + *

+ * Arbitraty tenant attributes that will be used to enforce attribute-based access control policies. + * + */ + @SerializedName("attributes") + @Expose + public HashMap attributes; + + public TenantUpdate withName(java.lang.String name) { + this.name = name; + return this; + } + + public TenantUpdate withDescription(java.lang.String description) { + this.description = description; + return this; + } + + public TenantUpdate withAttributes(HashMap attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/UserCreate.java b/src/main/java/io/permit/sdk/openapi/models/UserCreate.java new file mode 100644 index 0000000..8fe1bbb --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/UserCreate.java @@ -0,0 +1,107 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * UserCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class UserCreate { + + /** + * Key + *

+ * A unique id by which Permit will identify the user for permission checks. + * (Required) + * + */ + @SerializedName("key") + @Expose + public java.lang.String key; + /** + * Email + *

+ * The email of the user. If synced, will be unique inside the environment. + * + */ + @SerializedName("email") + @Expose + public java.lang.String email; + /** + * First Name + *

+ * First name of the user. + * + */ + @SerializedName("first_name") + @Expose + public java.lang.String firstName; + /** + * Last Name + *

+ * Last name of the user. + * + */ + @SerializedName("last_name") + @Expose + public java.lang.String lastName; + /** + * Attributes + *

+ * Arbitrary user attributes that will be used to enforce attribute-based access control policies. + * + */ + @SerializedName("attributes") + @Expose + public HashMap attributes; + + /** + * No args constructor for use in serialization + * + */ + public UserCreate() { + } + + /** + * + * @param key + */ + public UserCreate(java.lang.String key) { + super(); + this.key = key; + } + + public UserCreate withKey(java.lang.String key) { + this.key = key; + return this; + } + + public UserCreate withEmail(java.lang.String email) { + this.email = email; + return this; + } + + public UserCreate withFirstName(java.lang.String firstName) { + this.firstName = firstName; + return this; + } + + public UserCreate withLastName(java.lang.String lastName) { + this.lastName = lastName; + return this; + } + + public UserCreate withAttributes(HashMap attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/UserInTenant.java b/src/main/java/io/permit/sdk/openapi/models/UserInTenant.java new file mode 100644 index 0000000..91b8049 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/UserInTenant.java @@ -0,0 +1,134 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * UserInTenant + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class UserInTenant { + + /** + * Tenant + *

+ * The tenant key which the user is associated with + * (Required) + * + */ + @SerializedName("tenant") + @Expose + public String tenant; + /** + * Roles + *

+ * List of roles assigned to the user in that tenant + * (Required) + * + */ + @SerializedName("roles") + @Expose + public List roles; + /** + * UserStatus + *

+ * Whether the user has signed in or not + * (Required) + * + */ + @SerializedName("status") + @Expose + public UserInTenant.UserStatus status; + + /** + * No args constructor for use in serialization + * + */ + public UserInTenant() { + } + + /** + * + * @param roles + * @param tenant + * @param status + */ + public UserInTenant(String tenant, List roles, UserInTenant.UserStatus status) { + super(); + this.tenant = tenant; + this.roles = roles; + this.status = status; + } + + public UserInTenant withTenant(String tenant) { + this.tenant = tenant; + return this; + } + + public UserInTenant withRoles(List roles) { + this.roles = roles; + return this; + } + + public UserInTenant withStatus(UserInTenant.UserStatus status) { + this.status = status; + return this; + } + + + /** + * UserStatus + *

+ * Whether the user has signed in or not + * + */ + @Generated("jsonschema2pojo") + public enum UserStatus { + + @SerializedName("active") + ACTIVE("active"), + @SerializedName("pending") + PENDING("pending"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (UserInTenant.UserStatus c: values()) { + CONSTANTS.put(c.value, c); + } + } + + UserStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static UserInTenant.UserStatus fromValue(String value) { + UserInTenant.UserStatus constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/UserInTenant__1.java b/src/main/java/io/permit/sdk/openapi/models/UserInTenant__1.java new file mode 100644 index 0000000..2291d17 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/UserInTenant__1.java @@ -0,0 +1,85 @@ + +package io.permit.sdk.openapi.models; + +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * UserInTenant + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class UserInTenant__1 { + + /** + * Tenant + *

+ * The tenant key which the user is associated with + * (Required) + * + */ + @SerializedName("tenant") + @Expose + public String tenant; + /** + * Roles + *

+ * List of roles assigned to the user in that tenant + * (Required) + * + */ + @SerializedName("roles") + @Expose + public List roles; + /** + * UserStatus + *

+ * Whether the user has signed in or not + * (Required) + * + */ + @SerializedName("status") + @Expose + public io.permit.sdk.openapi.models.UserInTenant.UserStatus status; + + /** + * No args constructor for use in serialization + * + */ + public UserInTenant__1() { + } + + /** + * + * @param roles + * @param tenant + * @param status + */ + public UserInTenant__1(String tenant, List roles, io.permit.sdk.openapi.models.UserInTenant.UserStatus status) { + super(); + this.tenant = tenant; + this.roles = roles; + this.status = status; + } + + public UserInTenant__1 withTenant(String tenant) { + this.tenant = tenant; + return this; + } + + public UserInTenant__1 withRoles(List roles) { + this.roles = roles; + return this; + } + + public UserInTenant__1 withStatus(io.permit.sdk.openapi.models.UserInTenant.UserStatus status) { + this.status = status; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/UserLoginRequestInput.java b/src/main/java/io/permit/sdk/openapi/models/UserLoginRequestInput.java new file mode 100644 index 0000000..d79aa61 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/UserLoginRequestInput.java @@ -0,0 +1,67 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * UserLoginRequestInput + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class UserLoginRequestInput { + + /** + * User Id + *

+ * ID or key of the user for whom to generate a token + * (Required) + * + */ + @SerializedName("user_id") + @Expose + public String userId; + /** + * Tenant Id + *

+ * ID or key of the tenant to which access is requested + * (Required) + * + */ + @SerializedName("tenant_id") + @Expose + public String tenantId; + + /** + * No args constructor for use in serialization + * + */ + public UserLoginRequestInput() { + } + + /** + * + * @param tenantId + * @param userId + */ + public UserLoginRequestInput(String userId, String tenantId) { + super(); + this.userId = userId; + this.tenantId = tenantId; + } + + public UserLoginRequestInput withUserId(String userId) { + this.userId = userId; + return this; + } + + public UserLoginRequestInput withTenantId(String tenantId) { + this.tenantId = tenantId; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/UserRead.java b/src/main/java/io/permit/sdk/openapi/models/UserRead.java new file mode 100644 index 0000000..bbaba4c --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/UserRead.java @@ -0,0 +1,204 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * UserRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class UserRead { + + /** + * Key + *

+ * A unique id by which Permit will identify the user for permission checks. + * (Required) + * + */ + @SerializedName("key") + @Expose + public java.lang.String key; + /** + * Id + *

+ * Unique id of the user + * (Required) + * + */ + @SerializedName("id") + @Expose + public java.lang.String id; + /** + * Organization Id + *

+ * Unique id of the organization that the user belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public java.lang.String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the user belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public java.lang.String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the user belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public java.lang.String environmentId; + /** + * Associated Tenants + *

+ * + * + */ + @SerializedName("associated_tenants") + @Expose + public List associatedTenants; + /** + * Roles + *

+ * + * + */ + @SerializedName("roles") + @Expose + public List roles; + /** + * Email + *

+ * The email of the user. If synced, will be unique inside the environment. + * + */ + @SerializedName("email") + @Expose + public java.lang.String email; + /** + * First Name + *

+ * First name of the user. + * + */ + @SerializedName("first_name") + @Expose + public java.lang.String firstName; + /** + * Last Name + *

+ * Last name of the user. + * + */ + @SerializedName("last_name") + @Expose + public java.lang.String lastName; + /** + * Attributes + *

+ * Arbitrary user attributes that will be used to enforce attribute-based access control policies. + * + */ + @SerializedName("attributes") + @Expose + public HashMap attributes; + + /** + * No args constructor for use in serialization + * + */ + public UserRead() { + } + + /** + * + * @param organizationId + * @param environmentId + * @param id + * @param projectId + * @param key + */ + public UserRead(java.lang.String key, java.lang.String id, java.lang.String organizationId, java.lang.String projectId, java.lang.String environmentId) { + super(); + this.key = key; + this.id = id; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + } + + public UserRead withKey(java.lang.String key) { + this.key = key; + return this; + } + + public UserRead withId(java.lang.String id) { + this.id = id; + return this; + } + + public UserRead withOrganizationId(java.lang.String organizationId) { + this.organizationId = organizationId; + return this; + } + + public UserRead withProjectId(java.lang.String projectId) { + this.projectId = projectId; + return this; + } + + public UserRead withEnvironmentId(java.lang.String environmentId) { + this.environmentId = environmentId; + return this; + } + + public UserRead withAssociatedTenants(List associatedTenants) { + this.associatedTenants = associatedTenants; + return this; + } + + public UserRead withRoles(List roles) { + this.roles = roles; + return this; + } + + public UserRead withEmail(java.lang.String email) { + this.email = email; + return this; + } + + public UserRead withFirstName(java.lang.String firstName) { + this.firstName = firstName; + return this; + } + + public UserRead withLastName(java.lang.String lastName) { + this.lastName = lastName; + return this; + } + + public UserRead withAttributes(HashMap attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/UserRead__1.java b/src/main/java/io/permit/sdk/openapi/models/UserRead__1.java new file mode 100644 index 0000000..3409152 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/UserRead__1.java @@ -0,0 +1,204 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * UserRead + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class UserRead__1 { + + /** + * Key + *

+ * A unique id by which Permit will identify the user for permission checks. + * (Required) + * + */ + @SerializedName("key") + @Expose + public java.lang.String key; + /** + * Id + *

+ * Unique id of the user + * (Required) + * + */ + @SerializedName("id") + @Expose + public java.lang.String id; + /** + * Organization Id + *

+ * Unique id of the organization that the user belongs to. + * (Required) + * + */ + @SerializedName("organization_id") + @Expose + public java.lang.String organizationId; + /** + * Project Id + *

+ * Unique id of the project that the user belongs to. + * (Required) + * + */ + @SerializedName("project_id") + @Expose + public java.lang.String projectId; + /** + * Environment Id + *

+ * Unique id of the environment that the user belongs to. + * (Required) + * + */ + @SerializedName("environment_id") + @Expose + public java.lang.String environmentId; + /** + * Associated Tenants + *

+ * + * + */ + @SerializedName("associated_tenants") + @Expose + public List associatedTenants; + /** + * Roles + *

+ * + * + */ + @SerializedName("roles") + @Expose + public List roles; + /** + * Email + *

+ * The email of the user. If synced, will be unique inside the environment. + * + */ + @SerializedName("email") + @Expose + public java.lang.String email; + /** + * First Name + *

+ * First name of the user. + * + */ + @SerializedName("first_name") + @Expose + public java.lang.String firstName; + /** + * Last Name + *

+ * Last name of the user. + * + */ + @SerializedName("last_name") + @Expose + public java.lang.String lastName; + /** + * Attributes + *

+ * Arbitrary user attributes that will be used to enforce attribute-based access control policies. + * + */ + @SerializedName("attributes") + @Expose + public HashMap attributes; + + /** + * No args constructor for use in serialization + * + */ + public UserRead__1() { + } + + /** + * + * @param organizationId + * @param environmentId + * @param id + * @param projectId + * @param key + */ + public UserRead__1(java.lang.String key, java.lang.String id, java.lang.String organizationId, java.lang.String projectId, java.lang.String environmentId) { + super(); + this.key = key; + this.id = id; + this.organizationId = organizationId; + this.projectId = projectId; + this.environmentId = environmentId; + } + + public UserRead__1 withKey(java.lang.String key) { + this.key = key; + return this; + } + + public UserRead__1 withId(java.lang.String id) { + this.id = id; + return this; + } + + public UserRead__1 withOrganizationId(java.lang.String organizationId) { + this.organizationId = organizationId; + return this; + } + + public UserRead__1 withProjectId(java.lang.String projectId) { + this.projectId = projectId; + return this; + } + + public UserRead__1 withEnvironmentId(java.lang.String environmentId) { + this.environmentId = environmentId; + return this; + } + + public UserRead__1 withAssociatedTenants(List associatedTenants) { + this.associatedTenants = associatedTenants; + return this; + } + + public UserRead__1 withRoles(List roles) { + this.roles = roles; + return this; + } + + public UserRead__1 withEmail(java.lang.String email) { + this.email = email; + return this; + } + + public UserRead__1 withFirstName(java.lang.String firstName) { + this.firstName = firstName; + return this; + } + + public UserRead__1 withLastName(java.lang.String lastName) { + this.lastName = lastName; + return this; + } + + public UserRead__1 withAttributes(HashMap attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/UserRole.java b/src/main/java/io/permit/sdk/openapi/models/UserRole.java new file mode 100644 index 0000000..1684aae --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/UserRole.java @@ -0,0 +1,67 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * UserRole + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class UserRole { + + /** + * Role + *

+ * the role that is assigned + * (Required) + * + */ + @SerializedName("role") + @Expose + public String role; + /** + * Tenant + *

+ * the tenant the role is associated with + * (Required) + * + */ + @SerializedName("tenant") + @Expose + public String tenant; + + /** + * No args constructor for use in serialization + * + */ + public UserRole() { + } + + /** + * + * @param role + * @param tenant + */ + public UserRole(String role, String tenant) { + super(); + this.role = role; + this.tenant = tenant; + } + + public UserRole withRole(String role) { + this.role = role; + return this; + } + + public UserRole withTenant(String tenant) { + this.tenant = tenant; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/UserRoleCreate.java b/src/main/java/io/permit/sdk/openapi/models/UserRoleCreate.java new file mode 100644 index 0000000..e827b35 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/UserRoleCreate.java @@ -0,0 +1,67 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * UserRoleCreate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class UserRoleCreate { + + /** + * Role + *

+ * the role that will be assigned (accepts either the role id or the role key) + * (Required) + * + */ + @SerializedName("role") + @Expose + public String role; + /** + * Tenant + *

+ * the tenant the role is associated with (accepts either the tenant id or the tenant key) + * (Required) + * + */ + @SerializedName("tenant") + @Expose + public String tenant; + + /** + * No args constructor for use in serialization + * + */ + public UserRoleCreate() { + } + + /** + * + * @param role + * @param tenant + */ + public UserRoleCreate(String role, String tenant) { + super(); + this.role = role; + this.tenant = tenant; + } + + public UserRoleCreate withRole(String role) { + this.role = role; + return this; + } + + public UserRoleCreate withTenant(String tenant) { + this.tenant = tenant; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/UserRoleRemove.java b/src/main/java/io/permit/sdk/openapi/models/UserRoleRemove.java new file mode 100644 index 0000000..64efa65 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/UserRoleRemove.java @@ -0,0 +1,67 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * UserRoleRemove + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class UserRoleRemove { + + /** + * Role + *

+ * the role that will be unassigned (accepts either the role id or the role key) + * (Required) + * + */ + @SerializedName("role") + @Expose + public String role; + /** + * Tenant + *

+ * the tenant the role is associated with (accepts either the tenant id or the tenant key) + * (Required) + * + */ + @SerializedName("tenant") + @Expose + public String tenant; + + /** + * No args constructor for use in serialization + * + */ + public UserRoleRemove() { + } + + /** + * + * @param role + * @param tenant + */ + public UserRoleRemove(String role, String tenant) { + super(); + this.role = role; + this.tenant = tenant; + } + + public UserRoleRemove withRole(String role) { + this.role = role; + return this; + } + + public UserRoleRemove withTenant(String tenant) { + this.tenant = tenant; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/UserRole__1.java b/src/main/java/io/permit/sdk/openapi/models/UserRole__1.java new file mode 100644 index 0000000..2d2640c --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/UserRole__1.java @@ -0,0 +1,67 @@ + +package io.permit.sdk.openapi.models; + +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * UserRole + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class UserRole__1 { + + /** + * Role + *

+ * the role that is assigned + * (Required) + * + */ + @SerializedName("role") + @Expose + public String role; + /** + * Tenant + *

+ * the tenant the role is associated with + * (Required) + * + */ + @SerializedName("tenant") + @Expose + public String tenant; + + /** + * No args constructor for use in serialization + * + */ + public UserRole__1() { + } + + /** + * + * @param role + * @param tenant + */ + public UserRole__1(String role, String tenant) { + super(); + this.role = role; + this.tenant = tenant; + } + + public UserRole__1 withRole(String role) { + this.role = role; + return this; + } + + public UserRole__1 withTenant(String tenant) { + this.tenant = tenant; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/UserStatus.java b/src/main/java/io/permit/sdk/openapi/models/UserStatus.java new file mode 100644 index 0000000..53b7a16 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/UserStatus.java @@ -0,0 +1,54 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import java.util.Map; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.SerializedName; + + +/** + * UserStatus + *

+ * Whether the user has signed in or not + * + */ +@Generated("jsonschema2pojo") +public enum UserStatus { + + @SerializedName("active") + ACTIVE("active"), + @SerializedName("pending") + PENDING("pending"); + private final String value; + private final static Map CONSTANTS = new HashMap(); + + static { + for (UserStatus c: values()) { + CONSTANTS.put(c.value, c); + } + } + + UserStatus(String value) { + this.value = value; + } + + @Override + public String toString() { + return this.value; + } + + public String value() { + return this.value; + } + + public static UserStatus fromValue(String value) { + UserStatus constant = CONSTANTS.get(value); + if (constant == null) { + throw new IllegalArgumentException(value); + } else { + return constant; + } + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/UserUpdate.java b/src/main/java/io/permit/sdk/openapi/models/UserUpdate.java new file mode 100644 index 0000000..a5c310e --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/UserUpdate.java @@ -0,0 +1,76 @@ + +package io.permit.sdk.openapi.models; + +import java.util.HashMap; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * UserUpdate + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class UserUpdate { + + /** + * Email + *

+ * The email of the user. If synced, will be unique inside the environment. + * + */ + @SerializedName("email") + @Expose + public java.lang.String email; + /** + * First Name + *

+ * First name of the user. + * + */ + @SerializedName("first_name") + @Expose + public java.lang.String firstName; + /** + * Last Name + *

+ * Last name of the user. + * + */ + @SerializedName("last_name") + @Expose + public java.lang.String lastName; + /** + * Attributes + *

+ * Arbitrary user attributes that will be used to enforce attribute-based access control policies. + * + */ + @SerializedName("attributes") + @Expose + public HashMap attributes; + + public UserUpdate withEmail(java.lang.String email) { + this.email = email; + return this; + } + + public UserUpdate withFirstName(java.lang.String firstName) { + this.firstName = firstName; + return this; + } + + public UserUpdate withLastName(java.lang.String lastName) { + this.lastName = lastName; + return this; + } + + public UserUpdate withAttributes(HashMap attributes) { + this.attributes = attributes; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ValidationError.java b/src/main/java/io/permit/sdk/openapi/models/ValidationError.java new file mode 100644 index 0000000..119e82d --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ValidationError.java @@ -0,0 +1,85 @@ + +package io.permit.sdk.openapi.models; + +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ValidationError + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ValidationError { + + /** + * Location + *

+ * + * (Required) + * + */ + @SerializedName("loc") + @Expose + public List loc; + /** + * Message + *

+ * + * (Required) + * + */ + @SerializedName("msg") + @Expose + public String msg; + /** + * Error Type + *

+ * + * (Required) + * + */ + @SerializedName("type") + @Expose + public String type; + + /** + * No args constructor for use in serialization + * + */ + public ValidationError() { + } + + /** + * + * @param msg + * @param loc + * @param type + */ + public ValidationError(List loc, String msg, String type) { + super(); + this.loc = loc; + this.msg = msg; + this.type = type; + } + + public ValidationError withLoc(List loc) { + this.loc = loc; + return this; + } + + public ValidationError withMsg(String msg) { + this.msg = msg; + return this; + } + + public ValidationError withType(String type) { + this.type = type; + return this; + } + +} diff --git a/src/main/java/io/permit/sdk/openapi/models/ValidationError__1.java b/src/main/java/io/permit/sdk/openapi/models/ValidationError__1.java new file mode 100644 index 0000000..11a9eb5 --- /dev/null +++ b/src/main/java/io/permit/sdk/openapi/models/ValidationError__1.java @@ -0,0 +1,85 @@ + +package io.permit.sdk.openapi.models; + +import java.util.List; +import javax.annotation.processing.Generated; +import com.google.gson.annotations.Expose; +import com.google.gson.annotations.SerializedName; + + +/** + * ValidationError + *

+ * + * + */ +@Generated("jsonschema2pojo") +public class ValidationError__1 { + + /** + * Location + *

+ * + * (Required) + * + */ + @SerializedName("loc") + @Expose + public List loc; + /** + * Message + *

+ * + * (Required) + * + */ + @SerializedName("msg") + @Expose + public String msg; + /** + * Error Type + *

+ * + * (Required) + * + */ + @SerializedName("type") + @Expose + public String type; + + /** + * No args constructor for use in serialization + * + */ + public ValidationError__1() { + } + + /** + * + * @param msg + * @param loc + * @param type + */ + public ValidationError__1(List loc, String msg, String type) { + super(); + this.loc = loc; + this.msg = msg; + this.type = type; + } + + public ValidationError__1 withLoc(List loc) { + this.loc = loc; + return this; + } + + public ValidationError__1 withMsg(String msg) { + this.msg = msg; + return this; + } + + public ValidationError__1 withType(String type) { + this.type = type; + return this; + } + +} diff --git a/src/test/java/io/permit/sdk/PermissionCheckE2ETest.java b/src/test/java/io/permit/sdk/PermissionCheckE2ETest.java new file mode 100644 index 0000000..117db2b --- /dev/null +++ b/src/test/java/io/permit/sdk/PermissionCheckE2ETest.java @@ -0,0 +1,224 @@ +package io.permit.sdk; + +import com.google.gson.Gson; +import com.google.gson.internal.LinkedTreeMap; +import io.permit.sdk.api.PermitApiError; +import io.permit.sdk.api.PermitContextError; +import io.permit.sdk.api.UsersApi; +import io.permit.sdk.api.models.CreateOrUpdateResult; +import io.permit.sdk.enforcement.Resource; +import io.permit.sdk.enforcement.User; +import io.permit.sdk.openapi.models.*; +import org.junit.jupiter.api.Test; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.HashMap; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * this e2e test should run against a clean permit environment. + * if the environment contains any objects the test will fail. + * eventually we want to create an environment programmatically + * and then extract the api key and start the test. + */ +public class PermissionCheckE2ETest extends PermitE2ETestBase { + private final Logger logger = LoggerFactory.getLogger(PermissionCheckE2ETest.class); + + @Test + void testPermissionCheckRBAC() { + // init the client + Permit permit = new Permit(this.config); + + try { + // resource actions + HashMap actions = new HashMap<>(); + actions.put("create", new ActionBlockEditable()); + actions.put("read", new ActionBlockEditable().withName("Read").withDescription("Read Action")); + actions.put("update", new ActionBlockEditable()); + actions.put("delete", new ActionBlockEditable()); + + // resource attributes + HashMap attributes = new HashMap<>(); + attributes.put( + "private", + new AttributeBlockEditable().withType(AttributeType.BOOL).withDescription("whether the document is private") + ); + + // 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); + + // verify create output + assertNotNull(document); + assertNotNull(document.id); + assertEquals(document.key, "document"); + assertEquals(document.name, "Document"); + assertEquals(document.description, "google drive document"); + assertEquals(document.urn, "prn:gdrive:document"); + assertEquals(document.actions.size(), 4); + assertTrue(document.actions.containsKey("create")); + assertTrue(document.actions.containsKey("read")); + assertTrue(document.actions.containsKey("update")); + assertTrue(document.actions.containsKey("delete")); + + // verify list output + ResourceRead[] resources = permit.api.resources.list(); + assertEquals(resources.length, 1); + assertEquals(resources[0].id, document.id); + assertEquals(resources[0].key, document.key); + assertEquals(resources[0].name, document.name); + assertEquals(resources[0].description, document.description); + assertEquals(resources[0].urn, document.urn); + + // create admin role + RoleRead admin = permit.api.roles.create( + new RoleCreate("admin","Admin") + .withDescription("an admin role") + .withPermissions( + new ArrayList<>(Arrays.asList("document:create", "document:read")) + ) + ); + assertNotNull(admin); + assertEquals(admin.key, "admin"); + assertEquals(admin.name, "Admin"); + assertEquals(admin.description, "an admin role"); + assertTrue(admin.permissions.containsAll(Arrays.asList("document:create", "document:read"))); + + // create viewer role + RoleRead viewer = permit.api.roles.create( + new RoleCreate("viewer","Viewer") + .withDescription("an viewer role") + ); + assertNotNull(viewer); + assertEquals(viewer.key, "viewer"); + assertEquals(viewer.name, "Viewer"); + assertEquals(viewer.description, "an viewer role"); + assertEquals(viewer.permissions.size(), 0); + + // assign permissions to roles + viewer = permit.api.roles.assignPermissions("viewer", new ArrayList<>(Arrays.asList("document:read"))); + assertEquals(viewer.key, "viewer"); + assertEquals(viewer.permissions.size(), 1); + assertTrue(viewer.permissions.contains("document:read")); + assertFalse(viewer.permissions.contains("document:create")); + + // create a tenant + TenantRead tenant = permit.api.tenants.create( + new TenantCreate("tesla", "Tesla Inc").withDescription("The car company") + ); + assertEquals(tenant.key, "tesla"); + assertEquals(tenant.name, "Tesla Inc"); + assertEquals(tenant.description, "The car company"); + assertNull(tenant.attributes); + + // create a user + HashMap userAttributes = new HashMap<>(); + userAttributes.put("age", Integer.valueOf(50)); + userAttributes.put("fav_color", "red"); + + User userInput = (new User.Builder("auth0|elon")) + .withEmail("elonmusk@tesla.com") + .withFirstName("Elon") + .withLastName("Musk") + .withAttributes(userAttributes) + .build(); + CreateOrUpdateResult result = permit.api.users.sync(userInput); + UserRead user = result.getResult(); + assertTrue(result.wasCreated()); + assertEquals(user.key, "auth0|elon"); + assertEquals(user.email, "elonmusk@tesla.com"); + assertEquals(user.firstName, "Elon"); + assertEquals(user.lastName, "Musk"); + assertEquals(user.attributes.size(), 2); + assertEquals(((Double)user.attributes.get("age")).doubleValue(), 50.0); + assertEquals(((String)user.attributes.get("fav_color")), "red"); + + // assign role to user in tenant + RoleAssignmentRead ra = permit.api.users.assignRole("auth0|elon", "viewer", "tesla"); + assertEquals(ra.userId, user.id); + assertEquals(ra.roleId, viewer.id); + assertEquals(ra.tenantId, tenant.id); + assertEquals(ra.user, user.email); // TODO: fix bug + assertEquals(ra.role, viewer.key); + assertEquals(ra.tenant, tenant.key); + + logger.info("sleeping 2 seconds before permit.check() to make sure all writes propagated from cloud to PDP"); + Thread.sleep(2000); + + // positive permission check (will be true because elon is a viewer, and a viewer can read a document) + logger.info("testing positive permission check"); + assertTrue(permit.check( + User.fromString("auth0|elon"), + "read", + new Resource.Builder("document").withTenant(tenant.key).build() + )); + + logger.info("testing positive permission check with complete user object"); + assertTrue(permit.check( + userInput, + "read", + new Resource.Builder("document").withTenant(tenant.key).build() + )); + + // negative permission check (will be false because a viewer cannot create a document) + logger.info("testing negative permission check"); + assertFalse(permit.check( + User.fromString("auth0|elon"), + "create", + new Resource.Builder("document").withTenant(tenant.key).build() + )); + + // change the user role + permit.api.users.assignRole(user.key, admin.key, tenant.key); + permit.api.users.unassignRole(user.key, viewer.key, tenant.key); + + // list user roles in tenant + RoleAssignmentRead[] assignedRoles = permit.api.users.getAssignedRoles(user.key); + assertEquals(assignedRoles.length, 1); + assertEquals(assignedRoles[0].userId, user.id); + assertEquals(assignedRoles[0].roleId, admin.id); + assertEquals(assignedRoles[0].tenantId, tenant.id); + + logger.info("sleeping 2 seconds before permit.check() to make sure all writes propagated from cloud to PDP"); + Thread.sleep(2000); + + // run the same negative permission check again, this time it's true + logger.info("testing previously negative permission check, should now be positive"); + assertTrue(permit.check( + User.fromString("auth0|elon"), + "create", + new Resource.Builder("document").withTenant(tenant.key).build() + )); + } catch (IOException | PermitApiError | PermitContextError e) { + fail("got error: " + e); + } catch (InterruptedException e) { + fail("got interrupt: " + e); + } finally { + // cleanup + try { + permit.api.resources.delete("document"); + permit.api.roles.delete("admin"); + permit.api.roles.delete("viewer"); + permit.api.tenants.delete("tesla"); + permit.api.users.delete("auth0|elon"); + assertEquals(permit.api.resources.list().length, 0); + assertEquals(permit.api.roles.list().length, 0); + assertEquals(permit.api.tenants.list().length, 1); + assertEquals(permit.api.users.list().data.size(), 0); + } catch (IOException | PermitApiError | PermitContextError e) { + fail("got error: " + e); + } + } + } +} diff --git a/src/test/java/io/permit/sdk/PermitE2ETestBase.java b/src/test/java/io/permit/sdk/PermitE2ETestBase.java new file mode 100644 index 0000000..709093b --- /dev/null +++ b/src/test/java/io/permit/sdk/PermitE2ETestBase.java @@ -0,0 +1,59 @@ +package io.permit.sdk; + +import okhttp3.HttpUrl; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import java.io.IOException; +import java.net.InetSocketAddress; +import java.net.Socket; + +public abstract class PermitE2ETestBase { + protected final static Logger logger = LoggerFactory.getLogger(PermitE2ETestBase.class); + protected final PermitConfig config; + protected boolean skipTests = false; + private final static int connectionTimeout = 10; // 3 seconds to give up on sidecar / API + + public PermitE2ETestBase() { + final String token = System.getenv().getOrDefault("PDP_API_KEY", ""); + final String pdpAddress = System.getenv().getOrDefault("PDP_URL", "http://localhost:7766"); + final String pdpControlPlane = System.getenv().getOrDefault("PDP_CONTROL_PLANE", "http://localhost:8000"); + + this.config = new PermitConfig.Builder(token) + .withApiUrl(pdpControlPlane) + .withPdpAddress(pdpAddress) + .withDebugMode(true) + .build(); + + HttpUrl apiUrl = HttpUrl.parse(config.getApiUrl()); + HttpUrl pdpUrl = HttpUrl.parse(config.getPdpAddress()); + + try { + if (!isAddressReachable(apiUrl.host(), apiUrl.port(), connectionTimeout)) { + skipTests = true; + logger.warn(String.format("Permit API is not reachable (expected at address %s), SKIPPING TESTS.", config.getApiUrl())); + } + if (!isAddressReachable(pdpUrl.host(), pdpUrl.port(), connectionTimeout)) { + skipTests = true; + logger.warn(String.format("PDP is not reachable (expected at address %s), SKIPPING TESTS.", config.getPdpAddress())); + } + } catch (IOException e) { + e.printStackTrace(); + } + } + + private static boolean isAddressReachable(String address, int port, int timeout) throws IOException { + Socket socket = new Socket(); + try { + // Connects this socket to the server with a specified timeout value. + socket.connect(new InetSocketAddress(address, port), timeout); + // Return true if connection successful + return true; + } catch (IOException exception) { + // Return false if connection fails + return false; + } finally { + socket.close(); + } + } +} diff --git a/src/test/java/io/permit/sdk/PermitIntegrationTests.java b/src/test/java/io/permit/sdk/PermitIntegrationTests.java deleted file mode 100644 index f6f9834..0000000 --- a/src/test/java/io/permit/sdk/PermitIntegrationTests.java +++ /dev/null @@ -1,172 +0,0 @@ -package io.permit.sdk; - -import com.google.common.base.Strings; -import com.google.gson.Gson; -import io.permit.sdk.api.PermitApiException; -import io.permit.sdk.api.models.UserLoginResponse; -import io.permit.sdk.api.models.UserModel; -import io.permit.sdk.enforcement.Resource; -import io.permit.sdk.enforcement.User; -import okhttp3.HttpUrl; -import org.junit.jupiter.api.Test; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import java.io.IOException; -import java.net.InetSocketAddress; -import java.net.Socket; -import java.util.Random; - -import static org.junit.jupiter.api.Assertions.*; - -/** - * Sanity tests for basic usage of the SDK. - * - * These tests will only work against a running PDP. - * Therefore, they are not considered unit tests. - */ -class PermitIntegrationTests { - private final static Logger logger = LoggerFactory.getLogger(PermitIntegrationTests.class); - private final PermitConfig config; - private final static int connectionTimeout = 3; // 3 seconds to give up on sidecar - private final static int loggerSeparatorLength = 80; - private boolean skipTests = false; - - static Random rand = new Random(); - static String suffixedUserKey = "test|" + rand.nextInt(); - - private final static String roleKey = "captain"; - private final static String tenantKey = "tortuga"; - private final static String userKey = suffixedUserKey; - private final static String userEmail = "jack@pirates.com"; - private final static String userFirstName = "Jack"; - private final static String userLastName = "Sparrow"; - - public PermitIntegrationTests() { - String token = System.getenv("DEV_MODE_CLIENT_TOKEN"); - if (token == null) { - token = ""; - } - this.config = new PermitConfig.Builder(token) - .withDebugMode(true) - .build(); - - HttpUrl pdpUrl = HttpUrl.parse(config.getPdpAddress()); - - try { - if (!isAddressReachable(pdpUrl.host(), pdpUrl.port(), connectionTimeout)) { - skipTests = true; - logger.warn(String.format("PDP at address %s is not reachable, SKIPPING TESTS.", config.getPdpAddress())); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - private static boolean isAddressReachable(String address, int port, int timeout) throws IOException { - Socket socket = new Socket(); - try { - // Connects this socket to the server with a specified timeout value. - socket.connect(new InetSocketAddress(address, port), timeout); - // Return true if connection successful - return true; - } catch (IOException exception) { - // Return false if connection fails - return false; - } finally { - socket.close(); - } - } - - private static void logTestIsStarting(String testName) { - logger.info(Strings.repeat("-", loggerSeparatorLength)); - logger.info(String.format("Running test: %s", testName)); - logger.info(Strings.repeat("-", loggerSeparatorLength)); - } - - @Test void testPermitClientEnforcer() { - if (skipTests) { - return; - } - logTestIsStarting("permitCheckSucceeds"); - Permit permit = new Permit(this.config); - Boolean allowed = null; - try { - allowed = permit.check( - User.fromString(userKey), - "create", - Resource.fromString("document") - ); - } catch (IOException e) { - fail(e); - } - - assertTrue(allowed, "permit.check() should be true"); - } - - @Test void testPermitElementsLoginAs() { - if (skipTests) { - return; - } - logTestIsStarting("permitCheckSucceeds"); - Permit permit = new Permit(this.config); - UserLoginResponse loginAs = null; - try { - loginAs = permit.elements.loginAs("raz@permit.io", "fafb66f9c98647ad954f129b9f2b1c84"); - } catch (IOException e) { - fail(e); - } catch (PermitApiException e) { - e.printStackTrace(); - } - - assertNotNull(loginAs.redirectUrl); - assertNotNull(loginAs.content); - } - - @Test void testPermitApiUserLifecycle() { - if (skipTests) { - return; - } - logTestIsStarting("checkGetUser"); - - // objects to setup; - User testUser = new User.Builder(userKey) - .withEmail(userEmail) - .withFirstName(userFirstName) - .withLastName(userLastName) - .build(); - - // init the client - Permit permit = new Permit(this.config); - Gson gson = new Gson(); - - // create user lifecycle - try { - // check if the test user exists - expect null - UserModel user = permit.api.getUser(testUser.getKey()); - assertNull(user); - // returned user after syncUser - user = permit.api.syncUser(testUser); - assertNotNull(user); - assertEquals(user.customId, userKey); - assertEquals(user.email, userEmail); - assertEquals(user.firstName, userFirstName); - assertEquals(user.lastName, userLastName); - // getUser now returns the synced user - user = permit.api.getUser(testUser.getKey()); - assertNotNull(user); - assertEquals(user.customId, userKey); - assertEquals(user.email, userEmail); - assertEquals(user.firstName, userFirstName); - assertEquals(user.lastName, userLastName); - // delete the user - boolean deleted = permit.api.deleteUser(testUser.getKey()); - assertTrue(deleted); - // user will be null again - user = permit.api.getUser(testUser.getKey()); - assertNull(user); - } catch (IOException | PermitApiException e) { - fail("got error: " + e); - } - } -} diff --git a/src/test/java/io/permit/sdk/RolesApiE2ETest.java b/src/test/java/io/permit/sdk/RolesApiE2ETest.java new file mode 100644 index 0000000..5ee295c --- /dev/null +++ b/src/test/java/io/permit/sdk/RolesApiE2ETest.java @@ -0,0 +1,117 @@ +package io.permit.sdk; + +import com.google.gson.Gson; +import com.google.gson.internal.LinkedTreeMap; +import io.permit.sdk.api.PermitApiError; +import io.permit.sdk.api.PermitContextError; +import io.permit.sdk.openapi.models.RoleCreate; +import io.permit.sdk.openapi.models.RoleRead; +import io.permit.sdk.openapi.models.RoleUpdate; +import org.junit.jupiter.api.Test; + +import java.io.IOException; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * this e2e test should run against a clean permit environment. + * if the environment contains any objects the test will fail. + * eventually we want to create an environment programmatically + * and then extract the api key and start the test. + */ +public class RolesApiE2ETest extends PermitE2ETestBase { + @Test + void testRolesApi() { + // init the client + Permit permit = new Permit(this.config); + Gson gson = new Gson(); + + // roles lifecycle + try { + // list + RoleRead[] emptyRoles = permit.api.roles.list(); + assertEquals(emptyRoles.length, 0); + + // create + RoleRead admin = permit.api.roles.create( + new RoleCreate("admin","Admin").withDescription("an admin role") + ); + assertNotNull(admin); + assertEquals(admin.key, "admin"); + assertEquals(admin.name, "Admin"); + assertEquals(admin.description, "an admin role"); + + + RoleRead viewer = permit.api.roles.create( + new RoleCreate("viewer","Viewer").withDescription("an viewer role") + ); + assertNotNull(viewer); + assertEquals(viewer.key, "viewer"); + assertEquals(viewer.name, "Viewer"); + assertEquals(viewer.description, "an viewer role"); + + RoleRead[] roles = permit.api.roles.list(); + assertEquals(roles.length, 2); + assertEquals(roles[0].key, "admin"); + assertEquals(roles[0].name, "Admin"); + assertEquals(roles[1].key, "viewer"); + assertEquals(roles[1].name, "Viewer"); + + // get + RoleRead role = permit.api.roles.get("admin"); + assertNotNull(role); + assertEquals(role.key, "admin"); + assertEquals(role.name, "Admin"); + + // get 404 no such role + PermitApiError notFoundError = assertThrows(PermitApiError.class, () -> { + permit.api.roles.get("editor"); + }); + assertEquals(notFoundError.getMessage(), "Got error status code: 404"); + assertEquals(notFoundError.getResponseCode(), 404); + LinkedTreeMap error = notFoundError.getErrorObject(); + assertEquals(error.get("error_code"), "NOT_FOUND"); + assertTrue(error.get("message").toString().startsWith("The requested data could not be found")); + + // delete + try { + permit.api.roles.delete("admin"); + } catch (PermitApiError e) { + fail("got error: " + e); + } + + roles = permit.api.roles.list(); + assertEquals(roles.length, 1); + assertEquals(roles[0].key, "viewer"); + assertEquals(roles[0].name, "Viewer"); + assertEquals(roles[0].description, "an viewer role"); + + // update + permit.api.roles.update("viewer", new RoleUpdate().withDescription("new description")); + + roles = permit.api.roles.list(); + assertEquals(roles.length, 1); + assertEquals(roles[0].key, "viewer"); + assertEquals(roles[0].name, "Viewer"); + assertEquals(roles[0].description, "new description"); + + // delete + try { + permit.api.roles.delete("viewer"); + } catch (PermitApiError e) { + fail("got error: " + e); + } + + roles = permit.api.roles.list(); + assertEquals(roles.length, 0); + + // we already deleted this + PermitApiError exception = assertThrows(PermitApiError.class, () -> { + permit.api.roles.delete("viewer"); + }); + assertEquals(exception.getResponseCode(), 404); + } catch (IOException | PermitApiError | PermitContextError e) { + fail("got error: " + e); + } + } +}